APGen Documentation Previous Topic: APGen.RunArgs() Next Topic: APGError Object Parent Topic: APGen Object    APGen Object
APGen.OpenScript()
See Also:

The OpenScript()method opens an APG script file and returns an APGScript object.

Syntax

VBScript:

Set oAPGScript = oAPGen.OpenScript( strScriptPath )

JScript:

oAPGScript = oAPGen.OpenScript( strScriptPath );

Object

oAPGen An APGen object.

Parameters

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.

Return Value

oAPGScript An APGScript object.

Notes

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.

Example

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

Applies To

APGen Object