EXECUTEGLOBAL(string)
Description
EXECUTEGLOBAL executes one or more statements in the global namespace of a script. The required parameter, string, can be either a string expression or the name of a file containing statements that is executed. If multiple statements are to be executed, separate them with a carriage return (vbCRLF) or colon. All statements used with EXECUTEGLOBAL are executed in the program's global namespace. This allows code to be added to the program so that any procedure can access it. For example, a CLASS statement can be executed at run time and functions can subsequently create new instances of the class.
Adding procedures and classes at runtime can be useful, but also introduces the possibility of overwriting existing global variables and functions at runtime If you don't need access to a variable or function outside of a procedure, use the EXECUTE statement that will only affect the calling function.
Example
REM EXECUTEGLOBAL Example
'EXECUTEGLOBAL executes a string as a SUB
DIM x
x = ("DIM y" & vbcrlf & "y = 4 * 10" & _
vbcrlf & "Print y")
EXECUTEGLOBAL x
Output
40
Related Items
EVAL, EXECUTE