Global Variables and Procedures

When adTempus runs a script, the script has access to several global properties, collections, and functions.

Properties

Result Property

The Result property is a Variant property used to return a result to adTempus. The values that are valid will depend on the circumstances; in places where adTempus expects a result from a script, the documentation will indicate the value that should be returned. See, for example, the Script Execution task.

Checkpoint Property

The Checkpoint property is a String property that can be used to get or set the current checkpoint for the job. This is only meaningful for a script being run by a Script Execution task.

Collections

Environment Collection

The Environment collection contains the environment variables for a job. The environment variables are loaded at the beginning of the job, and the same environment is used for all steps of the job. Therefore modifying the values in this collection in one step will affect all subsequent steps.

Note that this environment does not include any additional environment variables defined for a Program Execution task.

The Environment collection has the following properties and methods:

Item

Gets or sets an environment variable. For example:

path=Environment.Item("path")
path=Environment("path")

Environment.Item("somekey")="somevalue"
Environment("somekey")="somevalue"

 

for i=1 to Environment.Count

   var=Environment(i)

next

If the variable already exists, its value is replaced. If the variable does not exist it is added.

Count

Returns the number of variables in the collection

Remove

Removes the variable with the specified key or index:

Environment.Remove("somekey")

Environment.Remove(1)

Functions

ActivateWindowWithTitle title

The ActivateWindowWithTitle function is similar to the AppActivate method of the Windows Script Host WshShell object. It activates (brings to the top and makes active) the window with the specified title.

For example, to activate a Notepad window:

ActivateWindowWithTitle "Untitled - Notepad"

Note that the application must already be running, and the title you specify must exactly match the title shown in the window's title bar.

ActivateWindowWithTitle returns True if the window was activated, False if it was not.

The WshShell AppActivate method does the same thing. However, that method apparently does not restore minimized windows, which means that they cannot accept keystrokes. Our ActivateWindowWithTitle function restores the window if it is minimized, and then activates it, leaving it ready to accept keystrokes.

ActivateWindowWithHandle handle

The ActivateWindowWithHandle function activates the window with the specified Windows handle. This function is primarily useful in conjunction with the GetTaskMainWindow function.

ActivateWindowWithHandle returns True if the window was activated, False if it was not.

GetTaskMainWindow

The GetTaskMainWindow function is only valid when run as an action within a step that executes a Program Execution task. It returns the handle of the main window of the application that adTempus launched, which can be used by ActivateWindowWithHandle to activate the window.

For an example, see the Sending Keystrokes to an Application topic.

GetTaskMainWindow returns 0 if the application does not have a window or if it is run other than in a step that runs a Program Execution task.