Script Processing

Scripts are processed when the object is activated or started. The time at which the script is processed depends on object attributes. The order in which scripts are processed in an object depends on which Process pages the scripts are on.

This page includes the following:

Execution Stages

Scripts are processed when the task is generated. It is important that you understand the stages of execution that a task goes through. The task is activated, generated, and finally executed. Tasks may be generated immediately after activation, or later. The object definition and settings such as scheduling determine when the task is generated. For more information, see Execution Stages.

Time of Processing

The following options in the Attributes of the object determine when the task is generated and the script is processed:

Example

The following script uses a function to set the value of a variable to the current date and time:

:SET &CURRENTTIME# = SYS_TIME()

The actual date and time that the script returns depend on the point in time at which the task is generated. Assume that you have two tasks that are configured differently:

For more information about object attributes that concern generation, see Attributes Page.

Important! If you exit the AWI after starting an object that is configured to be generated at activation, script generation may not have finished. If the script includes elements that require action, such as a :READ statement, you may not get the desired results.

Order of Processing

Depending on the type of object, the task may have more than one Process page on which you can write scripts. The scripts in the Process pages are processed in the following order:

  1. Pre-Process page and Process page
  2. Child Post Process page
  3. Post Process page

For more information, see Process Pages.

Processing In Scripts

The Automation Engine processes scripts line by line. The results of executed script elements (such as the value of a variable that has been set) are regularly written to the AE database. This process is referred to as a commit. Other scripts can only access these new or modified values after the values have been committed.

When scripts run for longer times, the Automation Engine automatically makes a commit every 5 seconds. In addition, some script elements that require processes to complete also result in commits.

Examples

Some script elements start or stop tasks, and wait for the RunID of the task to be returned, therefore resulting in a commit. The following functions are examples of such script elements:

Some script statements require user interaction. The system waits for the user to react, so script statements such as the following also result in a commit:

The :WAIT script statement instructs the system to wait for a specific length of time, and also results in a commit.

Tip: Use :WAIT to enforce a commit.

See also:

seealso

Functional Logic with Scripts

Writing Scripts

Script Elements Ordered by Purpose

Alphabetical List of Script Statements and Functions