4) When
include cannot find the specified file there is an error dialog:
Error at include: The system cannot find the file specified.
include "Lib"
The only option available to the user is "OK" which continues script execution.
I think it would be better if include was elevated to a full command similar to
assert:
Code: Select all
include file, [message], [continue=0]
This way we can customize the message to tell the user where to get the include file and prevent continuing.
5) Similarly, calling a non-existent UDF shows the stepping dialog with the error:
'test::bad' is not a valid script command.
The default action when that dialog is shown is to continue which doesn't seem like the best option. To complicate matters, if the script is storing the return value of that UDF:
No error is shown as it is assumed that the right-hand side of the '=' is a string, thus
$ret is set to "Test::bad()".
6)
include should really follow the same relative path resolution rules that
load does:
::help('idh_scripting_comref.htm#idh_sc_load'); wrote:(1) in the path of the calling script file (if any)
(2) in the Scripts subfolder of the application data path (variable <xydata>\Scripts)*
(3) in the application data path (variable <xydata>)
* And I sincerely hope the documentation is wrong as #2 should be checking <xyscripts> which may not be the same as <xydata>\Scripts.
7) In general we need some better error handling for detecting missing includes and UDFs.
Maybe that's in the form of
try-catch:
Code: Select all
try {
Test::bad();
} catch ($msg) { // on error - no dialog is shown, instead $msg is set to the error that would have been displayed.
End true, $msg;
}
Or maybe it is in the form of some preemptive functions?
Code: Select all
FunExists(functionName);
// Returns true if functionName exists.
// If functionName is just a namespace 'Test::', returns true if any functions in that namespace are present.
The name should probably be better but I couldn't resist the chuckles.
Or maybe it is a special user function which gets run automatically when a file is included - similar to
_Initialize - in this "init" function we can set variables which can be used to detect when the file is included.