omron — Global Procedures

Appendix: VBScript When writing your code in a VBScript interface, you can access any tag from the IWS tags database or any function from the Built-in Scripting Language by applying the "$" prefix to the tag/function name, as in the examples below: $Time 'Returns the value of the tag Time from the tags database $MyTag 'Returns the value of the tag MyTag from the tags database $Open("main") 'Executes the Open() built-in function to open the "main" screen Therefore, you can create scripts using built-in functions from IWS, tags from the IWS tags database, VBScript functions, VBScript variables, ActiveX properties, methods or events, and any other interface available.

The IWS tags are shared by all modules from IWS, including the Graphic Module and the Background Task. Global Procedures This Global Procedures interface is used create a library of VBScript functions and sub-routines that can be called by any other scripting interface in IWS. The procedures declared here are never directly executed during runtime; they must be explicitly called by another script. Caution: IWS will not prevent you from declaring two or more functions with the same name. (This includes functions imported from external files; see "Importing Functions from an External File" below.) However, if you do, then your project may behave unexpectedly during runtime.

Make sure that all of your functions are named correctly. To use the Global Procedures interface: 1. In the Global tab of the Project Explorer, right-click the Global Procedures folder and choose Open from the shortcut menu. Global Procedures - Open option The Global Procedures interface is displayed. Global Procedures Interface 2. Declare your functions and sub-routines in the interface. For example: Option Explicit 'Keep the Option Explicit statement in the first line of this interface.

'Procedures with global scope can be implemented here 'Global variables are NOT supported in this interface Sub MyMessage(message) MsgBox(message,0) End Sub Function MyAdd(number1, number2) MyAdd = number1 + number2 Call MyMessage("The sum is" & MyAdd & ".") End Function Page 642 InduSoft Web Studio