|
APGScript Object |
|
See Also: |
APGScript.Run() executes the script.
VBScript:
JScript:
| oAPGScript | An APGScript object. |
The first time an APGScript is Run(), the script file is loaded and preprocessed, its include files are loaded and preprocessed, and the assembled script is delivered to script engines and compiled. Next, all global code is run. Lastly, if a procedure named Main exists, it is called.
The second and later times an APGScript is Run(), the global code is executed, and then the procedure Main (if one exists) is executed. The script loading, preprocessing, and compiling does not occur more than once with the same APGScript object.
If a fatal error occurs while loading, preprocessing, compiling, or running the script, an error is raised by Run(). Detailed error information can be obtained by calling APGScript.GetLastError() and examining the APGError object.
There is a way to prevent Run() from raising an error when a fatal error occurs in the script: Write a custom error handler, and in the custom error handler either:
This example uses APGScript.Run() to run the script hello.apg.
<%#
Dim oAPGen, oScript
Set oAPGen = CreateObject("APGen")
Set oScript = oAPGen.OpenScript("hello.apg")
' Begin error handling, in case hello.apg raises a fatal error
On Error Resume Next
' Run the script
oScript.Run
' End error handling
On Error Goto 0
#%>