QuickScripts
QuickScripts is the name of the scripting language and functionality used in the InTouch environment. The actual scripting language is very similar to PLC languages like IEC611-31 and Structured Text. InTouch QuickScript capabilities allow you to execute commands and logical operations based on specified criteria being met, such as when a key is pressed, a window opens, or a value changes. All InTouch QuickScripts are event-driven, such as a data change, a condition, a mouse click, or a timer.
The order of processing is application specific. While it may appear that there is some inherent order in the way multiple scripts initiated by the same event are scheduled, there is no guarantee of any specific order. Therefore, when using QuickScripts, you should not build any dependency on the order of processing.
Script Type | Description |
Application | Scripts linked to the entire application |
Window | Scripts linked to a specific window |
Key | Scripts linked to a specific key or key combination on the keyboard |
Touch Action | Scripts associated with an object linked to a |
Touch Link – Touch Pushbutton – Action animation link | |
Data Change | Scripts linked to a tagname and/or tagname.field only |
Condition | Scripts linked to a discrete tagname or expression |
ActiveX Event | Scripts that execute ActiveX control events in Runtime |
QuickFunctions | Scripts you create that can be called from other InTouch QuickScripts or |
animation link expressions. QuickFunctions can be either synchronous or | |
asynchronous, while all other script types are synchronous only |
Application Scripts Application Scripts are linked to the entire application. They can be used to start other applications, create process simulations, calculate variables, and so on. There are three types of Application Scripts.
On Startup: Executes once when the application is initially started up. Executes beforeany window opens or any Runtime initialization occurs. You cannot refer to ActiveX methods, properties or events in an On Startup script. I/O communications are initialized after the Application On Startup script executes. I/O-type tags or remote tagname references cannot be referred to in an On Startup script.
While Running: Executes repeatedly at the specified frequency while the application isrunning. When a While Running script is selected, the Every Msec field becomes active. The field contains the number of milliseconds that must elapse before the script executes. The script will repeatedly execute at the specified frequency. To execute the script immediately, create an identical On Startup script. As long as the condition or event for the While Running script is met, the script will repeatedly execute at the specified frequency.
On Shutdown: Executes once when the application is closed. I/O-type tags and remotetagname references will not update in an On Shutdown script. On Shutdown script cannot be used to startup other applications.
Window Scripts
Window Scripts function within a specific window.
There are three types of Window scripts.
On Show: Executes once when the window is initially opened.
While Showing: Executes repeatedly at the specified frequency while the window isshowing. When While Showing is selected, the Every Msec field becomes active. The field contains the number of milliseconds that must elapse before the script executes. To execute the script immediately, create an identical On Show script. As long as the condition or event for the While Showing script is met, the script will repeatedly execute at the specified frequency.
On Hide: Executes once when the window is hidden.
Key Scripts Key Scripts execute on a specific key or key combinations on the keyboard. They can be used to create global keys for the application, such as returning to a main menu window, logging off the operator, and so on.
There are three types of Key Scripts:
On Key Down: Executes once when the key is initially pressed.
While Down: Executes repeatedly at the specified frequency while the key is held down. When While Down is selected, the Every Msec field is active. The field contains the number of milliseconds that must elapse before the script executes.
To execute the script immediately, create an identical On Key Down script. As long as the condition or event for the While Down script is met, the script will repeatedly execute at the specified frequency.
On Key Up: Executes once when the key is released.
Note: The key equivalents used in the local active windows for Touch Pushbutton – Action scripts override any global Key Scripts with the same key equivalents.
Touch Action Scripts
Touch Action Scripts are similar to Key Scripts, except they are associated with an object linked to a Touch Link – Touch Pushbutton – Action (access the script editor through the animation link selection dialog box.) They are executed when the operator clicks or presses the object or button assigned to the link.
There are thirteen types of Touch Action Scripts.
The following Touch Action Scripts execute once when the key or button is initially pushed down:
On Left Click/Key DownOn Right ClickOn Center Click
The following Touch Action Scripts execute repeatedly at the specified frequency while the key or button is held down. When this is selected, the Every Msec field is active. The field contains the number of milliseconds that must elapse before the script executes.
While Left/Key DownWhile Right DownWhile Center Down
The following Touch Action Scripts execute once when the key or button is released:
On Left/Key UpOn Right UpOn Center Up
The following Touch Action Scripts execute when the mouse button is double clicked. The key equivalent feature disables when these are selected, since there is no keyboard equivalent for a mouse button double-click action.
On Left Double ClickOn Right Double ClickOn Center Double Click
The following Touch Action Scripts executes one time when the cursor rests over an object. Script is delayed with the After X msec field. After X msec is the length of time the cursor must be over the object before the script executes. The key equivalent feature is disabled when this condition type is selected, since there is no keyboard equivalent for moving the mouse cursor over an object.
On Mouse Over
Note: If any object or action pushbutton in the active window is assigned to the same key used for a Key Script, the key equivalent link on the key in the active window will take precedence over the execution of the Key script.
Assigning a Key Equivalent to a Script
The Key Script editor is different from the other QuickScript editors. Since you are creating scripts that apply to a key, you must specify the key(s) the operator will press to execute the script. Assigning key equivalents to scripts is discussed in Module 4 Section 2, “Animating Objects.”
Data Change Scripts
Data Change Scripts are linked to a tagname and/or tagname.field only.
They are executed once when the value of the tagname or tagname.field changes by a value greater than the value deadband defined in the Tagname Dictionary. Since Data Change Scripts are executed based on a change in a data value, you must specify a tagname or tagname.field in the Tagname[.field] box.
Condition Scripts
Condition Scripts are linked to a discrete tag or expression that equates to TRUE or FALSE. This type of script is the most widely used script type. Discrete expressions containing analog tagnames can also be used.
Since Condition Scripts are executed based on a condition being met, you must specify the condition (a discrete tag or expression) in the Condition box. The expression would equate a condition related to a tag to TRUE or FALSE.
For example:
TankLevel >= 75.
When the value of TankLevel is greater than or equal to 75, the script will execute.
Note: The value for the condition must transition to become true or false before the script will execute. For example, if the initial value when WindowViewer starts is true, the value must become false and then true again for an On True script to execute.
There are four types of scripts that can be applied to a condition:
On False: Executes once when the condition transitions to false.
While False: Executes repeatedly while the condition is false. Frequency of execution is based upon the value of the Every Msec field.
On True: Executes once when the condition transitions to true.
While True: Executes repeatedly while the condition is true. Frequency of execution is based upon the value of the Every Msec field.
Both While True and While False scripts begin executing after the specified number of milliseconds have elapsed. To cause immediate execution, create duplicate On True and/or OnFalse scripts.
All four script types can be applied to the same condition.
ActiveX Event Scripts Most ActiveX controls have events associated with them. For example, click, double-click, mouse down, and key press are typical events used in many ActiveX controls. InTouch ActiveX Event scripts support event actions. You can associate one ActiveX Event script to each event. Execute ActiveX control events in Runtime (WindowViewer).
QuickFunctions QuickFunctions are scripts that are called from other scripts and animation link expressions. The code is stored in one location, allowing all script instances to be updated with one edit session. Reusing QuickFunctions decreases your application maintenance by reducing the amount of duplicate code that is copied and pasted over and over into scripts. The reused code is stored in one script and in one location, thereby supporting update of all script instances with one edit session.
QuickFunctions can be defined as asynchronous, so that, when executed, they will run in the background of the main WindowViewer (Runtime) process. This functionality allows WindowViewer to separate time consuming operations (such as SQL database calls) from the main program flow.
When a resource-consuming operation needs to be performed, an asynchronous QuickFunction provides an efficient method for all animation links and other InTouch functionality to remain active while the operation executes. Animation link expression boxes are limited to 1023 characters. However, you can create a more complex QuickFunction and then call it from an animation link expression box.
This enables the developer to use the CALL statement to call a complex script that contains a RETURN statement that returns the result back to the expression.
For example, when several tagnames of 30 characters each are added (using “&” and “:“) together, you can only use 8 tagnames (plus spaces) in the expression. However, by using the statement, CALL MYSCRIPT($Second), in the expression, you can execute a QuickFunction that might contain hundreds of 30 character tagnames. This QuickFunction will use the RETURN statement to provide a value back to the expression.
Note: A “trigger” tagname must be used as a parameter for the QuickFunction to force an Animation Link to update. For example, using the tagname $Second as the parameter for the QuickFunction will cause the expression for the Animation Link to be evaluated every time $Second changes value. This results in the QuickFunction being called every second.
Once you create a QuickFunction and save it, you can immediately call it from any other script or expression by its name.
The name can be up to 31 characters in length. Blank spaces and duplicate names cannot be used. This is the name that other QuickScripts or expressions will use to call the QuickFunction. This name will also appear in the Choose function dialog box when you click eitherthe All or the Quick buttons in the QuickScript editor.
Arguments fields contain each argument name for your QuickScript. The valid data types include the following.
Data Type | Description |
Integer | Used to pass integer variable, tagname, or constant values |
Real | Used to pass real variable, tagname, or constant values |
Discrete | Used to pass discrete variable, tagname, or constant values |
Message | Used to pass string variable, tagname, or constant values up to 131 |
characters |
The following are reserved keywords that should not be used as argument names: Return, Call, Dim, As, Integer, Real, Discrete, Message.
Argument names are local variables that exist only within the QuickFunction in which they are defined. You can use up to 16 arguments per QuickFunction.
The argument names can be up to 31 characters in length and spaces cannot be used. The argument names must also begin with an alpha character (A-Z). Duplicate names cannot be used. Do not use tagnames for argument names. Tagnames take precedence over argument names that are the same name and your QuickScript will not execute properly. An argument name does not consume a tag count because they are treated as local variables.
QuickFunction Arguments
Script parameters are passed by value. Argument expressions can be any script expression that returns an integer, real, discrete, or message data type value. All argument expression values are resolved by the calling script before executing the QuickFunction.
Examples:
CALL Stuff (5.6, 237, “PI”); In this expression, the real constant 5.6 is passed as argument1, the integer constant 237 as argument 2, and the message constant “PI” as argument 3.
CALL Temp (IntegerTag); IntegerTag is passed as argument expression value.
CALL ValveOpen (Tag.MaxEU -5); Calculated value (Tag.MaxEU -5) is passed as an argument expression value.
Argument Data Type Matching
There must be a strict left- to right correspondence between the data types of the calling statement’s argument list andthe data types of the saved QuickFunction being called.
There must also be an exact number of arguments to match the number of arguments in the saved QuickFunction argument list as well.
Coercion is used to type-cast Real values to Integer and Integer values to Real. This ability to modify the type of a value allows any analog argument to be passed to any other analog types.
For example, if you pass a Real value of 1.23 to an Integer argument it will use only the 1 and the .23 will be lost. Similarly, if you pass an Integer value of 1 to a Real argument it will promote the 1 to 1.0. However, despite this coercion capability we recommend that you make a strict match of calling argument types to the corresponding QuickFunction argument list.
Valid QuickFunction Syntax
QuickFunctions return a value. The QuickFunction statement syntax and form are as follows:
CALLQuickFunctionName ( [arg1, … arg16] );
where:
CALL is the required keyword in all QuickScripts and expressions to call a QuickFunction.
QuickFunctionName is a 1 to 31 character string that corresponds to the name assigned to the saved QuickFunction.
( [arg1, …arg16] ) are 0 to 16 comma separated argument expressions enclosed in parentheses.
Using the Return Statement
A QuickFunction is a script that can be called from another script (calling script).
The following is an example of a script that is calling a QuickFunction:
RETURNRESULT = CALL MyFunction( StartHour, EndHour);
The RETURN statement is used by a QuickFunction to force a value to be returned to the calling script.
When RETURN is encountered, an immediate end to the execution of the QuickFunction occurs. At this point, the QuickFunction returns a value back to the calling script. The data type returned can be a discrete, integer, real or message.
In the example above, the tag RETURNRESULT can be a discrete, message, integer, or real type tag to receive the transferred value.
In the following example, if the tagname ConvertType is equal to 0, the expression abs( (Max / Maxprogress) * 100 ) is calculated and this data type real result is returned to the calling script.
IF ConvertType == 0 THENRETURN abs( (Max / Maxprogress) * 100 );ELSERETURN 0;ENDIF; The data type of the return value is determined by the context. For example: RETURN AnalogTag; If the Tagname, AnalogTag, is defined as a Memory Integer, the RETURN statement will send an analog value back to the calling location. Only one value can be returned.
Section Objectives
Introduce the QuickScript Editor
Identify the different script functions and keywords
This section describes common features and functions of the QuickScript Editor. The features and functions that are unique to a particular script type are described later in this section.
Open the QuickScript Editor
Opening a QuickScript Editor to create a new script can be performed from the Special menu, or from the Application Explorer. From the Application Explorer:
Rightclick the QuickScript type and select Open or New. Some QuickScript types do not include the New command on the sub-menu. Note: Existing QuickScripts are displayed in the Application Explorer hierarchy view under their respective QuickScript type icons.
The InTouch QuickScript Editor displays the same basic interface for all script types:
The QuickScript Toolbar
The QuickScript toolbar performs basic editing functions.
The QuickScript Editor can be resized to increase the area for typing in scripts. Resize the editor by dragging the borders, or click the Maximize button to maximize the Editor in monitor screen.
QuickScript Editor Common CommandsScript Menu Options
The Script menu contains the common windows commands New, Save, Print, and Exit. In addition, the Erase command is used to completely delete the script. Script Menu Options
Undo: Your last editing operation is reversed.
Select All: The entire script is selected.
Cut: Select the text to remove. The cut text is deleted from the script and copied to the Windows Clipboard. You can now paste the cut text into another location in this script or into another script.
Copy: Select the text to be removed. The text is copied to the Windows Clipboard. You can now paste the copied text into another location in this script or into another script.
Note: When text is cut or copied, it is automatically written to the Windows Clipboard. This information remains on the Clipboard until a subsequent cut or copy command is performed.
\Paste: The contents of the Windows Clipboard is pasted into your script at the cursor location.
Clear: All text in the script is erased. However, the script is not deleted from your application. If you select this command, cancel the script editor and then reopen it, the script will open. To completely delete the script, you must use the Script / Erase command or select the entire script.
Note: The Script / Erase command is available for some QuickScript types. Deleted text is not written to the Windows Clipboard.
Find: Launches the Replace dialog box.
Using the Script Editor ScreenEquivalency and Mathematical Operator Buttons Equivalency and mathematical operator buttons are located at the bottom of the QuickScript Editor. The buttons are used to quickly insert the displayed keyword, function or symbol into your script at the cursor location.
Indent/Unindent Script Text Position the cursor at the beginning of the line to indent and then press the TAB key. To remove the indent, hold down the shift key and press the TAB key. Insert Menu Options
Functions can be accessed and inserted by selecting the Insert / Functions command on the Script Editor menu. Then select the name of the function category. You can also insert Tagnames, Windows, and ActiveX controls from the Insert menu.
Built-in Script Functions
InTouch provides numerous built-in functions that can be linked to objects or pushbuttons or used in scripts to perform a multitude of tasks. For example, acknowledging alarms, hiding windows, changing the tagname being trended by a pen, and so on.These functions are accessible through the Insert/Functions main menu or by clicking the various buttons in the Functions section of the Script Editor. Once you select a function in its respective dialog box, the function and its required arguments are automatically pasted into your script at the cursor location. After the function is pasted into your script, highlight the argument to modify and enter the new value.Each builtin Script Function is explained in Appendix G. The functions are listed in the order of the command buttons on the script editor.
Available Functions command buttons include the following:
Function | Description |
All | The Choose function dialog box appears displaying all available functions |
including the functions for each installed add-on program (Recipe Manager, | |
SPC Pro and SQL Access Manager). | |
String | The Choose function dialog box appears displaying all available string |
functions. | |
Math | The Choose function dialog box appears displaying all available mathematical |
functions. | |
System | The Choose function dialog box appears displaying all available system |
functions. For example, the functions to start and/or activate another | |
application, read and/or write file and disk information, and so on. | |
Add-ons | The Choose function dialog box appears displaying all available functions for |
each installed add-on program (Recipe Manager, SPC Pro and SQL Access | |
Manager). | |
Misc | The Choose function dialog box appears displaying all available miscellaneous |
functions. For example, the functions for alarms, historical trending, windows | |
controls, ActiveX controls, and so on. | |
Quick | The Choose function dialog box appears listing the names of all the |
QuickFunctions available for calling from the current script. | |
Help | The Choose function to Obtain Help for dialog box appears listing all available |
functions. Click a function to open its respective Help topic. |
Insert a Function into a Script In the Functions area of the QuickScript Editor, click the All function button. The Choose function dialog box appears:
Click Next Page to see additional functions.
The rest of the available functions display:
After selecting the function, the dialog box closes and the function is inserted into your script at the cursor location. To quickly access the Tag Browser, double-click a blank area in the QuickScript window.
To access a specific tagname’s definition in the Tagname Dictionary, enter the tagname in the QuickScript window and then double-click it. Insert a Tagname Dot Field into a Script Select Insert / Tagname: The Tag Browser appears in the unlimited selection mode. Note: The tags defined in the last tag source accessed through the Tag Browser will be displayed. To change the tag source, click the Tag Source arrow and select a different tag source in the list. Click the Define Tag Sources button to add or remove a tag source from the Tag Source list. Select the tagname and then click the Dot Field arrow. Select the .field to use with the tagname in the list. Click OK. The selected tagname.field will be inserted into your QuickScript at the cursor location. Tip: To quickly insert a tagname .field, enter the tagname followed by a period (.) and then double-click to the right of the period. The Choose field name dialog box will open. Click the .field that you want to use. The dialog box will close and the selected .field will automatically be inserted into your QuickScript at the cursor location.
Selecting Dot Fields from the Tag Browser Unlimited selection mode enables tagname .fields selection for the selected tag. When a tag and/ or its Dot Field is selected, it is automatically entered into the InTouch QuickScript, the animation link tagname or the expression box or other location from which you accessed the Tag Browser. The tagnames defined in a local or remote tag source can be displayed and selected in this mode. The unlimited selection mode is accessed by double-clicking in a blank area in any InTouch QuickScript window, animation link tagname or expression box or, a blank New Name box in the Substitute Tagnames dialog box. Unlimited selection mode also allows you to select tags from defined tag sources such as the Industrial Application Server.
Selecting a Dot Field Click Special / Scripts / Windows Scripts. Double-click the blank area. Click the Dot Field arrow to open the list of .fields that can be associated with the type of the selected tag. By default, <none> will initially be displayed for all types of tagnames. Click the .field in the list to append to the selected tag. The primary methods that display the Tag Browser in the unlimited selection mode include: z Double-clicking an animation link tagname or expression input box. z Double-clicking an ActiveX control or Wizard tagname or expression input box. z Double-clicking a blank area in any InTouch QuickScript window. z In the InTouch QuickScript editor, selecting the Tagname command on the Insert menu. z Pressing the ALT + N keys in the InTouch QuickScript editor. z Double-clicking a blank New Name box in the Substitute Tagnames dialog box. z Double-clicking the Tagname.FieldName input box in the SQL Access Bind ListConfiguration dialog box. The Tag Browser’s status bar provides status on the following items for the currently displayed tag source: z Total number of items in the application z The name of the currently selected item z Tagname .field selected, if any z The Access Name associated with the tag source Find or Replace within a Script z Select Edit / Find. The Replace dialog box displays:
Enter the item to find (or replace) and click Find Next. Enter the new item in the Replace with box to replace the old tagname and click Replace or Replace All. The Match case option finds specific upper or lowercase instances of the item. Click Cancel when finished. Tip: If you only want to replace certain instances of an item, click Find Next. InTouch will begin searching your script for the old item. When the old item is found, it will be highlighted. Click Replace to replace it with the new item or click Find Next to skip it and continue searching. To replace all occurrences of a specific item, click Replace All at any time during the search. Insert a Window Name into a ScriptSelect Insert / Window or click the Insert Window icon. The Window Name to Insert dialog box appears, displaying the names of all the windows in your application. Click the desired window name. The dialog box closes and the window name is automatically inserted into your script at the cursor location.
Validate a Script Click Validate to verify that your script syntax is accurate. This can be done at any time. Validation is automatically performed when you click OK or Save. If the system encounters errors when validating a script, a corresponding error message box will open. If no message appears, the script is accepted. Save a Script Click Save to save the first script if many scripts are to be configured. Then click Script / New to write a new script. Action, Application, and Window scripts do not support this function. Restore a Script If you change a script and then decide to clear your changes and restore the original script, click the Restore button. A script cannot be restored once it has been saved. Application and Window scripts do not support this function. Exit the Script Editor All script editors can be exited by clicking OK, or by clicking the X button in the upper-right of the caption bar. In some editors, selecting Script / Exit closes the script editor. Clicking OK or Script / Exit will cause the script editor to close, and the script to be validated and saved unless an error is encountered. Clicking X will cause the script editor to close. Any changes made will be discarded. No validation will occur. Specify a Script’s Execution Frequency In the WhileRunning/Showing/DownEvery 0 Milliseconds boxes, enter the number of milliseconds that must elapse before the script executes. When creating an Application WhileRunning script, Window While Showing scripts, Condition While On True/On False scripts or Key and Touch Pushbutton Action While Down scripts, you must specify the frequency (in milliseconds) that they will be executed. Note: WindowViewer will make every attempt possible to run these types of scripts as fast as the specified time. However, performance cannot be guaranteed. Also, scripts can never run any faster than the Tick Interval setting specified in WindowViewer’s properties.
IF-THEN-ELSE and Comparisons The IF-THEN-ELSE statement is used to conditionally execute various instructions based on the state of an expression. The following comparison operators are used to set up the conditions in an IF-THEN-ELSE statement. <Less than >Greater than <=Less than or Equal to >=Greater than or Equal to ==Equivalency (“is equivalent to”) <>Not Equal to Below are some examples of complex scripts using comparison operators. Note: Each IF must have a matching ENDIF and a semicolon must be entered at the end of each statement line. IF-THEN statement with no ELSE clauseIF a <> 0 THENa = a + 100;ENDIF;IF-THEN-ELSE statement with one ELSE clauseIF temp > 500 THENDisc = 1;Real = 43.7;ELSEDisc = 0;Real = 93.4;ENDIF;IF-THEN-ELSE statement with one ELSE IF clause and no ELSE clauseIF temp > 500 THENDisc = Disc * 10;ELSEIF temp > 250 THENx = y / z;a = abc + def;ENDIF;ENDIF;
IF-THEN-ELSE statement with one ELSE IF clause and one ELSE clauseIF temp > 500 THENDisc = Disc – 10;ELSEIF temp < 250 THENDisc = Disc + 10;ELSEDisc = Disc + 50;Real = 100;ENDIF;ENDIF;IF-THEN-ELSE statement with multiple ELSE IF clauses and one ELSE clauseIF temp > 100 THENtemphihi = 1Disc = 50;ELSEIF temp > 80 THENtemphi = 1;ELSEIF temp < 10 THENtemplo = 1;ELSEIF temp < 30 THENtemplolo = 1;ELSEtempok = l;ENDIF;ENDIF;ENDIF;ENDIF;IF-THEN-ELSE statement that tests for Condition 1 or Condition 2IF (pump1 < 50.0) OR (pump2 < 50.0) THENalarm1 = 1;ELSEalarm1 = 0;ENDIF;IF-THEN-ELSE statement that tests for Condition 1 and Condition 2IF (pump1 < 50.0) AND (pump2 < 50.0) THENalarm2 = 1;ELSEalarm2 = 0;ENDIF;IF-THEN-ELSE statement that tests for equivalency:IF a > 50 THENIF b == 100 THENc = 0;ENDIF;ENDIF;Notes – Math Functions Math functions are used on integer or real tag types. In the math functions, the ResultNumericTags and InputNumericTags can be either Real or Integer and freely interchanged. Keep in mind, however, that returning a non-integer result of a function to an Integer tagname will result in the truncation of the result, i.e. the portion to the right of the decimal point will be lost (not rounded). Notes – System Functions System functions are used to perform actions such as activating another Windows application, copying, deleting or moving files and retrieving information regarding your InTouch application. System functions read and write data from three file types: File information, Application information, and System information. Notes – WW I/O Functions DDE-related functions should not be used as a replacement for normal InTouch DDE communications. Whenever possible, you should create an I/O type tag to send data to or get data from an external application. The WW DDE functions are intended to support applications that cannot communicate using the DDE Advises supported by InTouch. For example, some applications support only DDE Executes or Pokes. The WWExecute(), WWPoke() and WWRequest() functions use the same Windows functions as Microsoft Visual Basic (DDEML). A single function actually does several things. For example, a WWPoke() will perform a DDE Initiate, a DDE Poke and a DDE Terminate all in one function. This makes WW DDE functions less error prone, but also less efficient in processing many DDE messages. As a general guideline for the use of these functions, avoid: Looping these functions (calling them over and over). Calling several of the DDE functions in a row and in the same script. Using them to call a lengthy task in another DDE application. If the DDE command executes a lengthy task in another application, it might use up all of the available processor time. Still, even if communication difficulties occur, no loss of data will occur. If the I/O Server cannot send messages to InTouch, it will continue to try. Importing QuickScripts Importing QuickScripts from one InTouch application to another can save development time. It allows you to reuse your previously created QuickScripts. To move QuickScripts from one InTouch application to another, you must use the File / Import command. Close all windows in your current application. Click File / Import. The Import from directory dialog box appears:
Select the application directory (folder) containing the QuickScript(s) to import. Click OK. The Application Data Import Options dialog box appears. Select Condition Scripts.
Click Select. The Select a Condition Script dialog box appears:
Select the QuickScript(s) to import then click OK to close the dialog box. Click Import. The system will automatically begin to import the selected QuickScript(s) into your current application.
Importing ActiveX Event Scripts
ActiveX Event scripts are used to make something happen as the result of an ActiveX Control event. For example, click, double-click, mouse down and key press are typical events used in many ActiveX controls.
InTouch ActiveX Event scripts are provided to support event actions. You can associate one ActiveX Event script to each event. You execute ActiveX control events in Runtime (WindowViewer).
You can use InTouch QuickScript functions to handle ActiveX control events, call control methods, and control properties. You can execute ActiveX methods through InTouch QuickScript functions. You can associate an ActiveX event with an ActiveX Event Script that executes when the event occurs.
In Runtime, the tagnames and QuickScripts you defined in WindowMaker control the behavior of your ActiveX controls.
When ActiveX Event scripts are imported from one application to another, all ActiveX Events scripts are imported.
Additionally, in order for an imported ActiveX Event script to function properly in the new application, the same ActiveX control and the same event for which the script was originally created must also be used in the new application.
If the window containing an ActiveX control is closed, its ActiveX Event scripts or any other InTouch QuickScripts containing script functions associated with that ActiveX control will not execute properly.
Note: ActiveX Controls and Event scripting are introduced inAppendix Dof this manual, anddiscussed in depth in the InTouch Advanced class.
Converting Placeholder Tagnames
When a QuickScript is imported into a new application, all of the tagnames referenced in the QuickScript are imported with it, but they are not added to your Tagname Dictionary. Instead, they are automatically converted to placeholder tagnames.
You must convert the placeholder tagnames in order to use them. If they are not currently defined in the new application’s Tagname Dictionary, you will be asked to define each of them.
When the tagnames in an imported QuickScript are converted to placeholder tagnames, three index characters are added to the beginning of each tagname. For example, when a discrete tagname is imported, the tagname is prefixed with the following three characters: ?d:.
When a tagname of 30, 31, or 32 characters in length is imported, the three indexing characters will still be added to the beginning of each tagname. However, the addition of these three characters will not truncate the length of your existing tagname. For example, for placeholder tagnames only, a 32 character tagname is increased to 35 characters.
These three additional spaces are allotted only for placeholder tagnames. This increase in tagname length is not supported for standard tagnames.
When you select a script to edit and click Convert, the Convert dialogue box appears:
You will be prompted to define any tags that are not currently in your tagname dictionary. Note: Tagname conversion is demonstrated in the following lab. Script Editor PrintingA Print icon is available in the script editor for printing the current script. You must have a printer connected on your network. The print function will print all the scripts conditions assigned. Printing Scripts All scripts in each InTouch QuickScript category can be printed. In WindowMaker, click File / Print. The WindowMaker Printout dialog box appears:
Select which database entries, windows, and/or scripts to print.
To print window scripts, select Windows, and then select Window Scripts. Select All In the Which Windows? area to print the scripts for all windows in the application.
Select the Selected option to print a specific window’sscript. The Windows to Print dialog box appears:
Select the window(s) whose script you want to print and then click OK. Note: If you select a window that does not have a script linked to it, the following heading will be printed on the report: Window Scripts for Window Name: none. To print all scripts for a QuickScript type, select the QuickScript type and then click OK. After choosing all print selections, click Next. The Save Application Data to File window appears:
Select an output to printer or to text file.
Quick ReferenceIntroduction In this guide, the basic functionality of each type of QuickScript that can be created is summarized.
QuickScripts
Script Type | Description |
Application | Scripts linked to the entire application |
Window | Scripts linked to a specific window |
Key | Scripts linked to a specific key or key combination on the keyboard |
Touch Action | Scripts associated with an object linked to a |
Touch Link – Touch Pushbutton – Action animation link | |
Data Change | Scripts linked to a tagname and/or tagname.field only |
Condition | Scripts linked to a discrete tagname or expression |
ActiveX Event | Scripts that execute ActiveX control events in Runtime |
QuickFunctions | Scripts you create that can be called from other InTouch QuickScripts or |
animation link expressions. QuickFunctions can be either synchronous or | |
asynchronous, while all other script types are synchronous only. |
Application Scripts Application Scripts are linked to the entire application. They can be used to start other applications, create process simulations, calculate variables, and so on.
Script Type | Description |
On Startup | Executes once when the application is initially started up |
While Running | Executes repeatedly at the specified frequency while the application is |
running | |
On Shutdown | Executes once when the application is closed |
Window Scripts Window Scripts function within a specific window.
Script Type | Description |
On Show | Executes once when the window is initially opened |
While Showing | Executes repeatedly at the specified frequency while the window is |
showing | |
On Hide | Executes once when the window is hidden |
Touch Action Scripts Touch Action Scripts are similar to Key Scripts, except they are associated with an object linked to a Touch Link – Touch Pushbutton – Action. The script editor is accessed through the animation link selection dialog box. They are executed when the operator clicks or presses the object or button assigned to the link.
Script Type | Description |
On Left Click/Key Down | Executes once when the key or button is initially pushed down |
While Left/Key Down | Executes repeatedly at the specified frequency while the key or button is |
held down | |
On Left/Key Up | Executes once when the key or button is released |
On Left Double Click | Executes when the mouse button is double clicked |
On Right Click | Executes once when the key or button is initially pushed down |
While Right Down | Executes repeatedly at the specified frequency while the key or button is |
held down | |
On Right Up | Executes once when the key or button is released |
On Right Double Click | Executes when the mouse button is double clicked |
On Center Click | Executes once when the key or button is initially pushed down |
While Center Down | Executes repeatedly at the specified frequency while the key or button is |
held down | |
On Center Up | Executes once when the key or button is released |
On Center Double Click | Executes when the mouse button is double clicked |
On Mouse Over | Executes the script one time when the cursor rests over an object |
Data Change Scripts Data Change Scripts are linked to a tagname and/or tagname.field only. They are executed once when the value of the tagname or tagname.field changes by a value greater than the value deadband defined in the Tagname Dictionary.
Condition Scripts Condition Scripts are linked to a discrete tag or expression that equates to TRUE or FALSE. This type of script is the most widely used script type. Discrete expressions containing analog tagnames can also be used.
Script Type | Description |
On False | Executes once when the condition transitions to false |
While False | Executes repeatedly while the condition is false |
On True | Executes once when the condition transitions to true |
While True | Executes repeatedly while the condition is true |
ActiveX Event Scripts Most ActiveX controls have events associated with them. For example, click, double-click, mouse down, and key press are typical events used in many ActiveX controls. InTouch ActiveX Event scripts support event actions. You can associate one ActiveX Event script to each event. Execute ActiveX control events in Runtime (WindowViewer). QuickFunctions QuickFunctions are scripts that you can write or call from other scripts or expressions. They are stored in the application in which they are created. Calling QuickFunctions from other scripts or expressions allows you to create a script once and then reuse it. QuickFunction valid data types are as follows.
Data Type | Description |
Integer | Used to pass integer variable, tagname, or constant values |
Real | Used to pass real variable, tagname, or constant values |
Discrete | Used to pass discrete variable, tagname, or constant values |
Message | Used to pass string variable, tagname, or constant values up to 131 |
characters |
Also Read:-