Script worksheet

A Script worksheet is used to implement program logic (using VBScript) that should be continuously executed during runtime, rather than on specific actions like the user pressing a button on a screen.

Note: The Script worksheet is functionally similar to the Math worksheet, except that it uses VBScript instead of the Built-in Scripting Language.
To create a new Script worksheet, do one of the following:

To edit an existing Script worksheet, double-click it in the Project Explorer.

Figure 1. Script worksheet

The code configured in each Script worksheet is executed by the Background Task. The project scans the worksheets sequentially (based on the worksheet number) and executes only the groups in which the condition configured in the Execution field of the worksheet is TRUE (i.e., non-zero).

Note: You must use the syntax supported by the Built-in Scripting Language in the Execution field. Only the body of the worksheet supports VBScript.

Variables declared in the worksheet have local scope for that specific group only. They are not available for any other VBScript interface.

You cannot define procedures (i.e., functions and subs) in the Script worksheet. However, you can call procedures defined in the Global Procedures or in the Startup Script.

'Variables available only for this group can be declared here
Dim myVar, myTest
myTest = 1

'The code configured here is executed while the condition configured in the Execution field is TRUE
myVar = $FindFile("c:\*.txt")
If MyVar > 0 Then
  $TagNumOfFiles = myVar
End If
When any Script worksheet is saved during runtime (on-line configuration), the Startup Script will be executed again and the current value of the local variables of any Script worksheet will be reset.