APGen Documentation Previous Topic: Output.Close() Next Topic: Script.Values Collection Parent Topic: APGen Object Reference    APGen Object Reference
Script Object
See Also:

The Script object encapsulates the currently running APG script.

Syntax

Script[ (key | index) | .collection | .property | .method ]

Collection Parameters

key A string key to the Values collection.
index A zero-based index to the Values collection.

Collections

Values The default collection for the Script object.
Arguments A collection containing arguments passed to the script.

Events

Error This event fires when an error (syntax, runtime, or component) occurs while running the script.

Properties

Filename String Returns the filename of the root APG script.
Dir String Returns the directory of the root APG script.
Path String Returns the complete path of the root APG script.
LastModified Date/Time Returns the most recent date/time that any of the source files were modified.
Debug True/False Returns whether script errors cause error dialogs and Just-In-Time debugging.  Default value is True.
Waiting True/False Returns whether the script is currently in a Script.Wait() statement.
OnError Function Sets a script (IDispatch) function to be called when an error occurs.

Methods

Abort() Halts execution of the script.
CreateObject() Creates a COM object, and optionally activates script event handling for the object.
ConnectEvents() Connects script event handling to an object.
DisconnectEvents() Disconnects script event handling for an object.
GetLastError() Returns the APGError object for the last error that occurred.
Wait() Waits for a specified interval, or until StopWait() is called.
StopWait() Interrupts a Wait() call.

Notes

The Script object is an intrinsic object available to running APG scripts.  This object contains information and functionality that pertains to the currently running script.

The APGScript interface is a superset of the Script object's interface.  The APGScript interface and the intrinsic Script  object represent two sides of the same object.  The APGScript interface is used to manipulate APG scripts from outside of the script code.  The Script object is used in script code.  See APGen Object Model for a diagram.

The following example uses the Script object and an external APGScript object.  The external APGScript object is named oExternalScript, and is obtained using APGen.OpenScript().

<%#
' Open ExternalScript.apg
Dim oAPGen, oExternalScript
Set oAPGen = CreateObject("APGen")
Set oExternalScript = oAPGen.OpenScript("ExternalScript.apg")

' oExternalScript now holds an APGScript object

' Check a value held in Script
If (Script("RunExternalScript") = True) Then  

    ' Set a value held in the external script 
    oExternalScript("RunExternalScript") = False

    ' Run the external script
    oExternalScript.Run

End If
#%>

Values can be stored in a script object, using the Script(variable)  syntax.  For more information, see the Script.Values collection topic.

To use the Script object in C++, see the IAPGInnerScript interface in <install dir>\include\APGen.h.