0% found this document useful (0 votes)
67 views193 pages

Intouchhh

wonderware intouch

Uploaded by

jalloulbaha92
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
67 views193 pages

Intouchhh

wonderware intouch

Uploaded by

jalloulbaha92
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 193
ormzo2e 1849 mallee by Schneider Electric Wonderware InTouch® HMI Scripting and Logic Guide 10/15/15 hitpssImanvalez.comidoclolmydvintouch-hmi-scrpting-anc-ogic-qu idragXk3®-hmi-scripting-and-ogic-guide aig o7iozr2026 14:49 ‘manual viewer All rights reserved. No part of this documentation shall be reproduced, stored in a retrieval system, or transmnitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of Schneider Electric Software, LLC. No copyright or patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this documentation, the publisher and the author assume no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information contained herein. The information in this documentation is subject to change without notice and does not represent a commitment on the part of Schneider Electric Software, LLC. The software described in this documentation is furnished under a license agreement. This software may be used or copied only in accordance with such license agreement. © 2015 Schneider Electric Software, LLC. Alll rights reserved. Schneider Electrie Software, LLC 26561 Rancho Parkway South Lake Forest, CA 92630 U.S.A. (949) 727-3200 http//software.schneider-electric.com For comments or suggestions about the product documentation, send an e-mail message to [email protected]. ArchestrA, Avantis, DYNSIM, EYESIM, Foxboro, Foxboro Evo, VA Series, InBatch, InduSoft, IntelaTrac. InTouch, PIPEPHASE, PRO/II, PROVISION, ROMeo, Schneider Electric, SIM4ME, SimCentral, Simi, Skelta, SmartGlanee, Spiral Software, VISUAL FLARE, WindowMaker, WindowViewer, and Wonderware are trademarks of Schneider Electric SE, its subsidiaries, and affiliated companies. An extensive listing of Schneider Electric Software, LLC trademarks can be found at: http://software schneider-electric.com/legal/trademarks/. All other brands may be trademarks of their respective owners. ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 2193 o7iozr2026 14:49 Chapter 1 Chapter 2 Contents Welcome... Documentation Conventions 9 Technical Support ..... 9 Introduction to Scripting . Basic Seripting Concepts Types of Scripts Editing and Creating Scripts 13 Advanced Scripting Concepts u4 OLE Objects 4 Scripting with ActiveX Controls 4 Creating and Editing Scripts .. Opening a Seript for Editing .. Saving or Discarding Changes to a Sript . Copying, Cutting and Pasting Text .. 18 Finding and/or Replacing Text 18 Inserting Code Elements 1s Accessing Help for Script Functions 19 Validating Scripts for Correct Syntax 20 Printing Scripts 20 TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide ang o7iozr2026 14:49 4 Contents Deleting Scripts 21 Chapter 3 Script Triggers . Types of Script Triggers Using Multiple Triggers ... Periodic Script Execution ..... Configuring Application Scripts 25 Limitations of Application Scripts .. 26 Configuring Window Seripts 27 Configuring Key Seripts 28 Configuring Condition Scripts .. Configuring Data Change Scripts Configuring Action Scripts .. Configuring ActiveX Event Scripts . Pausing Script Execution at Run Time 40 $LogicRunning System Tag 41 Chapter 4 The Script Language. Basic Syntax Rules Subroutines Statements Indentation .. Comments Tag References... Literal Data Values ...... ‘Value Expressions Syntax Validation ...... Calling Standard Functions Stax for Calling Standard Funetions Passing Parameters to a Function .. Calling Custom Funetions (QuickFunctions) ... Passing Parameters to a QuickFunetion Value Assignments and Operators Supported Operators Setting the Evaluation Order of Operato Implicit Data Type Conversion Examples for Expressions ‘Using Conditional Program Branching Structures Simple Conditional Structure Nested Conditional Structure ...... Invalid Scripting Example (Missing ENDIF) .. InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide ang o7iozr2026 14:49 Contents @ 5 Chapter 5 Chapter 6 Invalid Scripting Example (Incorrect Nesting) 60 ‘Using Program Loops 61 Forcing the End of a Loop 62 Effect of Loops on Other Run-Time Processes Time Limit for Loop Execution Examples of Loops . 68 ‘Using Local Variables Declaring a Local Variable Naming Confliets between Local Variables and Tags 65 Custom Script Functions . About QuickFunetions .. Configuring QuickFunetions Calling QuickFunctions ...... Creating Asynchronous QuickFunetions 70 Limitations of Asynchronous QuickFunctions 70 Checking if any Asynchronous QuickFunctions are Running Stopping Asynchronous QuickFunetions from Running .. Built-In Functions Forcing Updates in Animation Display Links 73 Mathematical Caleulations 74 Rounding, Truncating, and Determining Sign ... Using Trigonometrie Functions 77 Returning the Value of Pi ..... Calculating Logarithms Calculating the Square Root String Operations Returning Parts of Strings Changing Case of Strings . Removing Spaces from Strings Formatting Strings with Spaces 7 Converting Between Characters and ASCII Codes cscs 87 Searching and Replacing Text in Strings 89 Returning Information about Strings 92 Comparing Strings Converting Data Types Text Function ...... StringFromIntg Funetion StringFromReal( Function 97 TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyeuintouch-hmi-scriping-and-logle-quide-intouchandreg%s3B-hmi-scripting-and-logic guide sn93 o7iozr2026 14:49 ‘manual viewer 6 © Contents StringToIntg( Function StringToReal) Function .. . 100 DText( Function Working wich Titheh Windows at Run The - 101 Expose Window Name Property... sesnrenacts TOL Showing a List of Open Windows 103 Checking If a Window is Open, Closed, of EXiStS scence 108 Opening InTouch Windows eneeene 104 ‘Moving and Resizing a Window 106 Hiding InTouch Windows .. ams nictaasns MOT Changing the Color of a Window 108 Printing Windows at Run Time 109 Starting Tag Viewer 113 Working with Date and Time Information spans 118 Retrieving Numerical Date and Time Information .....000 113 Retrieving String Date and Time Information .. . 119 Converting Date and Time Information to Strings 121 Checking the Daylight Savings Time Status . 124 Interacting with Other Applications ..... . 125 Starting a Windows Application . 125 Retrieving the Application Title of a Running Application. 126 Checking If an Application is Running 126 Activating a Running Windows Application .. oe 12T Sending Simulated Key Strokes to an Application 128 Closing, Minimizing or Maximizing a Windows Application oe 130 Executing Commands and Exchanging Data using DDE... 131 Working with Files 184 Managing Files 135 Reading and Writing CSV Data . woe 189 Reading and Writing Text Data .. ve AL Retrieving System-Related Information .... . 143 Retrieving the Node Name of the Computer 143 Retrieving Disk Space Information 144 Retrieving Information on a File or Directory 145 Retrieving Information on the Windows Environment wa... 146 Retrieving InTouch Related Information a7 Retrieving the Name of the InTouch Application Directory ... 148 Retrieving the InTouch Version 148 Security-Related Scripting . 149 Logging On and Off . 149 Changing and Setting Password ..... . 150 InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide ergs o7iozr2026 14:49 Contents © 7 Chapter 7 Chapter 8 Specifying and Configuring Users Managing Security and Other Information ‘Miscellaneous Scripting ..... . Playing Sound Files from an InTouch Application . Getting and Setting Properties of Wizards Scripting with OLE Objects .. Creating, Validating, and Releasing OLE Objects 159 OLE_CreateObject() Function 160 OLE _IsObjectValid() Function 160 OLE _ReleaseObject() Function . 161 Using OLE Object Properties and Methods ... 162 Accessing the Properties of an OLE Object purists LOE Calling Methods of an OLE Object 163 Assigning Multiple Pointers to the Same OLE Object 164 Troubleshooting OLE Errors 165 OLE_GetLastObjectError() Function... eosensee 165 OLE_GetLastObjectErrorMessage() Function 165 OLE _ResetObjectExror() Fumetion 166 OLE_ShowMessageOnObjectError() Function, 166 OLE_IncrementOnObjectError( Function ... evens 166 Things You Can Do with OLE 167 Produce Random Numbers 167 Create User Interface Dialog Boxes 167 Open Windows Date and Time Properties Panel 169 Read and Write to the Registry 170 Minimize Windows ween see 170 Scripting ActiveX Controls . Calling ActiveX Control Methods Accessing ActiveX Control Properties from the InTouch HMI 173 Configuring ActiveX Control Properties to Read and Write Data .. . oes 178 Creating and Re-using ActiveX Event Scripts . cases 076 Creating ActiveX Event Scripts 176 Re-using ActiveX Event Scripts ut Creating Self-Referencing ActiveX Event Scripts .... . 178 Importing ActiveX Event Scripts 179 TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 793 o7iozr2026 14:49 ‘manual viewer 8 @ Contents Chapter 9 Troubleshooting QuickScripts. Logging Messages to the Log Viewer .. LogMessage() Function Viewing Log Viewer Messages Index.. InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide angs o7iozr2026 14:49 ‘manual viewer Welcome ‘You can create scripts to add procedures to your InTouch human machine interface (HMI applications, You use scripts to add capabilities and features to animations, alarms management, operator interfaces and trend wizards ‘You can view this document online or you ean print it, in part or whole, by using the print feature in Adobe Acrobat Reader, Before you begin learning about scripting and logic, you must know how to use Microsoft Windows, including navigating menus, moving from application to application, and moving objects on the sereen. If you need help with these tasks, see the Microsoft online help. Documentation Conventions This documentation uses the following conventions: Convention Used for Initial Capitals Paths and file names Bold Menus, commands, dialog box names, and dialog box options. Monospace Code samples and display text. Technical Support Wonderware Technical Support offers a variety of support options to answer any questions on Wonderware products and their implementation, TaTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide sng o7iozr2026 14:49 ‘manual viewer 10 @ Welcome Before you contact Technical Support, refer to the relevant section(s) in this documentation for a possible solution to the problem. If you need to contact technical support for help, have the following information ready © The type and version of the operating system you are using. © Details of how to recreate the problem. © The exact wording of the error messages you saw. ° Any relevant output listing from the Log Viewer or any other diagnostic applications. © Details of what you did to try to solve the problem(s) and your results, © Ifknown, the Wonderware Technical Support case number assigned to your problem, if this is an ongoing problem. InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 10193 o7iozr2026 14:49 ‘manual viewer it Chapter 1 Introduction to Scripting ‘You can use the InTouch scripting language, QuickSeript, to build more robust applications. There are seven types of scripts and many built-in seript functions available ‘The seven types of scripts are defined by what causes them to execute. For example, application scripts execute when an application starts, stops, or continues running. Data change scripts execute when a certain item of data changes. Window scripts execute when a window opens, closes, or remains open. The built-in script functions include mathematical functions, trigonometric functions, string functions, and others. Using these functions saves you time in developing your application, InTouch scripts ean include Object Linking and Embedding (OLE) objects and ActiveX controls. ‘You can use conditional statements, loops, and local variables in the scripting language to create complex effects in your application. TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide snit93, o7iozr2026 14:49 ‘manual viewer 12 © Chapter 1 Introduction to Scripting Basic Scripting Concepts Before you start scripting, you should understand: © A script is a set of instructions that direct an application to do something. © QuickSeript is the InTouch HMI scripting language. © A function is a script that can be called by another seript. The InTouch HMI comes with a set of predefined functions for your use © QuickFunctions are re-usable functions written in QuickSeript and stored in the QuickFunction library, To create a QuickFunction, you simply ereate a QuickSeript and name it. A QuickFunction can be called by another seript or from animation link expressions. Types of Scripts In InTouch, scripts are categorized based on what causes the seript to execute, For example, you would create a “key seript” if you want a script to execute when the operator presses a certain key on the keyboard, After you have chosen the script type, you can then further define the criteria, or conditions, that make the script execute. For example, you might want the seript to execute when the key is released, not when the key is pressed. The seript types are: © Application scripts execute either continuously while WindowViewer is running or one time when WindowViewer is, started or shut down, © Window scripts execute periodically when an InTouch window is open or one time when an InTouch window is opened or closed. © Key scripts execute one time or periodically when a certain key or key combination is pressed or released. © Condition scripts execute one time or periodically when a certain condition is fulfilled or not fulfilled. © Data change scripts execute one time when the value of a certain tag or expression changes. © Action seripts execute one time or periodically when an operator clicks on an InTouch HMI graphic object. © ActiveX event scripts execute one time when an ActiveX event occurs, stich clicking the ActiveX control. InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide rans o7iozr2026 14:49 Editing and Creating Scripts @ 13 Editing and Toolbars —} Condition _| definition area Script —+ window Equivalency and math —1 operator buttons Creating Scripts Use the InTouch HMI Script Editor to ereate and edit scripts within InTouch WindowMaker. saBvosad | Condtion turning =| Evey (0 | Msec Scripts used 0 pe [ikea =] trey 0] ee Somme © OE) IL command > Carel) buttons utten on fanton Mitone a = aay] | ven ove aoe) function bation This example is for an application seript. Each type of seript has its own version of the script dialog box, with options and selections that are unique to that type of script ‘The title bar of the editor identifies whieh type of seript you are working with. For information about types of scripts, see "Types of Scripts" on page 12. There are text, equivalency and mathematical operator buttons at the bottom of the QuickScript editor that you ean click to insert that keyword, function, or symbol into your script at the cursor location, ‘The Condition box includes the available execution conditions for the type of script you are writing. ‘The MEM OLE button in the lower right corner only appears if the Manufacturing Engineering Module (MEM) is installed with the InTouch HMI installation, Clicking this button allows you to script with MEM. TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 13193 o7iozr2026 14:49 ‘manual viewer 14 © Chapter 1 Introduction to Scripting Advanced Scripting Concepts Some advanced scripting capabilities allow you to achieve sophisticated functions beyond those of the basic InTouch HMI. OLE objects and ActiveX controls allow you to access your native computer system functions and interact with other programs such as the Manufacturing Engineering Module. OLE Objects In your custom seripts, you can call OLE objects. OLE objects allow you to access your native computer system functions and to interact with other programs such as the Wonderware Manufacturing Engineering Module. For example, using OLE, you can: © Produce random numbers. © Create user interface dialog boxes. Open the Windows date and time properties panel Read and write to the registry, Minimize windows. Scripting with ActiveX Controls Several ActiveX controls are provided with the InTouch HMT in the Wizards menu. Because the InTouch HMI is based on the Windows operating environment, you can use nearly any ActiveX control with the InTouch HMI InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide sans o7iozr2026 14:49 ‘manual viewer 15 Chapter 2 Creating and Editing Scripts ‘The steps to create a new seript vary according to the seript type. In general, you open the script editor, select a condition type, enter statements, and then save the script. For detailed information on creating seripts of each type, see the following sections: © "Configuring Application Scripts" on page 2 "Configuring Window Scripts" on page 27 "Configuring Key Scripts’ on page 28. ‘Configuring Condition Seripts" on page 80. "Configuring Data Change Scripts’ on page 23. "Configuring Action Scripts" on page 34, "Configuring ActiveX Event Scripts" on page 38. See the following sections for basic editing operations, as well as some advanced features that can save you time. © "Opening a Seript for Editing” on page 16. © "Saving or Discarding Changes to a Script” on page 17. © "Copying, Cutting and Pasting Text” on page 18. © "Finding andfor Replacing Text" on page 18. © "Inserting Code Elements” on page 18. . "Accessing Help for Script Functions" on page 19. TaTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 151193 o7iozr2026 14:49 ‘manual viewer 16 © Chapter 2 Creating and Editing Scripts Opening a Script for Editing The steps to open an existing script vary slightly depending on the sexipt type. To open an application script 1 Do either of the following: © Using the Classic View, in the Scripts pane, double-click: Application. © On the Special menu, point to Seripts, and then click Application Scripts. 2. Inthe Condition Type list, click the type of seript to edit. To open a window script 1 Do any of the following: © Using the Classic View, in the Windows pane, right-click the window name, and then click Window Scripts. © Using the Project View, expand Scripts, and then double-click the script. © Open the window that the script is associated with, On the Special enti, point to Scripts, and then click Window Scripts. © Open the window that the script is associated with. Right-click ona blank area in the window, and then click Window Scripts, 2. Inthe Condi run. \n Type list, click the condition to cause the script to To open an ActiveX event script © Do any of the following © Using the Classic View, in the Scripts pane, expand Activex Event, and then double-click the script name. © Using the Project View, expand Scripts, and then double-click the script, © Double-click the ActiveX control instance that the script is associated with, Click the Events tab, and then double-click the cell that contains the seript name. To open an action script 1 Open the window that contains the graphic element that the action script is associated with. 2. Double-click the graphic element that the action script is associated with. InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyeuintouch-hmi-scriping-and-logle-quide-intouchandreg%s3B-hmi-scripting-and-logic guide 161193 o7iozr2026 14:49 ‘manual viewer Saving or Discarding Changes to a Script_@ 17 3 In the Touch Pushbuttons area, click Action. The Seript Editor appears 4 In the Condition Type list, click the aetion to cause the seript to run. To open key, condition, or data change scripts 1 Do any of the following: © Using the Classic View, in the Scripts pane, expand the script category, and then double-click the script name. © Using the Project View, expand Scripts, and then double-click the script, © On the Special menu, point to Seripts, and then click the relevant seript type. The Seript Editor appears. Click the Browse button, and click the seript name. 2. Ifapplicable, in the Condi cause the script to run. n Type list, click the condition to Saving or Discarding Changes to a Script While working in the Script Editor, or when finished, you can save your seript either manually or automatically. Or you ean diseard it, altogether. The restore option is not available for window and application seripts. Note: Saving and discarding changes always applies to all condition types for a type of script, not just the condition type that is currently visible, To save changes and keep the script open © On the Script menu, click Save. To save changes and close the script * Click oK. To discard changes and keep the script open © Click Restore To discard changes and close the script © Click cancel TaTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyeuintouch-hmi-scriping-and-logle-quide-intouchandreg%s3B-hmi-scripting-and-logic guide wns o7iozr2026 14:49 ‘manual viewer 18 © Chapter 2 Creating and Editing Scripts Copying, Cutting and Pasting Text Copying, cutting and pasting text in the Seript Editor works the same way as in any other Windows application. Use either the standard keyboard shortcuts Ctrl-C, Ctrl-X, and Ctrl-V, or the toolbar buttons. Finding and/or Replacing Text ‘You can search and replace text in a seript. To \d and/or replace text On the Edit menu, click Find. The Replace dialog box appears. ‘The options in this dialog box work the same way as in other Windows applications, such as Notepad. Inserting Code Elements ‘You can automatically insert various code elements into your script by selecting them from lists. This saves you time and reduces the risk of typing errors. To insert a function into a script 1 On the Insert menu, point to Functions, and then click the name of the function category. The respective Choose function dialog box appears. If you cannot see the function you are interested in, click Next Page at the bottom of the list to go to the next page 2 Click the funetion to use. The dialog box closes, and the function is inserted into your script at the cursor location. To insert a tagname into a script 1 On the Insert menu, click Tagname. The Select Tag dialog box appears. 20 Click the tagname to use Alternatively, you can double-click a tagname to insert the tag and dot field currently selected in the dot field list. 3. To include a dot field, click it in the Dot Field list. Click OK. The Select Tag dialog box closes, and the tagname (with dot field, if any) is inserted into your script at the cursor location, For more information on using the Select Tag dialog box (including setting up multiple tag sources). see "Selecting an InTouch Tag" in the InTouch® HMI Visualization Guide. InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyeuintouch-hmi-scriping-and-logle-quide-intouchandreg%s3B-hmi-scripting-and-logic guide 18193 o7iozr2026 14:49 Accessing Help for Script Functions @ 19 To insert a dot field into a script 1 Type the tagname and a period. 2. Double-click to the right of the period. The Choose field name dialog box appears. 3° Click the dot field to use. The dialog box closes, and the dot field is inserted into your script at the cursor location. To insert a window name into a script 1 On the Insert menu, click Window. The Window Name to Insert dialog box appears. 2. Click the window name to use. The dialog box closes, and the window name is inserted into your script at the cursor loeation. To insert an ActiveX method or property into a script 1 On the Insert menu, click Activex. The Activex Control Browser dialog box appears. 2. Inthe Control Name list, click the ActiveX control instance whose properties and methods you want to list 3 Inthe Method / Property list, click the method or property. Click OK. The dialog box closes, and the method or property reference is inserted into your seript at the eursor location To insert a keyword or operator into a script Click the relevant button at the bottom of the Script Editor. The keyword or operator is inserted into your script at the cursor location. Accessing Help for Script Functions Ifyou are looking for help on a specific seript function, you can access it directly from the Seript Editor. To view help on a specific script function 1 Inthe bottom right corner of the Script Editor, click Help. A list of funetions appears. 2 Ifyou cannot see the function you are interested in, click Next Page at the bottom of the list to go to the next page. 3 Click the name of the required function. The corresponding Help topic appears. TaTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyeuintouch-hmi-scriping-and-logle-quide-intouchandreg%s3B-hmi-scripting-and-logic guide 191193 o7iozr2026 14:49 ‘manual viewer 20 @ Chapter 2 Creating and Editing Scripts Validating Scripts for Correct Syntax ‘When you save a script, the Script Editor automatically cheeks it for correct syntax, If an error occurs, a message with more information appears. You must fix all syntax errors before you can save the script ‘You can also start the validation manually while you are editing the seript, To manually ve © Click Validate. Printing Scripts ‘You can print scripts individually from the Script Editor, or you can print all scripts of a specific type using the print feature in ‘WindowMaker. ‘You can print scripts individually from the Script Editor, or you can print all scripts of a specific type using the print feature in ‘WindowMaker, To print an individual script 1 Open the script in the Script Editor. & 2 Click Print in the toolbar. The script is printed to the Windows default printer, To print all scripts of a specific type 1 On the File menu in WindowMaker, click Print. The WindowMaker Printout dialog box appears. 2. To print window scripts, do the following: a Select Windows. b_ Select the windows to print: All prints the information for all windows in the application. Selected prints only the information for specific windows. The Windows to Print dialog box appears, Select the windows in your application you want to print and click OK. Batch prints only the information for windows specified in a sv file. © Select Window Scripts to print the scripts associated with the windows 3 To print other types of scripts, select the appropriate check boxes, ‘To print all scripts, click All Scripts. 4 Click Next. The Select Output Destination dialog box appears InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyeuintouch-hmi-scriping-and-logle-quide-intouchandreg%s3B-hmi-scripting-and-logic guide 201193 o7iozr2026 14:49 ‘manual viewer Deleting Scripts @ 21 5 Doone of the following © Click Send output to Printer. © Click Send output to Text File. Click Browse to select a printer or to find a file, Click Print. To print all scripts 1. Select All Seripts to print all scripts used in the application. You can restrict printing to only selected types of scripts by clearing the All Scripts check box. Then, select the check box for each type of script that you want to print Click Next. The Select Output Destination dialog box appears. 3 Select the option to print the contents of the Tagname Dictionary or send the output to a text or htm! file. 4 Click Print Deleting Scripts The steps to delete a script vary depending on the seript type. See the following sections: © "Configuring Application Scripts” on page © "Configuring Window Scripts” on page 27, © "Configuring Key Scripts" on page 28. © "Configuring Condition Scripts" on page 30. © "Configuring Data Change Scripts" on page 33. © "Configuring Action Scripts’ on page 34. © "Configuring ActiveX Event Scripts" on page 38 TaTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyeuintouch-hmi-scriping-and-logle-quide-intouchandreg%s3B-hmi-scripting-and-logic guide 219s o7iozr2026 14:49 ‘manual viewer 22 @ Chapter 2 Creating and Editing Scripts InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 221193 o7iozr2026 14:49 ‘manual viewer 23 Chapter 3 Script Triggers All InTouch HMI scripts are executed by sevipt triggers. Each seript type has one or more triggers to launch it In the Script Editor, you can select which script trigger you want to use to execute your script. You select a script trigger based on when and how a script is executed. You can configure various triggers based on user actions, internal states, and changes of tagname values. User actions include pressing keys and clicking on graphic elements. Internal state triggers can inchude starting WindowViewer. Scripts are triggered by these kinds of actions: © Starting and shutting down WindowViewer. See "Configuring Application Scripts" on page © Opening and closing a window. See "Configuring Window Seripts" on page 27. © Pressing a key or key combination. See "Configuring Key Scripts" on page 28. © Fulfilling a certain condition, such as tagname or an expression value, See "Configuring Condition Scripts" on page 30. © Changing tagname values or tagname field values. See "Configuring Data Change Scripts’ on page 33. TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 231193 o7iozr2026 14:49 ‘manual viewer 24 @ Chapter 3 Script Triggers © Clicking a graphic object. See "Configuring Action Scripts’ on page 34. © Events that occur in an ActiveX control, such as clicking on the control. See "Configuring ActiveX Event Scripts” on page 38, Also, you can pause script execution. By default, when WindowViewer is started, logie is running and seripts are executed. You can pause seript execution at run time by halting logie. After pausing you can resume script execution. For more information, see "Pausing Seript Execution at Run Time” on page 40. Types of Script Triggers In the InTouch HMI, scripts are divided into seven types. Each type of seript has one or more triggers you can select to launch a script. © An application script has three triggers: on startup, on shutdown, and while running. Each trigger can execute a different seript. © A window script has three triggers: on show, on hide, and while showing. Each trigger can execute a different script. © Akey seript has three triggers: on key up, on key down, or while down. Each trigger can execute a different seript. © A condition script has four triggers: on true, while true, on false, and while false, Each trigger can execute a different script, © A data change script executes when the value of a certain tag or expression changes. © An action script executes one time or periodically when an operator clicks on an InTouch HMI graphic object © An ActiveX event seript executes one time when a certain ActiveX event occurs, such as a cliek on the ActiveX control Using Multiple Triggers For most script types you can use multiple triggers and associate different seripts with each trigger. For example, you ean configure an application seript to execute one seript when WindowViewer is started, and another script periodically while WindowViewer is running Select the trigger in the Condition Type list to view the existing seript for a trigger. InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide pans orinzreazs 14:49 ‘manual viewer Periodic Script Execution @ 25 Periodic Script Execution Scripts that execute periodically do not execute immediately after triggering, but after the specified period for the first time For example, if you configure a Key script to execute every 5000 ms while a specific key is pressed, it executes 5 seconds after the key is pressed and held down and then every 5 seconds afterwards, Configuring Application Scripts Application scripts are linked to the entire InTouch HMI application. ‘You can use application seripts to: © Execute a script one time when WindowViewer is started. © Execute a script periodically while WindowViewer is running © Execute a script one time when WindowViewer is shut down, To configure an application script 1. Using the Classic View, in the Scripts pane, right-click on Application and then click Open. The Application Script dialog box appears Edt ver Hep yaBvos Coin Type [his Rue~|Evey [0 Mine Suptuned 0 TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 251193 o7iozr2026 14:49 ‘manual viewer 26 © Chapter 3 Script Triggers 2. Inthe Condi execution: \n Type list, click the condition for the seript © Click On Startup to configure a seript to execute one time when WindowViewer is started, © Click While Running to configure a script to execute periodically while Window Viewer is running. © Click On Shutdown to configure a script to execute one time when WindowViewer is shut down, 3 Ifyou selected While Running in the previous step. type a time interval between 1 and 360000 milliseconds in the Every box. The time interval specifies how often the seript is executed. 4 Type your script in the window. 5 Click ox. To delete an application script 1 Using the Classic view. in the Scripts pane, right-click on Application and then click Open. The Application Script dialog box appears 2. In the Condition Type list. click the condition for the script to delete. The script appears in the main section of the Application Script dialog box, 3. On the Edit menu, click Clear. The script from the main section clears and the associated script is deleted. Limitations of Application Scripts Application scripts that are executed when WindowViewer starts or shuts down have limitations on their interaction with other objects. ‘You cannot use On Startup application seripts to: © Reference ActiveX methods, properties, o events. © Read from or write to controls and I/O tagnames or remote references © Run data change scripts and condition scripts. ‘You cannot use On Shutdown application scripts to: © Read from or write to controls and I/O tagnames or remote references © Start other applications InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 26193 o7iozr2026 14:49 ‘manual viewer Configuring Window Scripts @ 27 Configuring Window Scripts ‘Window seripts are seripts that are linked to speeifie windows. You can use the GetWindowName script function to help the run-time environment reduce scripting necessary to load windows. You can use window scripts to: © Execute a script one time when an InTouch window is opened. © Execute a script periodically while an InTouch window is open. © Execute a script one time when an InTouch window is closed. Note: Opening an InTouch window Is also referred to as “showing an InTouch window,” Closing an InTouch window Is also referred to as “hiding an InTouch window.” To configure a window script 1 Using the Classic View, in the Windows pane, right-click on a window and then click Window Scripts. The Window Script for Window Name dialog box appear Fle ait bet Help sagvosa Cardin pe [Wie Shaméa ~|E ny 0 | Mice Seishned 0 2 Inthe Condition Type list, do one of the following: © Click On Show to configure a script to execute one time when the associated window is started. © Click While Showing to configure a script to execute periodically while the associated Window is open. © Click On Hide to configure a script to execute one time when the associated window is clased. TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 2793 o7iozr2026 14:49 ‘manual viewer 28 @ Chapter 3 Script Triggers 3 Ifyou select While Showing in the previous step, type a time interval between 1 and 360000 milliseconds in the Every box. Type your script in the window, 5 Click 0K, To delete a window script 1. Using the Classic View, in the Windows pane, right-click on a window and click Window Scripts, The Window Script for Window Name dialog box appears 2. In the Condition Type list, click the script trigger for the seript to delete, The script appears in the main section of the Window Script for Window Name dialog box. 3 On the Edit menu, click Clear. Important: Do not use on hide scripts to read from or write to 1/0 tagnames. The 1/O value update does not necessarily complete before the window Is hidden. To read from or write to 1/0 tagnames when a window closes, configure a data change script and activate it from an on hide script, Configuring Key Scripts Key scripts are scripts that are linked to the pressing of a specific key or key combination. You can use key scripts to: © Execute a script one time when a key or key combination is pressed. @ Execute a script periodically while a key or key combination is pressed and not released. @ Execute a script one time when a key or key combination is released, A key script is identified by the name of key that initiates the script. For example: Ctrl+4. Note: If you have configured an action script that uses the same key or key combination to trigger it, the key script is ignored and instead the action script is executed. InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 281193 o7iozr2026 14:49 ‘manual viewer Configuring Key Scripts @ 29 To configure a key script 1 Using the Classic View, in the Scripts pane, do one of the following © To configure a new Key script, right-click Key, and then click New. The Key Scripts dialog box appears. Set Ge le Hp xaayoea ay low esa a) Crain yen Onkaybomm = Settoued 0 (x) (aw) (aaeie) [on] 8H) Be) © To configure an existing key script, expand Key, right-click the script name, and then click Edit. The Edit Key Script dialog box appears. 2 Click Key and select a key from the Choose Key dialog box. Ooo. co 1 a a a | te fen rt tet toe fee fei fe dG fe fe a cm tte tt ts ms fe fk Ly | eee ee eee ets me tak [gt de oth (Om | tie | jth | ines [hfe [eps 3 Select the Ctrl and/or Shift check boxes to assign a control key and/or shift key combination with your selected key TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 21193 o7iozr2026 14:49 30 © Chapter 3 Script Triggers In the Condition Type list, do one of the following: © Click On Key Down to configure a script to execute one time when the associated key or key combination is pressed. © Click While Down to configure a script to execute periodically while the associated key or key combination is pressed, © Click On Key Up to configure a script to execute one time when the associated key or key combination is released. If you selected While Down in the previous step, type a time interval between 1 and 360000 milliseconds in the Every box. ‘Type your script in the window. Click 0K To delete all key scripts associated with a key ° To delete a key script that is asso: 1 Using the Classic View. in the Scripts pane, expand Key right-click the key seript name, and then click Delete. When a message appears, click Yes. ited with a key Using the Classic View, in the Scripts pane, expand Key, right-click the key script name, and then click Edit. The Edit Key Script dialog box appears. In the Condition Type list, click the script trigger for the seript to delete. The script appears in the main section of the Edit Key Script dialog box. On the Edit menu, click Clear. The seript from the main section clears and the associated script is deleted. Configuring Condition Scripts Condition scripts are triggered depending on when certain logical conditions are fulfilled. Use condition scripts to execute a script: One time when a condition is fulfilled. One time when a condition is not fulfilled. Periodically while a certain condition is fulfilled. Periodically while a certain condition is not fulfilled, InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 301193 o7iozr2026 14:49 ‘manual viewer Configuring Condition Scripts @ 31 A condition seript is identified by the condition syntax that initiates the script. For example: tag1>=13. Note: A script that Is assigned the On True condition type only executes if the condition transitions from False to True. A script that is assigned the On False condition type only executes if the condition transitions from True to False, To configure a conditi 1 Using the Classic View. in the Scripts pane either: Siope Eat set Hep 4aBVOSE © Toedit an existing condition script, click the plus sign next to Condition, right-click the condition script name, and click Edit. Condition Script dialog box appears 2. Inthe Condition box, the condition, yype the expression that you want to use as You can type the expression to a maximum length of 1024 characters. 3 You can enter a comment in the Comment box. In the Condition Type list, do one of the following: © Click On False to configure a script to exeeute one time when the condition becomes false. © Click While False to configure a script to execute periodically while the condition is false. TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 31193 o7iozr2026 14:49 ‘manual viewer 32 @ Chapter 3 Script Triggers © Click On True to configure a seript to execute one time when the condition becomes true © Click While True to configure a seript to execute periodically while the condition is true. 5 Ifyou selected While False or While True in the previous step, type a time interval between 1 and 360000 milliseconds in the Every box, Note: The conditional WindowViewer timers will stop themselves If the condition is no longer true. For example, While Mouse Button Down events will not trigger if the mouse button is no longer down, and key scripts will stop if keys are no longer down. 6 ‘Type your script. or modify the existing script in the window. 7 Click 0K. To delete all condi condition ion scripts that are associated with a © Using the Classic View, in the Scripts pane, expand Condition, right-click the condition script name and click Delete. When a message appears, click Yes. To delete lual condition scripts that are associated with a condition 1 Using the Classic View, in the Scripts pane, expand Condition, right-click the key script name and click Edit. The Edit Condition Script dialog box appears. 2. Inthe Condition Type list. click the script trigger for the seript to delete. The seript appears in the main section of the Edit Condition Script dialog box. 3. On the Edit menu, click Clear. The script from the main section clears and the associated script is deleted. InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 321193 o7iozr2026 14:49 ‘manual viewer Configuring Data Change Scripts @ 33 Configuring Data Change Scripts ‘You can use data change scripts to execute a seript one time when a certain tagname or dot field changes by move than its defined dead band. Adata change script is identified by the tagname or tagname field that initiates the script. For example: Tag! or Tag2. HiHiiLimit. To configure a data change script 1 Using the Classic View. in the Scripts pane, right-click Data Change and click New. The Data Change Scripts dialog box appears ‘Srpt_ fot set Hep saayoea Torneo, = we (ne) (Bsr) (Boe) 2. Tocreate a new script, in the Tagname[-field] box, enter a tagname or tagname field. ‘To edit an existing script, click the ellipsis button to the right of the Tagnamef field] box and select the script from the list that appears. 3° Type your script in the window. 4 Click ox. To delete a data change script Using the Classic View, in the Scripts pane, expand Data Change, right-click the data change script name and click Delete. When a message appears, click Yes. TaTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 331193 o7iozr2026 14:49 ‘manual viewer 34 @ Chapter 3 Script Triggers Configuring Action Scripts Use action scripts to associate operator actions with graphic objects, ‘You can configure one or more of the following events with a graphic object: © Clicking the left, center, or right mouse button. © Clicking and holding the left, center, or right mouse button, Releasing the left, center, or right mouse button. Double-clicking the left, center, or right mouse button, Pressing a key or key combination. Pressing and holding a key or key combination. Releasing a key or key combination. © Moving a mouse pointer over an object. An action seript can only be configured in the Animation Link Selection panel of the object itself. Important: Ifa key script exists that is triggered by the same key or key combination as the action script, the action script is executed and the key script Is Ignored. To configure an action script 1 Double-click the graphic object. The Animation Links Sel panel appears bic pe: Recta Peri] (Near ((Dintete Va.) | (Mita) Baten || om. i (ete) InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 3493 o7iozr2026 14:49 ‘manual viewer Configuring Action Scripts ° 35 2. Click Action. The Touch -> Action Script dialog box appears. sanvoea Clon ish God Girton ge Onlah eke Dom ~| Je) le) ble) (ven) (Boe) 3 Inthe Condi To configure a script that executes on this condi click one of the following: Click (One time when the left mouse button or a certain key or key combination is pressed Periodically while the left mouse button or a certain key or key combination is pressed (One time when the left mouse button or a certain key or key combination is released One time when the left mouse button. is double-clicked (One time when the right mouse button is pressed Periodically while the right mouse button is pressed One time when the right mouse button. is released ‘On Left Click/Key Down While Left/Key Down, On Left/Key Up On Left Double Cli (On Right Click Right Down ht Up TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 351193 o7iozr2026 14:49 ‘manual viewer 36 © Chapter 3 Script Triggers To configure a script that executes on this condition (One time when the right mouse button On is double-clicked (One time when the center mouse (On Center Click button is pressed Center Down Periodically while the center mouse Whi button is pressed One time when the center mouse On Center Up button is released One time when the center mouse On Center Double button is double-clicked Click. (One time when the mouse moves over On Mouse Over the object 4 Ifyou select On Left Click/Key Down, While Left/Key Down, or (On Left/Key Up: a Click Key. The Choose Key dialog box appears b Click a key. © Select the Ctrl and/or Shift check boxes to assign a control key and/or shift key combination to your selected Key. 5 Ifyou select While Left/Key Down or While Right Down, type a time interval between 1 and 360000 milliseconds in the Every box. 6 Ifyou select On Mouse Over, in the After box, type the number of milliseconds between 1 and 360000 to pass after the mouse has moved over the object before the script is executed. 7 ‘Type your script in the window. 8 Click oK. InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 361193 o7iozr2026 14:49 Configuring Action Scripts @ 37 To delete all action scripts associated with an InTouch graphic object 1 Double-click the graphic object. The object properties panel appears, bec pe Recta Pv Touch Unk seria eras Dies ee Leeson Pace FI vee || rere | vee) || ova (Ciena) || wh) | Hecots | Heo Teh Pushutns | -Mincelanecus—)- Va Diy 2 Click to clear the Action check box. The action seripts will not be executed during run time, Ifyou cliek the Action button, the editor opens with the last action script that you saved for any object. To delete an individual action script 1 Double-click the graphic object that has the action sevipt to delete, ‘The object properties panel appears. 2. Click the Action button. The Touch -> Action Script dialog box appears. In the Condition Type list, click the seript trigger w 4 On the Edit menu, click Clear. The script from the main section clears and the associated script is deleted. TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 37193 o7iozr2026 14:49 ‘manual viewer 38 @ Chapter 3 Script Triggers Configuring ActiveX Event Scripts Use ActiveX event scripts to run a script when an ActiveX event ocewss. Depending on the ActiveX control, such events ean include: © ActiveX control is started: Startup © ActiveX control is closed: Shutdown, © User clicks on AetiveX control: Click © User double-clicks on ActiveX control: Doubleclick An ActiveX event seript is identified by a name. By default, the InTouch HMI automatically adds the control name and event that the seript is associated with. For example: MyActiveXSeript (AlarmViewerCtrl1:Clicl), To configure a new ActiveX event script 1 Double-click on the ActiveX control to configure. The ActiveX control properties dialog box appears. Cortzcl Name [General | Cor | Time Femat | Que | Pose | Everts Comat Ativan Enended Peparine ut 208 to wane 20 ete [180 Vibe up: [GFISreAD reese e1C1 ZeSTEME) Coo) Etre) 2. Click the Events tab. Cara | cow | Car Tn Fumst| Gey | Fone] Eves Eve Sere (ox Dosti hd Sete InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 38193 o7iozr2026 14:49 ‘manual viewer Configuring ActiveX Event Scripts @ 39 3° Select an event such as click, double-click, shut down, or start up. 4 Click in the Seripts cell for that event. Square brackets appear. 5 Type ina new name for an event script and click OK. When a message appears, click OK to create a new script. The Activex Event Scripts dialog box appears. ‘eres Esk Inet Hep yaBVoea Arion Dale al 6 Inthe Name box, you can make changes to the ActiveX event script 7 Type your seript in the window. 8 Click oK, To edit an existing ActiveX event script 1 Using the Classic View, in the Scripts pane, expand Activex Event, right-click the ActiveX seript name and click Edit. The ActiveX Event Scripts dialog box appears. 2 Make any necessary changes to the script and click OK. TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 39193 o7iozr2026 14:49 40 Chapter 3. Script Triggers To delete an existing Activex event script 1 Make sure that no ActiveX controls are using the ActiveX event seript to delete. If there are AetiveX controls using the seript, do the following first: a Remove the ActiveX event script references in the Events panel of every ActiveX control that may be using it. b Close all windows and update the use counts. 2. Using the Classic View. in the Scripts pane, expand Activex Event, right-click the ActiveX script name and click Delete. When a message appears, click Yes. The ActiveX event seript is deleted. Pausing Script Execution at Run Time By default, when WindowViewer is started, logic is running and synchronous seripts are executed. You can pause script execution at run time by halting logie, After pausing you can resume script execution, To pause script execution at run time from the menu On the Logic menu, click Hatt Logic, The synchronous scripts stop running, Asynchronous seripts continue running but no new asynchronous seripts are started. To pause script execution at run time with scripting Write the value 0 to the diserete system tag $LogicRunning. The synchronous seripts stop running. Asynchronous seripts continue running but no new asynchronous scripts are started. To resume script execution at run time On the Logie menu, click Start Logie. The script execution is resumed. To resume script execution at run time with scripting © Write the value Ito the discrete system tag SLogieRunning. The SLogieRunning system tag must be contained in an. asynchronous seript that is executing at the time the logic is paused InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 40/193 o7iozr2026 14:49 ‘manual viewer Pausing Script Execution at Run Time @ 41 $LogicRunning System Tag ‘This system tag monitors and/or controls the running of scripts. Usage $LogicRunning Remarks Setting the value to 1 starts the script running. Setting the value to 0 stops the seript running. This system tag is equal to selecting Start Logic or Halt Logic on the Logic menu in WindowViewer. ‘You cannot stop asynchronous scripts that are currently running. However, you can prevent new scripts from running. Data Type Discrete (read / write) TaTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide anri93 o7iozr2026 14:49 ‘manual viewer 42 @ Chapter 3 Script Triggers InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 421193 o7iozr2026 14:49 ‘manual viewer 43 Chapter 4 The Script Language Use these concepts, techniques, and syntax rules for writing seripts using the InTouch HMI script language © Basic syntax rules. See "Basic Syntax Rules" on page 44. © Calling pre-defined or custom functions. See "Calling Standard Funetions" on page 46 and "Calling Custom Functions (QuickFunctions)’ on page 47. © Using value assignments and the various operators. See "Value Assignments and Operators" on page 48, © Using conditional statements. See "Using Conditional Program Branching Structures" on page 58 © Using loops. See "Using Program Loops on page 61. © Using local variables. See "Using Local Variables" on page 64. For more information on the general operation of the script editor, see Creating and Editing Scripts. For more information on the various types of seript triggers, see Script, Triggers. For a reference of standard script functions, see Built-In Functions. TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 431193 o7iozr2026 14:49 44 @ Chapter 4 The Script Language Basic Syntax Rules Basic syntax rules cover these aspects of the InTouch HMI script language: Subroutines Subroutines Statements Indentation ‘Comments ‘Tag references Literal data values Value expressions Syntax validation each subroutine, See "Custom Seript Funetions Statements Indentation There is no concept of separate subroutines within the same script, such as “Sub” procedures in Visual Basic. To structure a script into multiple subroutines, you must create a custom QuickFunetion for on page 67 A statement can be a value assignment, a function call, or a control structure, Each statement in a script must end with a semicolon (;) You can have multiple statements in the same line, as long as each statement ends with a semicolon. You can spread a statement across multiple lines by using line breaks (pressing Enter). ‘You can indent your script code in any manner. Indents have no functional relevanee. Comments To mark text as a comment, enclose it in braces { }. Comments can span multiple lines, InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 4ari93 o7iozr2026 14:49 ‘manual viewer Basic Syntax Rules @ 45 Tag References ‘There are several ways to make tag references. © Tovefer to a tag that is defined in the local Tagname Dictionary, simply use the tagname. © Torefer to a specific dot field, use the regular reference format (Tagname..Dot field). © Torefer to a data item on a remote node, use a regular remote tag reference (AcceseName: Item). © You can also define local variables whose scope is limited to the current seript. See "Using Local Variables” on page 64. Literal Data Values © You can specify integer values in decimal or hexadecimal notation For example, 255 or OxFP. © You can specify floating-point values in decimal or scientific notation. For example, 0.001 or 12-3. © To specify a Boolean value, use the numerical values 0 for FALSE. and 1 for TRUE, © Tospeeify a string value, enclose it in double quotation marks. For example: "This is a string.* Value Expressions Value expressions can include literal values, tag references and function calls, all linked together by suitable operators. See "Value Assignments and Operators" on page 48. Syntax Validation When you save a script, the Script Editor automatically checks it for correct syntax. You can also start this validation manually by clicking the Validate button, See "Validating Scripts for Correct Syntax" on. page 20. TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 45/193 o7iozr2026 14:49 ‘manual viewer 46 @ Chapter 4 The Script Language Calling Standard Functions Standard functions eome predefined with the InTouch HMT. See "Calling Custom Funetions (QuickFunctions)" on page 47 Syntax for Calling Standard Functions The syntax to call a predefined script funetion depends on whether and how the function returns a result, Some functions do not return any result; some functions return an optional result that can be assigned to a tag or used in an expression: some functions return a result that must be assigned to a tag or used in an expression. To determine the function type, look at the function deseription. Each function description has a syntax listing that shows whether the function returns a result and whether that result is optional To call a function that does not return a result © Use only the function name (and parameters, if any) in a statement. For example: Funct ionllame (Paraneters) To call a fun: ned n that requires its result to be as: © Use the function name (and parameters, if any) anywhere in a script where you could use a literal value or a tagname of the relevant data type. For example, in a value assignment: ReoultsTagnane = FunctionNane (Parameters); Or in a nested function call, using it as a parameter for another standard function: OtherStandardPunct:ion (Functionllane (Paraneters) ); To call a function that returns an optional result © Use either of the preceding procedures. Passing Parameters to a Function Parameters to standard predefined functions are usually passed by value, This means that you can pass any valid expression as a parameter, as long as the expression evaluates to the data type that is required for the parameter. Such expressions can include literal values, tag references, and function calls, all linked together by suitable operators. For more information on expressions and operators, see "Value Assignments and Operators" on page 48 When the script calls the function, the expression is evaluated and the resulting value passed to the function. InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 45/193 o7iozr2026 14:49 Calling Custom Functions (QuickFunctions) @ 47 However, there are some functions that require a tag reference as a parameter. For example: RecipeSelectRecipe (Filename, RecipeName, Munber) : In this example, the RecipeName parameter must be a tag reference (that is, you must use a literal tagname for the RecipeName parameter). You cannot pass a string expression instead. even if that expression evaluates to a valid tagname. Note: Some legacy predefined functions with only one parameter (for example, the Ack() function) do not follow the standard syntax of passing parameters in parentheses, Instead, the parameter Is separated from the function name by a space. Check the syntax description in the function documentation if you are in doubt about a particular function, Calling Custom Functions (QuickFunctions) Calling a custom QuickFunction differs slightly from calling a predefined standard function: © The keyword CALL must precede the QuickFunction name. © Results returned by QuickFunctions are always optional: you can use them, but you do not have to. To call a QuickFunction that does not return a result ‘© Use the function name (and parameters. if any) preceded by the keyword CALL in a statement. For example: CALL, QuickFunct ionNane (Paranetera) : To call a QuickFunction that returns a result © Docither of the following: © Call the QuickFunetion as if it did not return a result (see the preceding procedure). © Use the function name (and parameters. if any) preceded by the keyword CALL anywhere in a script where you could use a literal value or a tagname of the relevant data type. For example, in a value assignment: ReoulteTagname = CALL QuickFunctionlane (Parameters) ; Or in a nested function call, using it as a parameter for a standard function: OtherStandardFunction (CALL FunctionName (Parameters) ) ; Note: You cannot nest QuickFunction calls so that a QuickFunction Is, used as a parameter for another QuickFunctlon. For example, call QF1 (call QF2()); isnot a valid statement. TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide a7ri93 o7iozr2026 14:49 ‘manual viewer 48 @ Chapter 4 The Script Language Passing Parameters to a QuickFunction Parameters to QuickFunctions are always passed by value. You eannot pass parameters to QuickFunctions by reference ‘You can pass any valid expression as a parameter, as long as the expression evaluates to the data type that is required for the parameter. Such expressions can include literal values, tag references, and function calls, all linked together by suitable operators. For more information on expressions and operators, see "Value Assignments and Operators” on page 48. When the script calls the function, the expression is evaluated and the resulting value passed to the function. Note: You cannot nest QuickFunction calls so that QuickFunction Is, used as a parameter for another QuickFunction. For example, CALL QF1 (CALL QF2()); Is not a valid statement. Value Assignments and Operators Ina seript, you use value assignments to write values to a tag. The syntax for a value assignment is as follows: Tagname = Value=xpression; ‘When this statement is executed, ValueExpression is written to the tag referred to by Tagname. ValueExpression can be any valid expression whose data type matches the tag data type. Value expressions can include literal values, tag references, and function calls, all linked together by suitable operators. See "Supported Operators" on page 48, See "Setting the Evaluation Order of Operators" on page 56. See "Examples for Expressions’ on page 87. Supported Operators ‘The following table lists all supported operators. For information on the use of a specific operator, see the relevant section Operator More information + "Addition or Concatenation: +” on page 49 - "Subtraction or Negation: -" on page 50 * "Multiplication: *" on page 50 1 "Division: /" on page 50 "Power: **” on page 50 InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide ag/193 o7iozr2026 14:49 ‘manual viewer Value Assignments and Operators @ 49 Operator More information MOD "Modulo: MOD" on page 51 ~ "Complement: ~" on page 51 SHL "Shift Left: SHL and Shift Right: SHR" on page 51 SHR ‘Shift Left: SHL and Shift Right: SHR" on page 51 & "Bitwise AND: &" on page 52 | "Bitwise OR: |" on page 53 ‘Bitwise XOR: *" on page 63 AND “Logical Conjunction: AND” on page 54 OR "Logical Disjunction: OR" on page 54 NOT ‘Logical Negation: NOT” on page 55, < "Comparisons: <>, >" on page > "Comparisons: <>. >" on page ‘Comparisons: <, > oon page 55 "Comparisons: <, >, "on page "Comparisons: <, >, "on page = ‘Comparisons: <, >, "on page 55 Note: For numeric calculations, always select the operands so that the result of the calculation is still within the value range of a Real number, Otherwise, the result will not be correct. Addition or Concatenation: + Adds two numeric operands or concatenates two string operands. Valid operands For addition: Any Integer or Real value For concatenation: Any Message value Data type of return value For addition: Integer or Real For concatenation: Message TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 49/193 o7iozr2026 14:49 ‘manual viewer 50 @ Chapter 4 The Script Language Example MessageTag = "Setpoint value: " + Text (SetpolntTag, "#.##"): Subtraction or Negation: - When used with two operands, performs a regular numeric subtraction. When used with one operand, toggles the sign of the operand. Valid operands Any Integer or Real value Data type of return value Integer or Real Example In this example, if OriginalValue is 70, InvertedValue becomes -70. If OriginalValue is -70, InvertedValue becomes 70. InvertedValue = -OriginalValue Multiplication: * Regular numeric multiplication. Valid operands Any Integer or Real value Data type of return value Integer or Real Division: / Regular numeric division. If you try to divide by 0 at run time, 0 is returned as the result. Valid operands Any Integer or Real value Data type of return value Integer or Real Power: ** Raises the left operand (the base) to the power of the right operand (the power), InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 50193 o7iozr2026 14:49 ‘manual viewer Value Assignments and Operators e 51 Valid operands Integer or Real values. It is not possible to combine a base of 0 with a negative power, or a negative base with a fractional power. In these cases, 0 is returned as the result, Data type of return value Integer or Real Example 8 ** (1/3) returns 2 (the cubic root of 8) : MOD Returns the remainder of the division of two integer values, Valid operands Any Integer value. Data type of return value Integer Example 37 MoD 4 returns 1 Complement: ~ Returns the one's complement of an integer value. That is, converts each zero-bit to a one-bit and vice versa. Valid operands Any Integer value. Data type of return value Integer Shift Left: SHL and Shift Right: SHR Shifts the binary representation of an integer value to the right or left by a specified number of bit positions. The left operand is the value to be shifted, the right operand is the number of bit positions. Bits shifted out of the word are lost. Bit positions vacated by the shift are set to 0. Valid operands Any Integer value. Data type of return value Integer TaTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 51193 o7iozr2026 14:49 52 Chapter 4 The Script Language Example ImtTag = IntTag SHL 1; has the following results when executed repeatedly for an initial tag value of 5: Iteration _ Binary pattern —Tag value Initial value 0...) 00000101 Execution 1 9{..-]00003010 10 Execution 2 — 0[..-]00010100 Bitwise AND: & Compares the binary representations of two integer numbers, bit for bit, and returns a result according to the following table Bitin first Bitin second _Bit in operand operand result 0 0 0 0 1 0 1 ° 0 1 1 1 ‘You can use this operator to quickly “mask out” (set to 0) certain parts of a bit pattern, For example, the following statement masks out the upper 24 bits of the IntTag tag: IntTag = IntTag & 255 As shown in the table, the result bit is always 0 if one of the operand bits is 0. In the binary representation of 255, only the lower 8 bits are 1, so the 24 remaining 0-bits cause all the corresponding bits in the result to be set to 0. Valid operands Any Integer value Data type of return value Integer InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 521193 ‘o7iozr2026 14:50 ‘manual viewer Value Assignments and Operators @ 53 Bitwise OR: | Compares the binary representations of two integer numbers, bit for bit, and returns a result according to the following table: Bit in first Bit in second operand operand result 0 0 0 0 1 1 1 0 1 1 1 1 This operation is also ealled “inclusive OR.” Valid operands Any Integer value. Data type of return value Integer Bitwise XOR: * Compares the binary representations of two integer numbers, bit for bit, and returns a result according to the following table Bit in first Bit in second Bit in operand operand result 0 0 0 ° 1 1 1 0 1 1 1 0 This operation is also called “exclusive OR.” Valid operands Any Integer value Data type of return value Integer TaTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 53193 ‘o7iozr2026 14:50 ‘manual viewer 54 @ Chapter 4 The Script Language Logical Conjunction: AND Returns TRUE if both discrete operands are TRUE; otherwise, returns FALSE. The truth table for this operator is as follows: Pp 4q PANDq F F F FO TT FO. T FF... TT «T TT | Valid operands Any Diserete value. Data type of return value Discrete Logical Disjunction: OR Returns TRUE if at least one of the discrete operands is TRUE; otherwise, retwns FALSE. The truth table for this operator is as, follows: Pp q poRq F F F rr T F TT. T TT TT. Valid operands Any Discrete value. Data type of return value Discrete InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 5493 ‘o7iozr2026 14:50 ‘manual viewer Value Assignments and Operators @ 55 Logical Negation: NOT Returns TRUE if the discrete operand is FALSE, and vice versa. The truth table for this operator is as follows: Pp NOT p F T T F Valid operands Any Diserete value. Data type of return value Discrete Comparisons: <, >, <=, >=, pt These operators compare two values and return TRUE if the condition specified by the operator is met. The operands can be of any data type. For string operands, the comparison is based on alphabetical, non-case-sensitive ordering, with b being greater than a, c greater than b, and so on. For discrete operands, TRUE is considered greater than FALSE. The following table lists all comparison operators along with their conditions: Operation Example Condition ‘Less than ab a is greater than b Lessthanorequal a<=b —_ ais less than or equal tob Greater than orequal a>=b —_ais greater than or equal to b Equal a is equal tob Not equal a<>b — aisnot equal tob Valid operands Values of any data type (both values must be of the same data type). Data type of return value Discrete TaTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 551193 ‘o7iozr2026 14:50 ‘manual viewer 56 @ Chapter 4 The Script Language Setting the Evaluation Order of Operators In any expression, you can use parentheses to force operators to be evaluated in a certain order. This works the same way as in any mathematical expression. If you do not use parentheses, your expression is evaluated based on the default precedence rules for operators. The operation with the highest precedence level is executed first, followed by the operation with the second-highest precedence level, and so on. The following table shows the precedence level of each operator. Operators on the same row have the same precedence level +, NOT, - Highest precedence *,/, MOD. 7 Lowest precedence InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 561193 ‘o7iozr2026 14:50 Value Assignments and Operators _@ 57 Implicit Data Type Conversion Examples ‘The InTouch HMI scripting language provides implicit value conversion in assignments between certain data types. However, this, can lead to unexpected results, 50 you should only use this feature with caution, ‘The following table shows what happens when you assign a value of a certain type to a tag of a different type. Used Expected data datatype type — Remarks Discrete Integer A value of Ois interpreted as FALSE. Any other value is interpreted as TRUE. Discrete Real A value of 0 is interpreted as FALSE. Any other value is interpreted as TRUE. Integer Discrete A value of FALSE is converted to 0. A value of TRUE is converted to 1 Integer Real Only the value before the decimal separator is used. All decimal places are discarded. Real Avvalue of FALSE is converted to 0. A value of TRUE is converted to 1 Real Integer The value is preserved without changes, For information on using script functions to convert between other data types, see "Converting Data Types" on page 95. for Expressions The following table shows some valid expressions, along with the expression’s result and the result’s data type. Datatype Expression ofresult Result 37 Wop 4 Integer 1 37 MoD 4 == Discrete. TRUE NOT (37 MOD 4 == 4) Discrete. FALSE. InfoappActive(InfoAppTitle Diserete TRUE iff process (ya) == 1 called “xyz” is running Baten "+ Text(intTag, Message “Batch 010" if int. 000") has a value of 10 TaTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 57193 ‘o7iozr2026 14:50 58 @ Chapter 4 The Script Language The following table shows some invalid expressions, along with the reason why they are invalid. Expression Problem MOF (37 MoD 4) NOT requires a diserete operand. NOT 37 MOD 4 NOT has a higher precedence than the other operators, so the InTouch HMI tries to apply NOT to the integer value of 37 instead of the discrete result of the comparison. “patch " + ntTag When using the + operator to concatenate strings, both operands must be strings. Using Conditional Program Branching Structures ‘You can dynamically control the execution path of a seript based on. certain conditions being met. The InTouch HMI supports TF-THEN-ELSE control structures for this purpose. ‘The basic syntax for an IP-THEN-ELSE control structure is as follows: Syntax IP Condition statements and/or another IP-THEN-ELSE structure (tse statements and/or another IF-THEN-ELSE structure] ENDIF; ‘Remember the following rules when working with IP-THEN-2LSB structures: © 1P-THEN-ELSE structures can be nested, both in the THEN section and in the ELSE section. © Forevery I statement, there must be a closing ENDIP statement. An ENDIF statement always applies to the nearest prior TF statement on the same nesting level. © condition must be a valid discrete expression. The THEN section is executed if Condition is TRUE. The ELSE section is executed if Condition is FALSE. InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 58193 ‘o7iozr2026 14:50 ‘manual viewer Using Conditional Program Branching Structures @ 59 © The ELSE section is optional, © Some other programming languages allow you to check multiple conditions on the same hierarchy level of an IF-THEN-SLSE structure and have one general ELSE section that is executed if all of the conditions evaluate to FALSE. (The 1£-ElseT£-Flse structure in Visual Basic is an example of this.) This is not possible in the InTouch HMI. For every condition to check, you must open a new IF-THEN-ELSE structure. Therefore, to have a single section of code to act as the ELSE code for all conditions, you must place it in the ELSE section of the IP-THEN-ELSE structure at the last nesting level. Simple Conditional Structure ‘The following seript shows a simple conditional structure. If SuccessTag is TRUE, the “Success” window opens, otherwise the “Failure” window opens. TF SuccessTag == 1 THEN Show "Success" ELSE Show "Failure" ENDIF; Nested Conditional Structure The following seript shows how to check for multiple conditions and have one general ELSE section with code that is executed if none of the conditions are met. IP Choice?ag == 1 THEN Show "Procedure 1" ELSE IF ChoiceTag == 2 THEN Show "Procedure 2"; ELSE IF ChoiceTag 3 TN Show "Procedure 2"; ELSE Show "Detauit Procedure"; ENDIF; ENDIF; ENDIF; TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 591193 ‘o7iozr2026 14:50 ‘manual viewer 60 @ Chapter 4 The Script Language Invalid Scripting Example (Missing ENDIF) Ifyou are familiar with Visual Basie, you might TF statement like this: to write a simple IF OpenThicWindow =~ 1 THEN show "Thie Window"; This does not work in the InTouch HMI. For every IF statement, there must be a closing ENDTP statement, Invalid Scripting Example (Incorrect Nesting) If you are familiar with a language like Visual Basic, you might want to write a conditional structure with multiple conditions and a default condition like this: IP Choice?ag == 1 THEN Show "Procedure 1"; ELSE IP Choicetag show "Procedure 2 2 THEN ELSE IP ChoiceTag Show "Proceduve 3 ELSE Show "Default Praceduve"; ENDIF: This does not work in the InTouch HMI, Each TP opens a new nesting level and must have a corresponding ENDIF statement. For a correct version of this example, see "Nested Conditional Structure" on page 58. InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 0193 ‘o7iozr2026 14:50 ‘manual viewer Using Program Loops @ 61 Using Program Loops ‘Loops allow you to execute a section of code repeatedly. The InTouch HMI only supports FoR loops. A FOR loop works by monitoring the value of a numeric loop variable that is incremented or decremented with each loop iteration. The loop is executed until the value of the loop variable reaches a fixed limit. Syntax FOR LoopTag = Startxpression TO Hadxpression (STEP ChangeExpression] statements or another FOR loop - NEXT; © Start@xpression, End&xpression and ChangeBxpression together define the number of iterations, © startexpression sets the start value of the loop range. EndExpresaion sets the end value of the loop range. © STEP ChangeBxpression optionally sets the value by which the loop tag is incremented or decremented during each loop iteration; if you do not specify this, a default of 1 is used. When you execute a FoR loop, the InTouch HMI: 1 Sets LoopTas to the value of StartExpression. 2. Tests whether LoopTag is greater than EndExpreesion. If so, the InTouch HMI exits the loop. (If Changezxprese ion is negative the InTouch HMI tests whether LoopTag is less than EndExpression.) 3. Executes the statements within the loop. Increments LoopTag by the value of Change2xpression (1 unless otherwise specified) 5 Repeats steps 2 through 4. ‘Remember the following rules when working with FoR loops: © oR loops can be nested. The maximum number of nesting levels depends on the available memory and system resources, © For every For statement, there must be a closing NEXT statement. ANEXT statement always applies to the nearest prior FOR statement on the same nesting level. © Looptag must be a numeric tag (or local variable), TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide ents ‘o7iozr2026 14:50 ‘manual viewer 62 @ Chapter 4 The Script Language © StartExpression, End8xpression and ChangeBxpression must be valid expressions that evaluate to a numeric result. © If changeBxpression is positive, EndBxpression must be greater than Startexpression; if ChangeBxpression is negative StartExpression must be greater than EndExpression. Otherwise, the loop does not start. © ‘Toexit a loop, use the EXIT FOR statement. For more information, see "Forcing the End of a Loop" on page 62. © There is a time limit for loops. See "Time Limit for Loop Execution on page 63. Caution: Loop execution affects other run-time processes. For more information, see "Effect of Loops on Other Run-Time Processes" on page 63. Forcing the End of a Loop You can exit a loop at any time by calling the following statement: EXIT FOR, This statement causes script execution to continue at the statement immediately following the loop NEXT statement. Example ‘The following code fragment uses a loop to insert a large number of dummy records into a database table. If there is an error inserting a record, the loop is aborted to prevent creating more errors, FOR Counter = 1 70 1000 ResultCode = SQLInsert (ConnecticnID, "Bat *Binabist1") ; IF ResultCode <> 0 THEN Logessage ("Error creating records! Aborting.. EXIT FOR; ENDIF; NeXT; Details", InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide e293 ‘o7iozr2026 14:50 Using Program Loops @ 63 Effect of Loops on Other Run-Time Processes While a Por loop is executing, all other run-time processes in WindoviViewer are paused. This includes the following areas: © Screen updates (animation links, value displays, trends, ete.). This means that you cannot use FOR loops to animate objects, because no movement will occur until after the loop has completed, © 1/0 communications. For example, if you modify the value of an 1/0 tag in a FOR loop, only the value after the final iteration is written to the 1/0 device © Other scripts, including asynchronous QuickFunetions. ‘You can avoid pausing other run-time processes by placing the FOR Joop in an asynchronous QuickFunetion. Time Limit for Loop Execution Examples To avoid infinite loops, there is a time limit during which FoR loops must complete execution. If a loop does not complete execution after this time span, WindowViewer automatically terminates it and writes a message about the termination to the Log Viewer. The default time limit is 5 seconds. You can customize it by adding the following line to the intouch.ini file in your application directory: LeopTimeou Replace x with the time limit in seconds. Note: The time limit is checked only at the axt statement of the loop. Therefore, the first Iteration of the loop Is always executed, even if it takes longer than the time limit. of Loops The following script uses a simple loop and an indirect tag to re initialize 100 tags (Tag001 to Tag00) with a value of 0. DIM Counter AS INTEGER, FOR Counter = 1 TO 100 IndirectInteger.Name = "Tag" + Text (Counter, 000"); IndirectInteger.Value = 0 Next; TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 3/193 ‘o7iozr2026 14:50 64 @ Chapter 4 The Script Language The following seript uses two nested loops and an indirect tag to reinitialize 1000 tags (Line01_Tag001 to Line10_Tag100) with a value of 0. DIN LineCounter AS INTEGER; DIM TagCounter AS INTEGER: FOR LineCounter = 1 T0 10 FOR TagCounter = 1 TO 100 IndirectInteger.Name = "Line" + Text (LineCounter, "00") + "Tag" + Text (Tagcounter, *000") : Indirect Integer-Value = 0; MEXT: NEXT; Using Local Variables Declaring ‘You can declare loeal variables in a seript to store temporary or intermediate results. This increases performance and helps to keep your tag count low. You can use local variables just like tagnames in your seript, However, there are certain differences: © Local variables only exist within the scope of the script in which they are declared. They lose their value when script execution finishes. They cannot be referenced by any other seripts in your application, © Local variables do not have dotfields. © Local variables do not count towards the tag count. Before you can use a local variable in a seript, you must declare it: otherwise, the reference is considered a tagname. See "Declaring a Local Variable" on page 64. ‘You can declare local variables that have the same names as tags. See "Naming Conflicts between Local Variables and Tags" on page 65. a Local Variable ‘You can declare local variables anywhere in your seript, as long as you declare them before their first use. To declare a local variable, use the following statement: DIM LocVarNane (AS Dataypel LocvaxNane is the name of the local variable. The name must follow ‘the naming conventions for tagnames. For more information, see Tag Name Conventions in the InTouch® HMI Data Management Guide. Datatype is the data type of the local variable. Valid values are Discrete, Integer, Real, and Message. If you do not specify this option, Integer is used as the default InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide artes ‘o7iozr2026 14:50 ‘manual viewer Using Local Variables @ 65 ‘You must use a separate DIM statement for each local variable to declare. ‘You can declare any munber of local variables. The number is only Limited by the available memory. Examples To declare an Integer variable: DIM MytocalIntVar AS Integer: To declare multiple Real variables: DIM NyLocalRealVarl AS Real; DIM NyLocalRealVar2 AS Real; ‘The following statement is not valid: DIM MyhocalRealVarl, MyLocalRealVar? AS Real; Naming Conflicts between Local Variables and Tags ‘You can declare a local variable with the same name as an existing tag. However, when you refer to that name in a seript, the local variable always takes precedence over the tag. For example, assume you have an existing Integer tag called “iTag,” and you run the following script: DIM iTag as Integer; iTag = 20; In this scenario, the value assignment writes a value to the local variable only. The value of the tag with the same name remains unchanged. TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 651193 ‘o7iozr2026 14:50 ‘manual viewer 66 @ Chapter 4 The Script Language InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 5/193 ‘o7iozr2026 14:50 ‘manual viewer 67 Chapter 5 Custom Script Functions InTouch HMI QuickFunctions are seripts that in other environments might be known as macros, subroutines, or procedures. About QuickFunctions QuickFunctions are scripts that you can call from other scripts and animation links. The main advantage of QuickFunctions is a reduction in duplicate code, ‘You can pass values to QuickFunetions, which can use the values and return results. QuickFunctions can run asynchronously. Unlike other scripts, they can run in the background without disrupting the main program flow. ‘A QuickFunction running asynchronously can be used for time-consuming operations, such as SQL database calls, Note: Plan QuickFunctions and their arguments carefully, because if you want to modify the arguments in a QuickFunction, you must first delete all calls to that QuickFunction from every script that uses the QuickFunction. after the change Is made, you must then add the QuickFunction call back to the scripts. See the note in "Configuring QuickFunctions” on page 68. TaTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide e793 o7inzrenzs 14:50 ‘manual viewer 68 @ Chapter 5 Custom Script Functions ‘There are three basic parts of a QuickFunetion: © Name © Arguments (optional) © Script body with optional retwm values QuickFunctions are executed by using the CALL function in either an animation link or another script. See "Calling QuiekFunetions" on page 69, Configuring QuickFunctions ‘You can ereate, modify, nr delete QuickFunetions. To create a QuickFunction 1 Inthe Scripts pane, right-click QuickFunctions, and then click New. The QuickFunctions dialog box appears, Sent Eat Inset Options Help samvaed Fe) Ein ii 5 Sm &@ Oe eee (omen) (ase) [on] (ee) (cs) Ca) (cio (nor) 2. Inthe Function box, enter a name for the QuickFunetion, 3. Inthe Arguments area, for each argument, enter a name on the left and a data type on the right. InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide a/193 ‘o7iozr2026 14:50 ‘manual viewer Calling QuickFunctions_@ 69 Arguments are local variables that exist only within the QuickFunction in which they are defined. You can have up to 16 arguments per QuickFunetion. Argument names can have 81 characters but no spaces, The argument names must begin with an alpha character. Argument names must be unique, 4 Type your script in the window. 5 Tocause the QuickFunction to return a result, add to your script: RETURN value Value can be a literal value, a local variable, or global tagname or calculated expression. The script terminates at the RETURN command and continues at the calling function. 6 Click ox. To modify a QuickFunetion 1 Inthe Scripts pane, expand QuickFunctions, right-click the QuickFunction to modify and click Edit. The QuickFunctions dialog box appears. 2. Make modifications to the script body and click OK, Note: You cannot make modifications to the argument list If there are calls to the QuickFunction in the InTouch application. You must delete those calls first, close all InTouch windows, and update the use counts. To delete a QuickFunction 1 Delete all calls to the QuickFunction, close all InTouch windows, and update the use counts, 2 In the Scripts pane, expand QuickFunctions, right-click the QuickFunction to delete and click Delete. When a message appears, click Yes Calling QuickFunctions ‘You can configure scripts and animation links to call QuickFunetions and to process or show a possible return value. A QuickFunction is not called if the parameter values have not changed. You can use $second as a parameter to insure a QuickFunction is executed at least every second. For more information, see "Calling Custom Functions (QuickFunetions)" on page 47. TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide 9/193 ‘o7iozr2026 14:50 ‘manual viewer 70 @ Chapter 5 Custom Script Functions Creating Asynchronous QuickFunctions ‘You can define QuickFunetions to run asynchronously (that is, parallel) to the main program flow. To create an asynchronous QuickFunction 1 In the Seript Editor, create a QuickFunction. 2. On the Options menu, click Asynchronous. Limitations of Asynchronous QuickFunctions ‘You cannot © Return a valte from an asynchronous QuickFunetion. © Rum more than one instance of the same QuiekFunetion at the same time, © Stop asynchronous QuickFunctions after they start executing. ‘You should not © Run more than three different asynchronous QuickFunetions at the same time. Running more than three QuickFunctions at the same time reduces system performance significantly © Use asynchronous functions as part of expressions for animation inks, e.g. Tool Tips. Checking if any Asynchronous QuickFunctions are Running ‘You can check if any asynchronous QuickFunctions are running with the IsAnyAsyneFunetionBusy0 function. You ean use this function to make the QuickScript that calls an asynchronous QuickFunetion wait for all other asynchronous QuickFunctions to complete processing. IsAnyAsyncFunctionBusy() Function Returns a discrete value indicating if any asynchronous QuickFunetions are running. Syntax result ~ IsAnyAsyncFunctionBusy (timeout) Arguments result The diserete value that indicates if asynchronous QuiekFunetions are running with following meaning: InTouch HMI Scripting and Logie Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide or193 ‘o7iozr2026 14:50 ‘manual viewer Creating Asynchronous QuickFunctions_@ 71 © 0=Noasynchronous QuickFunctions are running. © 1= Asynchronous QuickFunctions are running. timeout ‘The number of seconds to wait before checking if any asynchronous QuickFunctions are running, A literal integer valve, integer tagname or integer expression. Example(s) Assume you want to connect to several SQL databases using asynchronous QuickFunetions, and you know that it takes 2 minutes to make those connections First, execute the asynchronous QuickFunetions to connect to the SQL databases, Next, use the IsAnyAsyneFunctionBusy(120) function in a QuickScript to allow enough time for SQL to make the connections before completing the QuickFunction, If after 2 minutes the connections have not been made and the asynchronous QuickFunetions are still busy trying to make the connections, a value of 1 (true) is returned by the IsAnyAsyneFunctionBusy() function ‘You can now show an error message telling the operator that the SQL connections were unsuccessful. The following script implements the scenario: IF TeAnyAeyncFunct ionBusy (120) == 1 THEN SHOW "SQL Connection Error Dialog"; ENDIF; Stopping Asynchronous QuickFunctions from Running ‘You cannot stop asynchronous QuickFunetions after they are started, but you can stop further asynchronous QuickFunetions from being started by stopping the script logic. This affects all QuickScripts in your InTouch application. For more information on stopping seript execution, see "Pausing Script Execution at Run Time" on page 40. TaTouch HMI Scripting and Logic Guide ntips:manualzz.com/dociolmfyewintouch-hmi-scriping-andogle-quide-intouchandregt3B-hmi-scripting-and-logic guide rte

You might also like