18.01.2015 Views

Technical Reference Manual - InduSoft

Technical Reference Manual - InduSoft

Technical Reference Manual - InduSoft

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Overview of VBScript<br />

• On the Insert tab of the ribbon, in the Task Worksheets group, click Script;<br />

• Right-click the Script folder in the Project Explorer, and then click Insert on the shortcut menu; or<br />

• Click New on the Application menu, click the File tab, and then select Script Worksheet.<br />

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

Script worksheet<br />

The code configured in each Script worksheet is executed by the Background Task. The project scans<br />

the worksheets sequentially (based on the worksheet number) and executes only the groups in which the<br />

condition configured in the Execution field of the worksheet is TRUE (i.e., non-zero).<br />

Note: You must use the syntax supported by the Built-in Scripting Language in the Execution field.<br />

Only the body of the worksheet supports VBScript.<br />

Variables declared in the worksheet have local scope for that specific group only. They are not available for<br />

any other VBScript interface.<br />

You cannot define procedures (i.e., functions and subs) in the Script worksheet. However, you can call<br />

procedures defined in the Global Procedures or in the Startup Script.<br />

Example:<br />

'Variables available only for this group can be declared here<br />

Dim myVar, myTest<br />

myTest = 1<br />

'The code configured here is executed while the condition configured in the Execution<br />

field is TRUE<br />

myVar = $FindFile("c:\*.txt")<br />

If MyVar > 0 Then<br />

$TagNumOfFiles = myVar<br />

End If<br />

Caution: When any Script worksheet is saved during runtime (on-line configuration), the Startup<br />

Script will be executed again and the current value of the local variables of any Script worksheet will<br />

be reset.<br />

<strong>InduSoft</strong> Web Studio Page 771

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!