|
APGen Object |
|
See Also: |
The OpenScript()method opens an APG script file and returns an APGScript object.
VBScript:
JScript:
| oAPGen | An APGen object. |
| strScriptPath | The path of the APG script to be loaded. If strScriptPath is a relative path, it is resolved using the current drive and directory. |
| oAPGScript | An APGScript object. |
If the script strScriptPath is not found, an error is raised.
When an APG script will be run more than once, you should call APGen.OpenScript() to open the script, and APGScript.Run() or APGScript.RunArgs() to run the script each time. Using this method, you will only incur the overhead of loading, parsing, and compiling the script once. If you repeatedly call APGen.Run() with a single script, you will be loading, parsing, and compiling the script each time. The following example shows the proper technique.
This VBScript snippet runs a "test.apg" script several times with different arguments.
Dim oApgen, oApgScript
Set oApgen = CreateObject("APGen")
' Load/parse the script
Set oApgScript = oApgen.OpenScript("test.apg")
Dim rgArgs, strFruit
rgArgs = Array("apple", "banana", "orange", "pear")
For Each strFruit In rgArgs
oApgScript.RunArgs strFruit
Next