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:
- Generate Task at: Activation time: the script is processed immediately when the object is activated.
- Generate Task at: Runtime: the script is processed when the object executes.
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:
-
Task A is configured to be generated at activation time. The value of the variable is set immediately upon activation.
-
Task B is configured to be generated at runtime. The task is in a workflow that has several preceding tasks before Task B. Task B is generated when the preceding tasks have finished. The value of the variable is set to the actual time when the task is generated.
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:
- Pre-Process page and Process page
- Child Post Process page
- 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: