It Scripts and Logic
It Scripts and Logic
formerly Wonderware
aveva.com
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved.
No part of this documentation shall be reproduced, stored in a retrieval system, or transmitted by any means,
electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of AVEVA.
No liability is assumed with respect to the use of the information contained herein.
Although precaution has been taken in the preparation of this documentation, AVEVA assumes no responsibility
for errors or omissions. The information in this documentation is subject to change without notice and does not
represent a commitment on the part of AVEVA. The software described in this documentation is furnished under
a license agreement. This software may be used or copied only in accordance with the terms of such license
agreement.
ArchestrA, Aquis, Avantis, Citect, DYNSIM, eDNA, EYESIM, InBatch, InduSoft, InStep, IntelaTrac, InTouch, OASyS,
PIPEPHASE, PRiSM, PRO/II, PROVISION, ROMeo, SIM4ME, SimCentral, SimSci, Skelta, SmartGlance, Spiral
Software, Termis, WindowMaker, WindowViewer, and Wonderware are trademarks of AVEVA and/or its
subsidiaries. An extensive listing of AVEVA trademarks can be found at: https://sw.aveva.com/legal. All other
brands may be trademarks of their respective owners.
Publication date: Monday, August 23, 2021
Contact Information
AVEVA Group plc
High Cross
Madingley Road
Cambridge
CB3 0HB. UK
https://sw.aveva.com/
For information on how to contact sales and customer training, see https://sw.aveva.com/contact.
For information on how to contact technical support, see https://sw.aveva.com/support.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 2
Contents
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 3
Chapter 3 Script Triggers .................................................................................. 32
About Script Triggers ........................................................................................................................... 32
Types of Script Triggers ....................................................................................................................... 32
Using Multiple Triggers ....................................................................................................................... 33
Periodic Script Execution ..................................................................................................................... 33
Configuring Application Scripts ............................................................................................................ 33
Limitations of Application Scripts ............................................................................................................... 34
Configuring Window Scripts ................................................................................................................ 35
Configuring Key Scripts........................................................................................................................ 36
Configuring Condition Scripts .............................................................................................................. 38
Configuring Data Change Scripts .......................................................................................................... 40
Configuring Action Scripts ................................................................................................................... 41
Configuring ActiveX Event Scripts ........................................................................................................ 43
Pausing Script Execution at Run Time .................................................................................................. 45
$LogicRunning System Tag ......................................................................................................................... 46
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 4
Bitwise OR: | ........................................................................................................................................... 55
Bitwise XOR: ^ ......................................................................................................................................... 55
Logical Conjunction: AND ....................................................................................................................... 56
Logical Disjunction: OR ........................................................................................................................... 56
Logical Negation: NOT ............................................................................................................................ 57
Comparisons: <, >, <=, >=, ==, <> ............................................................................................................ 57
Setting the Evaluation Order of Operators ................................................................................................ 58
Implicit Data Type Conversion ................................................................................................................... 58
Examples for Expressions ........................................................................................................................... 59
Using Conditional Program Branching Structures ................................................................................. 60
Simple Conditional Structure ..................................................................................................................... 60
Nested Conditional Structure ..................................................................................................................... 60
Invalid Scripting Example (Missing ENDIF) ................................................................................................. 61
Invalid Scripting Example (Incorrect Nesting) ............................................................................................ 61
Using Program Loops .......................................................................................................................... 61
Forcing the End of a Loop........................................................................................................................... 62
Effect of Loops on Other Run-Time Processes ........................................................................................... 63
Time Limit for Loop Execution.................................................................................................................... 63
Examples of Loops ...................................................................................................................................... 63
Using Local Variables .......................................................................................................................... 64
Declaring a Local Variable .......................................................................................................................... 64
Naming Conflicts between Local Variables and Tags ................................................................................. 64
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 5
Using Trigonometric Functions .................................................................................................................. 73
Sin() Function .......................................................................................................................................... 73
ArcSin() Function .................................................................................................................................... 74
Cos() Function ......................................................................................................................................... 74
ArcCos() Function ................................................................................................................................... 75
Tan() Function ......................................................................................................................................... 75
ArcTan() Function ................................................................................................................................... 75
Returning the Value of Pi ........................................................................................................................... 76
Calculating Logarithms ............................................................................................................................... 76
Log() Function ......................................................................................................................................... 76
Exp() Function ......................................................................................................................................... 76
LogN() Function ...................................................................................................................................... 77
Calculating the Square Root ....................................................................................................................... 77
String Operations ................................................................................................................................ 78
Returning Parts of Strings........................................................................................................................... 78
StringLeft() Function ............................................................................................................................... 78
StringRight() Function ............................................................................................................................. 78
StringMid() Function ............................................................................................................................... 79
Changing Case of Strings ............................................................................................................................ 79
StringLower() Function ........................................................................................................................... 80
StringUpper() Function ........................................................................................................................... 80
Removing Spaces from Strings ................................................................................................................... 80
StringTrim() Function .............................................................................................................................. 80
Formatting Strings with Spaces .................................................................................................................. 81
Converting Between Characters and ASCII Codes...................................................................................... 82
StringChar() Function .............................................................................................................................. 82
StringASCII() Function ............................................................................................................................. 82
Searching and Replacing Text in Strings ..................................................................................................... 83
StringInString() Function ......................................................................................................................... 83
StringReplace() Function ........................................................................................................................ 84
Returning Information about Strings ......................................................................................................... 85
StringLen() Function ............................................................................................................................... 85
StringTest() Function .............................................................................................................................. 85
Comparing Strings ...................................................................................................................................... 86
StringCompare() Function ...................................................................................................................... 86
StringCompareNoCase() Function .......................................................................................................... 87
StringCompareEncrypted() Function ...................................................................................................... 87
Converting Data Types ........................................................................................................................ 88
Text() Function ........................................................................................................................................... 88
StringFromIntg() Function .......................................................................................................................... 89
StringFromReal() Function ......................................................................................................................... 89
StringToIntg() Function............................................................................................................................... 90
StringToReal() Function .............................................................................................................................. 91
DText() Function ......................................................................................................................................... 91
Working with InTouch Windows at Run Time....................................................................................... 92
Expose Window Name Property ................................................................................................................ 92
GetWindowName() Function.................................................................................................................. 92
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 6
Showing a List of Open Windows ............................................................................................................... 93
OpenWindowList() Function ................................................................................................................... 93
Checking If a Window is Open, Closed, or Exists........................................................................................ 94
WindowState() Function ......................................................................................................................... 94
Opening InTouch Windows ........................................................................................................................ 94
Show() Function ...................................................................................................................................... 95
ShowAt() Function .................................................................................................................................. 95
ShowHome() Function ............................................................................................................................ 96
ShowTopLeftAt() Function ...................................................................................................................... 96
Moving and Resizing a Window ................................................................................................................. 96
WWMoveWindow() Function ................................................................................................................. 96
Hiding InTouch Windows ........................................................................................................................... 97
Hide() Function ....................................................................................................................................... 97
HideSelf() Function ................................................................................................................................. 97
Changing the Color of a Window ............................................................................................................... 98
ChangeWindowColor() Function ............................................................................................................ 98
Printing Windows at Run Time ................................................................................................................... 98
SetWindowPrinter() Function ................................................................................................................. 98
Recommendations for Printing............................................................................................................... 99
PrintWindow() Function ......................................................................................................................... 99
PrintScreen() Function .......................................................................................................................... 100
PrintHT() Function ................................................................................................................................ 101
Starting Tag Viewer .................................................................................................................................. 101
LaunchTagViewer() Function ................................................................................................................ 101
Working with Date and Time Information .......................................................................................... 102
Retrieving Numerical Date and Time Information ................................................................................... 102
$Year System Tag.................................................................................................................................. 103
$Month System Tag .............................................................................................................................. 103
$Day System Tag ................................................................................................................................... 103
$Hour System Tag ................................................................................................................................. 104
$Minute System Tag ............................................................................................................................. 104
$Second System Tag ............................................................................................................................. 104
$Msec System Tag ................................................................................................................................ 105
$Time System Tag ................................................................................................................................. 105
$Date System Tag ................................................................................................................................. 105
$DateTime System Tag ......................................................................................................................... 105
DateTimeGMT() Function ..................................................................................................................... 106
Retrieving String Date and Time Information .......................................................................................... 106
$DateString System Tag ........................................................................................................................ 106
$TimeString System Tag ....................................................................................................................... 107
UTCDateTime() Function ...................................................................................................................... 107
Converting Date and Time Information to Strings ................................................................................... 108
StringFromTime() Function ................................................................................................................... 108
wwStringFromTime() Function ............................................................................................................. 109
StringFromTimeLocal() Function .......................................................................................................... 110
Checking the Daylight Savings Time Status .............................................................................................. 110
wwIsDaylightSaving() Function ............................................................................................................. 110
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 7
Interacting with Other Applications ................................................................................................... 111
Starting a Windows Application ............................................................................................................... 111
Retrieving the Application Title of a Running Application ....................................................................... 111
InfoAppTitle() Function......................................................................................................................... 112
Checking If an Application is Running ...................................................................................................... 112
InfoAppActive() Function ...................................................................................................................... 112
Activating a Running Windows Application ............................................................................................. 113
ActivateApp Function ........................................................................................................................... 113
Sending Simulated Key Strokes to an Application.................................................................................... 113
SendKeys Function................................................................................................................................ 113
Closing, Minimizing or Maximizing a Windows Application .................................................................... 115
WWControl() Function.......................................................................................................................... 115
Executing Commands and Exchanging Data using DDE ........................................................................... 115
WWExecute() Function ......................................................................................................................... 116
WWRequest() Function ........................................................................................................................ 116
WWPoke() Function.............................................................................................................................. 117
Working with Files ............................................................................................................................ 118
Managing Files.......................................................................................................................................... 118
FileCopy() Function ............................................................................................................................... 119
FileDelete() Function ............................................................................................................................ 120
FileMove() Function .............................................................................................................................. 120
Reading and Writing CSV Data ................................................................................................................. 121
FileReadFields() Function...................................................................................................................... 121
FileWriteFields() Function..................................................................................................................... 122
Reading and Writing Text Data ................................................................................................................ 123
FileReadMessage() Function................................................................................................................. 123
FileWriteMessage() Function................................................................................................................ 124
Retrieving System-Related Information ............................................................................................. 125
Retrieving the Node Name of the Computer ........................................................................................... 125
GetNodeName() Function .................................................................................................................... 125
Retrieving Disk Space Information ........................................................................................................... 125
InfoDisk() Function................................................................................................................................ 126
Retrieving Information on a File or Directory .......................................................................................... 126
InfoFile() Function................................................................................................................................. 126
Retrieving InTouch Related Information ............................................................................................ 127
Retrieving the Name of the InTouch Application Directory ..................................................................... 128
InfoInTouchAppDir() Function .............................................................................................................. 128
Retrieving the InTouch Version ................................................................................................................ 128
InTouchVersion() Function ................................................................................................................... 128
Security-Related Scripting ................................................................................................................. 129
Logging On and Off ................................................................................................................................... 129
Changing and Setting Password ............................................................................................................... 130
Specifying and Configuring Users ............................................................................................................. 130
Managing Security and Other Information .............................................................................................. 130
Miscellaneous Scripting..................................................................................................................... 131
Playing Sound Files from an InTouch Application .................................................................................... 131
PlaySound() Function ............................................................................................................................ 131
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 8
Getting and Setting Properties of Wizards............................................................................................... 132
GetPropertyD() Function ...................................................................................................................... 132
SetPropertyD() Function ....................................................................................................................... 133
GetPropertyI() Function ........................................................................................................................ 133
SetPropertyI() Function ........................................................................................................................ 134
GetPropertyM() Function ..................................................................................................................... 135
SetPropertyM() Function ...................................................................................................................... 135
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 9
Importing ActiveX Event Scripts ......................................................................................................... 153
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 10
Chapter 1
Introduction to Scripting
About Scripting
You can use the InTouch scripting language, QuickScript, to build more robust applications. There are eight types
of scripts and many built-in script functions available.
Scripts can be classified by when they are run and whether they run independently of other ongoing application
processes. Scripts can generally be run in two different ways:
Event-based scripts run once when an event occurs. For example, an event-based script can run after an
operator presses a key or a tag value changes.
Time-based scripts run periodically while a condition is fulfilled. For example, a time-based script can run
while a window is open or a button is kept pressed.
You can configure multiple event-based and time-based scripts to run with the same trigger. For example, you
can configure a script to run once when a key is pressed and another script to run periodically every 5 seconds
while the same key remains pressed.
You can use conditional statements, loops, and local variables in the scripting language to create complex effects
in your application.
For condition scripts you can either run a script synchronously or asynchronously.
When a synchronous script runs, all InTouch animation and tag value updating stops. Then, animation and
tag value updating resumes after the script stops.
When an asynchronous script runs, all InTouch animation and tag value updating continues during the
period when the script runs.
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 can include Object Linking and Embedding (OLE) objects and ActiveX controls.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 11
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 1 – Introduction to Scripting
A function is a script that can be called by another script. The InTouch HMI comes with a set of predefined
functions for your use.
QuickFunctions are re-usable functions written in QuickScript and stored in the QuickFunction library. To
create a QuickFunction, you simply create a QuickScript and name it. A QuickFunction can be called by
another script or from animation link expressions.
Types of Scripts
In InTouch, scripts are categorized based on what causes the script to run. For example, you would create a "key
script" 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 script to execute when the key is released, not when the key is
pressed.
The script 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 scripts execute one time or periodically when an operator clicks on an InTouch HMI graphic object.
Action scripts often are used for pushbuttons.
ActiveX event scripts execute one time when an ActiveX event occurs, such clicking the ActiveX control.
OLE Objects
In your custom scripts, 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 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.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 12
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 1 – Introduction to Scripting
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 13
Chapter 2
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 14
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 2 – Creating and Editing Scripts
Area Description
1 Toolbars
2 Condition definition area
The Condition Type box provides the available execution conditions for the type
of script you are writing.
3 Script text window
4 Command buttons
5 Built-in script function buttons
6 MEM OLE button
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.
This example is for an application script. Each type of script has its own version of the script dialog box, with
options and selections that are unique to that type of script.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 15
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 2 – Creating and Editing Scripts
The title bar of the editor identifies which type of script 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 available in a context-sensitive pop-up window
that you can click to insert that keyword, function, or symbol into your script at the cursor location.
Element Color
Keywords Blue
Syntax highlighted while typing.
Comments (both single line and Green
multi-line)
Syntax highlighted while typing.
Strings Purple
Syntax highlighted while typing.
Function names, numeric constants, Black
operators, semicolons, dim
See descriptions for Attribute names
variables, alias variables, and so on
and Reserved words.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 16
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 2 – Creating and Editing Scripts
Autocomplete displays a context-sensitive list of options for script elements, keywords, object and attribute
names, and programmatic constructs. Press Ctrl+Space to display all available autocomplete options and
variables for the selected location in the script. You can identify the context from the icons displayed at the
bottom of the autocomplete pop-up window.
Icon Represents
Method
Keywords
Operators
Variables
Tag
Windows
ActiveX Instances
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 17
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 2 – Creating and Editing Scripts
Use main menu options Edit, then Redo or Ctrl+Y to redo edits. You can also use context menu options to
undo and redo.
An undone change can be redone. Redo mirrors undo changes.
A single undo typically is comprised of sequences of typing or deleting, which can be interrupted by interaction
with an autocomplete list or by moving the cursor with the mouse, or by clicking elsewhere in the script.
All pending undo and redo actions are lost if you close the Script Editor or switch to another script within the
Script Editor.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 18
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 2 – Creating and Editing Scripts
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 19
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 2 – Creating and Editing Scripts
o On the Special menu, point to Scripts, and then click the relevant script type. The Script Editor appears.
Click the Browse button, and click the script name.
2. If applicable, in the Condition Type list, click the condition to cause the script to run.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 20
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 2 – Creating and Editing Scripts
You can also use keyboard shortcuts Ctrl+F (Quick find) and Ctrl+H (Quick replace) to display the Find and
Replace dialog box.
In a simple search using default search options, select the Quick Find tab and type a word or phrase in the
Find what field.
Select Find Next to start a search. A light blue background identifies a word or phrase in the script that
matches the search string
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 21
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 2 – Creating and Editing Scripts
In a simple replace operation using default options, select the Quick Replace tab, type a word or phrase in
the Find what field, and also type a replacement word or phrase in the Replace with field.
Select Find Next to start a replacement operation. A light blue background identifies a word or phrase in the
script that matches the search string entered in the Find what field. You have three replacement options
after locating a matching word or phrase.
o Select Find Next to ignore the current matching word or phrase and continue searching for the next
match in the script.
o Select Replace to replace the current matching word or phrase with the string entered in the Replace
with field.
o Select Replace All to replace all matching words or phrases with the string entered in the Replace with
field.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 22
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 2 – Creating and Editing Scripts
Find Options
You can expand or collapse the Find options section. The following options can be selected or cleared to filter
search results more precisely.
Match case
When selected, the search results only display instances of the Find what string that are matched both by
content and by case. For example, a search for Triangle4 with Match case selected returns Triangle4 but not
triangle4.
Match whole word
When selected, the search results only display instances of the Find what string that are matched in
complete words. For example, a search for LogicBit will return LogicBit but not LogicBits.
Search up
When selected, a search is conducted from the current position within a script to the top of the script. By
default, a search is conducted from the current position within a script to the bottom.
Search type
The Search type field provides options to conduct a script search based on the type of search.
Normal
The default search type, which requires an exact match between the characters in a search string and text in
a script.
Search by Regular Expressions on page 24
A regular expression describes one or more strings to match when you search a script. A regular expression
consists of ordinary characters that serve as a template for matching a character pattern to the string being
searched.
Search by Wildcard Characters on page 26
A wildcard search uses keyboard characters like an asterisk (*) or a question mark (?) to represent one or
more characters when searching within a script.
Search by Acronym on page 28
An acronym search matches a character at the start of a word, then every capital letter or character
following an underscore.
Search by Shorthand on page 29
A shorthand search extends the 'Search by Acronym' option by allowing non-whitespace characters between
the search pattern characters.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 23
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 2 – Creating and Editing Scripts
You must type a search string that complies with the syntax and supported characters of the selected search
type.
Match any single character s.e matches "ste" in "step" and "sfe" in
.
(except a line break) "transfer" but not "acro" in "across".
Match zero or more occurrences
of the preceding expression a*r matches "r" in "rack", "ar" in
*
(match as many characters as "ark", and "aar" in "aardvark"
possible)
c.*e matches "cke" in "racket",
Match any character zero or
.* "comme" in "comment", and "code" in
more times (Wildcard *)
"code"
Match one or more occurrences
of the preceding expression e.+e matches "eede" in "feeder" but
+
(match as many characters as not "ee".
possible)
Match any character one or more e.+e matches "eede" in "feeder" but
.+
times (Wildcard ?) not "ee".
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 24
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 2 – Creating and Editing Scripts
Anchor the match string to the End\r?$Â matches "end" only when it
\r?$
end of a line appears at the end of a line.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 25
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 2 – Creating and Editing Scripts
\ Escape
(), (?:), (?=), [] Parentheses and brackets
*, +, ?, {n}, {n,}, {n,m} Quantifiers
^, $, \anymetacharacter Anchors and sequences
| Alternation
Characters have higher precedence than the alternation operator, which, for example, allows "m|food" to
match "m" or "food".
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 26
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 2 – Creating and Editing Scripts
Examples
Logic*
Finds Logic1, LogicTest, but not ALogicTest
*Test*
Finds LogicTest1, PumpTestABC, but not LogicTst1
A question mark in a search string matches any character at a
single position within a search string.
Examples
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 27
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 2 – Creating and Editing Scripts
Search by Acronym
Acronym searching matches a character at the start of a word, then every capital letter or character following an
underscore.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 28
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 2 – Creating and Editing Scripts
Search by Shorthand
The shorthand search extends the 'Search by Acronym' option, by allowing any number of non-whitespace
characters between the search pattern characters.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 29
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 2 – Creating and Editing Scripts
The autocomplete pop-up windows include a row of icons at the bottom of the pop-up for direct access to the
available elements.
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:
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 30
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 2 – Creating and Editing Scripts
Deleting Scripts
The steps to delete a script vary depending on the script type. See the following sections:
Configuring Application Scripts on page 33.
Configuring Window Scripts on page 35.
Configuring Key Scripts on page 36.
Configuring Condition Scripts on page 38.
Configuring Data Change Scripts on page 40.
Configuring Action Scripts on page 41.
Configuring ActiveX Event Scripts on page 43.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 31
Chapter 3
Script Triggers
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 32
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 3 – Script Triggers
A window script has three triggers: on show, on hide, and while showing. Each trigger can execute a
different script.
A key script has three triggers: on key up, on key down, or while down. Each trigger can execute a different
script.
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 script executes one time when a certain ActiveX event occurs, such as a click on the
ActiveX control.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 33
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 3 – Script Triggers
2. In the Condition Type list, click the condition for the script execution:
o Click On Startup to configure a script to execute one time when WindowViewer is started.
o Click While Running to configure a script to execute periodically while WindowViewer is running.
o Click On Shutdown to configure a script to execute one time when WindowViewer is shut down.
3. If you 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 script is executed.
4. Type your script in the window.
5. Click OK.
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.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 34
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 3 – Script Triggers
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 35
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 3 – Script Triggers
3. If you select While Showing in the previous step, type a time interval between 1 and 360000 milliseconds in
the Every box.
4. Type your script in the window.
5. Click OK.
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 script 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 I/O tagnames. The I/O value update does not
necessarily complete before the window is hidden.
To read from or write to I/O tagnames when a window closes, configure a data change script and activate it
from an on hide script.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 36
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 3 – Script Triggers
o To configure a new key script, right-click Key, and then click New. The Key Scripts dialog box appears.
o 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.
3. Select the Ctrl and/or Shift check boxes to assign a control key and/or shift key combination with your
selected key.
4. In the Condition Type list, do one of the following:
o Click On Key Down to configure a script to execute one time when the associated key or key
combination is pressed.
o Click While Down to configure a script to execute periodically while the associated key or key
combination is pressed.
o Click On Key Up to configure a script to execute one time when the associated key or key combination is
released.
5. If you selected While Down in the previous step, type a time interval between 1 and 360000 milliseconds in
the Every box.
6. Type your script in the window.
7. Click OK.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 37
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 3 – Script Triggers
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 38
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 3 – Script Triggers
o Right-click Condition and click New. The Condition Scripts dialog box appears.
o To edit an existing condition script, click the plus sign next to Condition, right-click the condition script
name, and click Edit. The Edit Condition Script dialog box appears.
2. In the Condition box, type the expression that you want to use as the condition.
You can type the expression to a maximum length of 1024 characters.
3. You can enter a comment in the Comment box.
4. In the Condition Type list, do one of the following:
o Click On False to configure a script to execute one time when the condition becomes false.
o Click While False to configure a script to execute periodically while the condition is false.
o Click On True to configure a script to execute one time when the condition becomes true.
o Click While True to configure a script to execute periodically while the condition is true.
5. If you 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 OK.
To delete all condition scripts that are associated with a condition
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.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 39
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 3 – Script Triggers
2. To create 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 Tagname[.field] box and select the script
from the list that appears.
3. Type your script in the window.
4. Click OK.
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.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 40
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 3 – Script Triggers
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 41
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 3 – Script Triggers
2. Click Action. The Touch -> Action Script dialog box appears.
One time when the left mouse button or a certain key or key On Left Click/Key Down
combination is pressed
Periodically while the left mouse button or a certain key or While Left/Key Down
key combination is pressed
One time when the left mouse button or a certain key or key On Left/Key Up
combination is released
One time when the left mouse button is double-clicked On Left Double Click
One time when the right mouse button is pressed On Right Click
Periodically while the right mouse button is pressed While Right Down
One time when the right mouse button is released On Right Up
One time when the right mouse button is double-clicked On Right Double Click
One time when the center mouse button is pressed On Center Click
Periodically while the center mouse button is pressed While Center Down
One time when the center mouse button is released On Center Up
One time when the center mouse button is double-clicked On Center Double Click
One time when the mouse moves over the object On Mouse Over
4. If you select On Left Click/Key Down, While Left/Key Down, or On Left/Key Up:
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 42
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 3 – Script Triggers
2. Click to clear the Action check box. The action scripts will not be executed during run time. If you click 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 script to delete. The object properties panel appears.
2. Click the Action button. The Touch -> Action Script dialog box appears.
3. In the Condition Type list, click the script trigger.
4. On the Edit menu, click Clear. The script from the main section clears and the associated script is deleted.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 43
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 3 – Script Triggers
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 44
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 3 – Script Triggers
5. Type in a 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.
6. In the Name box, you can make changes to the ActiveX event script name.
7. Type your script 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 script name and
click Edit. The ActiveX Event Scripts dialog box appears.
2. Make any necessary changes to the script and click OK.
To delete an existing ActiveX event script
1. Make sure that no ActiveX controls are using the ActiveX event script to delete. If there are ActiveX controls
using the script, 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 script is deleted.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 45
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 3 – Script Triggers
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 46
Chapter 4
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 47
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 4 – The Script Language
Subroutines
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 QuickFunction for each subroutine. See
Custom Script Functions on page 66.
Statements
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).
Indentation
You can indent your script code in any manner. Indents have no functional relevance.
Comments
To mark text as a comment, enclose it in braces { }. Comments can span multiple lines.
Tag References
There are several ways to make tag references.
To refer to a tag that is defined in the local Tagname Dictionary, simply use the tagname.
To refer to a specific dot field, use the regular reference format (Tagname.Dotfield).
To refer to a data item on a remote node, use a regular remote tag reference (AccessName:Item).
You can also define local variables whose scope is limited to the current script. See Using Local Variables on
page 64.
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 51.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 48
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 4 – The Script Language
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 30.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 49
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 4 – The Script Language
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.
Note: You cannot nest QuickFunction calls so that a QuickFunction is used as a parameter for another
QuickFunction. For example, Call QF1(Call QF2()); is not a valid statement.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 50
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 4 – The Script Language
Supported Operators
The following table lists all supported operators. For information on the use of a specific operator, see the
relevant section.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 51
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 4 – The Script Language
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
Example
MessageTag = "Setpoint value: " + Text(SetpointTag, "#.##");
Subtraction: -
When used with two operands, performs a regular numeric subtraction.
Valid operands
Any Integer or Real value
Data type of return value
Integer or Real
Example
In this example, if TemperatureSetpoint is 70, after the script executes TemperatureSetpoint is 65.
TemperatureSetpoint = TemperatureSetpoint – 5;
Multiplication: *
Regular numeric multiplication.
Valid operands
Any Integer or Real value
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 52
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 4 – The Script Language
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).
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)
Modulo: 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.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 53
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 4 – The Script Language
0 0 0
0 1 0
1 0 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.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 54
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 4 – The Script Language
Valid operands
Any Integer value.
Data type of return value
Integer
Bitwise OR: |
Compares the binary representations of two integer numbers, bit for bit, and returns a result according to the
following table:
0 0 0
0 1 1
1 0 1
1 1 1
Bitwise XOR: ^
Compares the binary representations of two integer numbers, bit for bit, and returns a result according to the
following table:
0 0 0
0 1 1
1 0 1
1 1 0
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 55
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 4 – The Script Language
Valid operands
Any Integer value.
Data type of return value
Integer
p q p AND q
F F F
F T F
T F F
T T T
Valid operands
Any Discrete value.
Data type of return value
Discrete
Logical Disjunction: OR
Returns TRUE if at least one of the discrete operands is TRUE; otherwise, returns FALSE. The truth table for this
operator is as follows:
p q p OR q
F F F
F T T
T F T
T T T
Valid operands
Any Discrete value.
Data type of return value
Discrete
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 56
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 4 – The Script Language
p NOT p
F T
T F
Valid operands
Any Discrete value.
Data type of return value
Discrete
Valid operands
Values of any data type (both values must be of the same data type).
Data type of return value
Discrete
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 57
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 4 – The Script Language
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 58
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 4 – The Script Language
For information on using script functions to convert between other data types, see Converting Data Types on
page 88
Data type of
Expression result Result
37 MOD 4
Integer 1
37 MOD 4 == 1
Discrete TRUE
NOT (37 MOD 4 == 1)
Discrete FALSE
InfoAppActive(InfoAppTitle
("xyz")) == 1 Discrete TRUE if a process called
"xyz" is running
"Batch " + Text(IntTag,
"000") Message "Batch 010" if IntTag
has a value of 10
The following table shows some invalid expressions, along with the reason why they are invalid.
Expression Problem
NOT (37 MOD 4)
NOT requires a discrete operand.
NOT 37 MOD 4 == 1
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.
"Batch " + IntTag
When using the + operator to concatenate
strings, both operands must be strings.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 59
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 4 – The Script Language
For every IF statement, there must be a closing ENDIF statement. An ENDIF statement always applies to the
nearest prior IF 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.
The ELSE section is optional.
Some other programming languages allow you to check multiple conditions on the same hierarchy level of
an IF-THEN-ELSE structure and have one general ELSE section that is executed if all of the conditions
evaluate to FALSE. (The If-ElseIf-Else 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 IF-THEN-ELSE structure at the last nesting level.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 60
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 4 – The Script Language
StartExpression sets the start value of the loop range. EndExpression sets the end value of the loop
range.
STEP ChangeExpression 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 LoopTag to the value of StartExpression.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 61
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 4 – The Script Language
2. Tests whether LoopTag is greater than EndExpression. If so, the InTouch HMI exits the loop. (If
ChangeExpression is negative, the InTouch HMI tests whether LoopTag is less than EndExpression.)
3. Executes the statements within the loop.
4. Increments LoopTag by the value of ChangeExpression (1 unless otherwise specified).
5. Repeats steps 2 through 4.
Remember the following rules when working with FOR loops:
FOR 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. A NEXT statement always applies to the
nearest prior FOR statement on the same nesting level.
LoopTag must be a numeric tag (or local variable).
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 62
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 4 – The Script Language
Examples of Loops
The following script uses a simple loop and an indirect tag to re initialize 100 tags (Tag001 to Tag100) with a
value of 0.
DIM Counter AS INTEGER;
FOR Counter = 1 TO 100
IndirectInteger.Name = "Tag" + Text(Counter, "000");
IndirectInteger.Value = 0;
NEXT;
The following script uses two nested loops and an indirect tag to reinitialize 1000 tags (Line01_Tag001 to
Line10_Tag100) with a value of 0.
DIM LineCounter AS INTEGER;
DIM TagCounter AS INTEGER;
FOR LineCounter = 1 TO 10
FOR TagCounter = 1 TO 100
IndirectInteger.Name = "Line" + Text(LineCounter, "00") + "_Tag" + Text(TagCounter,
"000");
IndirectInteger.Value = 0;
NEXT;
NEXT;
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 63
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 4 – The Script Language
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 64
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 4 – The Script Language
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.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 65
Chapter 5
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 QuickFunctions, 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 66.
There are three basic parts of a QuickFunction:
Name
Arguments (optional)
Script body with optional return values
QuickFunctions are executed by using the CALL function in either an animation link or another script. See Calling
QuickFunctions on page 68.
Configuring QuickFunctions
You can create, modify, or delete QuickFunctions.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 66
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 5 – Custom Script Functions
To create a QuickFunction
1. In the Scripts pane, right-click QuickFunctions, and then click New. The QuickFunctions dialog box appears.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 67
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 5 – Custom Script Functions
Calling QuickFunctions
You can configure scripts and animation links to call QuickFunctions 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 (QuickFunctions) on page 50.
IsAnyAsyncFunctionBusy() Function
Returns a discrete value indicating if any asynchronous QuickFunctions are running.
Syntax
result = IsAnyAsyncFunctionBusy (timeout)
Arguments
result
The discrete value that indicates if asynchronous QuickFunctions are running with following meaning:
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 68
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 5 – Custom Script Functions
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 69
Chapter 6
Built-In Functions
Mathematical Calculations
The InTouch HMI supports basic mathematical functions that you can use in scripts and in animation links, such
as functions to:
Round and truncate numbers.
Calculate sine and cosine.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 70
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Use To
Abs() Function
Returns the absolute value of a specified number. You can use this to convert a negative number to a positive
number.
Syntax
result = Abs (number)
Parameters
number
A literal number, analog tagname, or numeric expression.
Example(s)
Abs(14) returns 14.
Abs(-7.5) returns 7.5.
Int() Function
Returns the integer less than (or equal to) a specified number.
Syntax
result = Int (number)
Parameters
number
A literal number, analog tagname, or numeric expression.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 71
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Example(s)
Int(4.7) returns 4.
Int(-4.7) returns -5.
Note: For negative real numbers, this function returns an integer that is smaller than the specified number. For
example, Int(-4.7) is not -4, but -5. To have the integer part returned, use the Trunc() function. See Trunc()
Function on page 73.
Round() Function
Rounds a number to a specified precision. The result is a real number.
Syntax
result = Round (number, precision)
Parameters
number
A literal number, analog tagname, or numeric expression.
precision
The precision to which the number is rounded. Can be a literal number, analog tagname, or numeric
expression.
Example(s)
Round(4.3, 1) returns 4.
Round(4.3, 0.01) returns 4.30.
Round(4.5, 1) returns 5.
Round(-4.5, 1) returns -4.
Round(106, 5) returns 105.
Round(43.7, 0.5) returns 43.5.
Sgn() Function
Returns the sign of a number. Use it to determine if a number, tagname, or expression is negative, positive, or
zero.
Syntax
result = Sgn (number)
Parameters
number
A literal number, analog tagname, or numeric expression.
Example(s)
Sgn(425) returns 1.
Sgn(0) returns 0.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 72
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Trunc() Function
Returns the truncated value of a number. The truncated value is the part before a decimal point. Use it to work
with the integer part of a real number.
Syntax
result = Trunc (number)
Parameters
number
A literal number, analog tagname, or numeric expression.
Example(s)
Trunc(4.3) returns 4.
Trunc(-4.3) returns -4.
Note: You can also use this function to work with the fractional part of a number. To return the fractional part of
a specified number use the Trunc() function as follows:
result = number - trunc(number);
Use To
Note: Trigonometric QuickScript functions in the InTouch HMI use angles in degrees (0 - 360). To work with
radians instead you must perform the corresponding calculation before passing the parameter to the function or
after retrieving the result from the function.
Sin() Function
Returns the sine of a number. For trigonometric functions the number is the angle in degrees.
Syntax
result = Sin (number)
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 73
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Parameters
number
A literal number, analog tagname, or numeric expression.
Example(s)
Sin(90) returns 1.
Sin(0) returns 0.
Sin(30) returns 0.5.
100 * Sin (6 * $second) returns a sine wave with an amplitude of 100 and a period of one minute.
ArcSin() Function
Returns the arc sine of a number. It is the reciprocal function to the Sin() function. Use the ArcSin() function to
calculate the angle from -90 to 90 degrees whose sine is equal to that number.
Syntax
result = ArcSin (number)
Parameters
number
A literal number, analog tagname, or numeric expression in the range of -1 to 1.
Example(s)
ArcSin(1) returns 90.
ArcSin(0) returns 0.
ArcSin(0.5) returns 30.
Cos() Function
Returns the cosine of a number. For trigonometric functions the number is the angle in degrees.
Syntax
result = Cos (number)
Parameters
number
A literal number, analog tagname, or numeric expression.
Example(s)
Cos(90) returns 0.
Cos(0) returns 1.
Cos(60) returns 0.5.
20 + 50 * Cos(6 * $second) produces a sine wave oscillating around 20 with an amplitude of 50 and a period
of one minute.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 74
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
ArcCos() Function
Returns the arcus cosine of a number. It is the reciprocal function to the Cos() function. Use the ArcCos()
function to calculate the angle from 0 to 180 degrees whose cosine is equal to that number.
Syntax
result = ArcCos (number)
Parameters
number
A literal number, analog tagname, or numeric expression in the range of -1 to 1.
Example(s)
ArcCos(1) returns 0.
ArcCos(-0.5) returns 120.
Tan() Function
Returns the tangent of a specified number. For trigonometric functions the number is the angle in degrees.
Syntax
result = Tan (number)
Parameters
number
A literal number, analog tagname, or numeric expression.
Example(s)
Tan(45) returns 1.
Tan(0) returns 0.
ArcTan() Function
Returns the arcus tangent of a number. It is the reciprocal function to the Tan() function. Use the ArcTan()
function to calculate the angle whose tangent is equal to that number.
Syntax
result = ArcTan (number)
Parameters
number
A literal number, analog tagname, or numeric expression.
Example(s)
ArcTan(1) returns 45.
ArcTan(0) returns 0.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 75
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Example(s)
Pi() returns 3.1415927.
Calculating Logarithms
In a script, you can use the following functions to run calculations with logarithms and exponential functions.
Use To
Log() Function
Returns the natural logarithm of a specified positive number. This is the reciprocal function to the Exp() function.
Note: The natural logarithm of 0 and negative numbers is undefined. If you pass 0 or a negative number to the
Log() function, it returns a result of -99.0000000.
Syntax
result = Log (number)
Parameters
number
A positive literal number, analog tagname, or numeric expression.
Example(s)
Log(100) returns 4.6051702.
Log(1) returns 0.
Exp() Function
Returns the exponential of a specified number. This is the reciprocal function to the Log() function and is
equivalent to e raised to a power.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 76
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Note: If you pass values outside the range of -88.72 to 88.72 to the Exp() function, it returns a result of
-99.0000000.
Syntax
result = Exp (number)
Parameters
number
A literal number, analog tagname, or numeric expression in the range of -88.72 to 88.72.
Example(s)
Exp(1) returns 2.7182818.
Exp(0) returns 1.
LogN() Function
Returns the logarithm of a positive number to a specified base. This is the reciprocal function to the base to the
power of the logarithm.
Example(s)
Syntax
result = LogN (number, base)
Parameters
number
A positive literal number, analog tagname, or numeric expression.
base
A positive literal number, analog tagname, or expression unequal to 1.
Example(s)
LogN(8,2) returns 3.
LogN(num,btag) returns the logarithm of num to the base btag.
Note: If you pass invalid parameters to the LogN() function, it returns a result of -99.0000000.
Note: If you pass a negative value to the Sqrt() function, it returns a result of -99.0000000.
Syntax
result = Sqrt (number)
Parameters
number
A non-negative literal number, analog tagname, or numeric expression
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 77
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Example(s)
Sqrt(36) returns 6.
Sqrt(perftag) returns the square root of the value held by the tagname perftag.
String Operations
You can use many basic string functions in scripts and animation links. You can use these functions to:
Return parts of strings.
Change the case of strings.
Remove and add spaces to strings.
Handle ASCII values in strings.
Search and replace in strings.
Compare strings with each other.
Return other information about strings, such as their length.
StringLeft() Function
Returns a specified number of characters from the beginning of a string.
Syntax
result = StringLeft (string, length)
Parameters
string
A literal text, message tagname, or string expression.
length
The numbers of characters to return. A literal number, analog tagname, or numeric expression.
Example(s)
StringLeft("Hello World",5) returns "Hello".
StringLeft("Hello World",20) returns "Hello World".
StringLeft("Hello World",0) returns "Hello World".
Note: If you pass 0 as length to the StringLeft() function, it returns the entire string.
StringRight() Function
Returns a specified number of characters from the end of a string.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 78
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Syntax
result = StringRight (string, length)
Parameters
string
A literal text, message tagname, or string expression.
length
The number of characters to return. A literal number, analog tagname, or numeric expression.
Example(s)
StringRight("Hello World",5) returns "World".
StringRight("Hello World",20) returns "Hello World".
StringRight("Hello World",0) returns "Hello World".
Note: If you pass 0 as length to the StringRight() function, it returns the entire string.
StringMid() Function
Returns a part of a string. You can specify the starting point and how many characters to return.
Syntax
result = StringMid (string, startpos, length)
Parameters
string
A literal text, message tagname, or string expression.
startpos
The starting position in the string. A literal number, analog tagname, or numeric expression.
length
The number of characters to return. A literal number, analog tagname, or numeric expression.
Example(s)
StringMid("Hello World",5,4) returns "o Wo".
StringMid("Hello World",7,50) returns "World".
StringMid("Hello World",4,0) returns "lo World".
Note: If you pass 0 as length to the StringMid() function, it returns the entire string after the starting position.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 79
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
StringLower() Function
Returns the lowercase equivalent of a string.
Syntax
result = StringLower (string)
Parameters
string
A literal text, message tagname, or string expression.
Example(s)
StringLower("TURBINE") returns "turbine".
StringLower("The Value Is 22.2") returns "the value is 22.2".
mtag = StringLower(mtag) converts the message value of mtag to lowercase.
StringUpper() Function
Returns the uppercase equivalent of a string.
Syntax
result = StringUpper (string)
Parameters
string
A literal text, message tagname, or string expression.
Example(s)
StringUpper("abcd") returns "ABCD".
StringUpper("The Value Is 22.2") returns "THE VALUE IS 22.2".
mtag = StringUpper(mtag) converts the message value of mtag to uppercase.
StringTrim() Function
Rrim leading and trailing spaces (blanks) from strings. You can use this to remove unwanted spaces from a
string, for example after a user input.
Syntax
result = StringTrim (string, trimtype)
Parameters
string
A literal text, message tagname, or string expression.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 80
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
trimtype
A literal value, analog tagname, or numeric expression that determines which spaces to remove:
o 1 = Leading spaces.
o 2 = Trailing spaces.
o 3 = Leading and trailing spaces.
Remarks
This function removes all leading and trailing white spaces from a string. White spaces are spaces (ASCII 0x20)
and control characters in the range from ASCII 0x09 to 0x0D.
Example(s)
To remove all spaces in a message tag, mtag, with an action script, use the following script:
DIM i AS INTEGER;
DIM tmp AS MESSAGE;
mtag = StringTrim(mtag,3); {mtag is trimmed}
FOR i = 1 TO StringLen(mtag) {run variable i over the characters of mtag}
IF StringMid(mtag, i, 1)<>" " THEN {i-th character is not space} tmp = tmp +
StringMid(mtag, i, 1); {
add that character to tmp}
ENDIF;
NEXT;
mtag = tmp; {pass tmp back to mtag}.
Other examples:
StringTrim(" Joe ",1) returns "Joe ".
StringTrim(" Joe ",2) returns " Joe".
This script removes all spaces from the left and the right of the mtag value:
mtag = StringTrim(mtag,3)
Parameters
number
A literal number, numeric tagname, or numeric expression.
Example(s)
StringSpace(4) returns a string consisting of 4 blanks.
"Pump"+StringSpace(1)+"Station" returns "Pump Station".
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 81
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
StringChar() Function
Returns a single character corresponding to a specified ASCII code.
Syntax
result = StringChar (ASCIICode)
Parameters
ASCIICode
A literal number, numeric tagname, or numeric expression in the range of 0 to 255.
Remarks
This function is very useful for passing control characters to external devices (such as printers or modems) or
double quotes to SQL queries.
Example(s)
StringChar(65) returns "A".
This script returns "Hello World" enclosed by double quotes:
StringChar(34)+"Hello World"+StringChar(34)
This script returns "Hello World" where both words are separated by a carriage return and a line feed:
"Hello"+StringChar(13)+StringChar(10)+"World"
StringASCII() Function
Returns the ASCII code of the first character of a string.
Syntax
result = StringASCII (string)
Parameters
string
A literal string, message tagname, or string expression.
Example(s)
StringASCII("A") returns 65.
StringASCII("hello world") returns 104.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 82
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Use To
StringInString() Function
Returns the first position of a specified string in another string.
Syntax
result = StringInString (string, searchfor, startpos, casesens)
Parameters
string
This is the string to searched. A literal string, message tagname, or string expression.
searchfor
This is the string that is to be searched for. A literal string, message tagname, or string expression.
startpos
This is the starting position in string of the search. A literal value, numeric tagname, or numeric expression.
casesens
Determines whether the search is case sensitive. Can be 0 or 1, discrete tagname, or Boolean expression.
0 - search is not case sensitive (uppercase and lowercase are considered the same).
1 - search is case sensitive (uppercase and lowercase are considered to be different).
Remarks
Use this function to determine if a certain string is contained in a message tag. You can specify the starting
position for the search and whether the letter case is to be respected.
Example(s)
This script returns 5—because the first "M" in "MTX" is in the fifth position of the string:
StringInString("DBO MTX-010","MTX",1,0)
This script returns 3—because the first "M" in "MTX" is in the third position in the string:
StringInString("T-MTX 010 MTX","MTX",1,0)
This script returns 11—because the first "M" in "MTX" after the 8th position is in the 11th position in the string:
StringInString("T-MTX 010 MTX","MTX",8,0)
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 83
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
This script returns 11—because the first string that matches MTX in the correct case is in the 11th position:
StringInString("t-mtx 030 MTX", "MTX",1,1)
This script returns 0—because there is no "Mty" in the string:
StringInString("t-mtx 030 MTY-Mtx","Mty",1,1)
StringReplace() Function
Searches for a string within another string and, if found, replaces it with yet another string. You can specify:
Case-sensitivity - This determines if uppercase letters and lowercase letters are to be treated as identical
letters or not.
Number of occurrences to replace - This is useful if more than one occurrence of the search string is found.
Match whole words - Use this if the search string is a whole word.
Note: This function does not support double byte character sets.
Syntax
result = StringReplace (string, searchfor, replacewith, casesens, numtoreplace,
matchwholewords)
Parameters
string
The string to search within. A literal string, message tagname, or string expression.
searchfor
The string that is to be searched for. A literal string, message tagname, or string expression.
replacewith
The string that is used as replacement. A literal string, message tagname, or string expression.
casesens
Determines whether the search is case sensitive. Can be 0 or 1, discrete tagname or Boolean expression.
0 - search is not case sensitive (uppercase and lowercase are considered the same)
1 - search is case sensitive (uppercase and lowercase are considered to be different)
numtoreplace
The number of replacements to make. Set it to -1 to replace all occurrences of the found search string. A
literal integer value, integer tagname, or integer expression.
matchwholewords
Determines whether only whole words are matched. Can be 0 or 1, discrete tagname, or Boolean
expression.
0 - the function looks for the search string characters anywhere in the string
1 - only whole words are matched
Example(s)
This statement replaces only the first occurrence and returns "MTY 030 MTX".
StringReplace("MTX 030 MTX","MTX","MTY",0,1,0)
This statement replaces all occurrences and returns "MTY 030 MTY".
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 84
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
StringLen() Function
Returns the length of a specified string, including non-visible characters.
Syntax
result = StringLen (string)
Parameters
string
A literal string, message tagname, or string expression.
Example(s)
StringLen("Twelve percent") returns 14.
StringLen("12%") returns 3.
StringLen("The end." + StringChar(13)) returns 9.
StringTest() Function
Tests whether the first character of a string is in a certain group of characters.
Syntax
result = StringTest (string, group)
Parameters
string
A literal string, message tagname, or string expression.
group
The number of the group to test the character against. A literal value, integer tagname, or integer expression
in the range of 1 to 11.
1 - alphanumeric characters (A-Z, a-z, 0-9)
2 - numeric characters (0-9)
3 - alphabetic characters (A-Z, a-z)
4 - uppercase characters (A-Z)
5 - lowercase characters (a-z)
6 - punctuation characters (ASCII 0x21 - 0x2F), for example !,@,#,$,%,^,&,* and so on
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 85
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Comparing Strings
In a script, you can use the StringCompare(), StringCompareNoCase() and StringCompareEncrypted() functions
to compare two strings.
Use To
StringCompare() Function
Compares two strings with each other and returns a Boolean result (0 = strings are equal). The case of each
letter is respected so that, for example, ‘A’ is considered not equal to ‘a’.
Syntax
result = StringCompare (string1, string2)
Parameters
string1
A literal string, message tagname, or string expression.
string2
A literal string, message tagname, or string expression.
Example(s)
StringCompare ("Apple","Apple") returns 0.
StringCompare ("Apple","apple") returns 1.
This string compares the two message tags and returns a discrete result (0 or 1):
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 86
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
StringCompareNoCase() Function
Compares two strings with each other and returns an integer result. The case of each letter is not respected so
that, for example, ‘A’ is considered equal to ‘a’.
The integer result returns:
0 if both strings are identical (ignoring case).
Non-zero otherwise. The result is the difference of ASCII values between the differentiating character
(ignoring case).
Note: The result of the StringCompareNoCase() function can be used as a discrete result, as all non-zero values
are considered to equal TRUE in InTouch scripting.
Syntax
result = StringCompareNoCase (string1, string2)
Parameters
string1
A literal string, message tagname, or string expression.
string2
A literal string, message tagname, or string expression.
Example(s)
This string returns 0—because the strings are considered identical:
StringCompareNoCase("Apple","apple")
This string returns -6—because the strings are considered not identical and the ASCII values of the first
differentiating character "p" minus the ASCII value of the corresponding letter "v" equals -6:
StringCompareNoCase("Apple","Avocado")
StringCompareEncrypted() Function
Compares an encrypted string with an unencrypted string and returns a Boolean result. You can use this
function for password verification. For more information on password encryption, see Animating Objectsin the
InTouch® HMI Visualization Guide.
Syntax
result = StringCompareEncrypted (plain, encrypted)
Parameters
plain
A literal string, message tagname, or string expression.
encrypted
An encrypted message tagname.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 87
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Example(s)
This script returns 1 when the plain text and the encrypted text are identical, otherwise it returns 0. Passwd is a
message tag containing a value from an encrypted user input. PlainTxt is a message tag against which the user
input is to be compared.
StringCompareEncrypted(PlainTxt, Passwd)
Text() Function
The Text() function returns the value of a number as a string according to a specified format. You may want to
do this to format a value in a certain way or to combine the result with other string values for further
processing.
Syntax
result = Text (number, format)
Parameters
number
A literal numeric value, analog tagname, or numeric expression.
format
Use "#", "0", ".", or ",".
Use "#" to represent a digit, "." to represent the decimal separator, "0" to force a leading zero, and "," to
insert a comma.
If you use a zero in the format, it must be followed by zeros. All places to the right of the decimal point must
always be zeros. For example, 000.00 is correct, while #0#0.0# is incorrect.
The function rounds the value, if necessary. A literal string, message tagname, or string expression.
Example(s)
Text(66,"#.00") returns "66.00".
Text (1234,"#") returns "1234".
Text (123.4, "#,##0.0") returns "123.4".
Text (12.3, "0,000.0") returns "0,012.3".
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 88
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
StringFromIntg() Function
In a script, you can convert an integer value to a string value by using the StringFromIntg() function.
This function returns the string value of an integer value and performs a base conversion at the same time. This
can be used, for example, to show text together with integer values or for converting integer values to
hexadecimal numbers.
Syntax
result = StringFromIntg (number, base)
Parameters
number
A literal integer value, integer tagname, or integer expression.
base
The base of the conversion. This is used for converting the value to a different base, such as binary (2),
decimal (10) or hexadecimal (16). A literal integer value, integer tagname, or integer expression.
Example(s)
StringFromIntg(26,2) returns "11010" (binary.
StringFromIntg(26,8) returns "32"—because
(base 8: 26 = 3*8 + 2)
StringFromIntg(26,10) returns "26" (decimal).
StringFromIntg(26,16) returns "1A" (hexadecimal).
StringFromReal() Function
In a script, you can convert an real value to a string value by using the StringFromReal() function.
You can also specify to:
Round the value to a specified precision.
Pass the value in exponential notation.
This can be used, for example, to show text together with real values or for showing real numbers with
exponential notation.
Syntax
result = StringFromReal (number, precision, type)
Parameters
number
A literal value, analog tagname, or numeric expression.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 89
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
precision
Specifies how many decimal places are to be used. A literal integer value, integer tagname, or integer
expression.
type
Specifies if the exponential notation is to be used. A literal string, message tagname, or string expression.
"f" - Use floating point notation.
"e" - Use exponential notation with lowercase "e".
"E" - Use exponential notation with uppercase "E".
Example(s)
StringFromReal(263.355, 2,"f") returns "263.36".
StringFromReal(263.355, 2,"e") returns "2.63e2".
StringFromReal(263.55, 3,"E") returns "2.636E2".
StringFromReal(0.5723, 2,"E") returns "5.72E-1".
StringToIntg() Function
In a script, you can convert a value contained in a string to an integer value by using the StringToIntg() function.
You can use this to read a value contained at the beginning of a string into an integer tag for further
mathematical operations.
Syntax
result = StringToIntg (string)
Parameters
string
A literal string, message tagname, or string expression.
Remarks
The function checks the first character of the string. If it is a number, it attempts to read this and the following
characters as an integer number until a non-numeric character is met. The function ignores leading spaces in the
string.
Example(s)
StringToIntg("ABCD") returns 0.
StringToIntg("13.4 mbar") returns 13.
StringToIntg("Pressure is 13.4") returns 0.
To extract the first integer from a string (mtag) that is not at the beginning and to store it in the integer tag itag,
use the following action script:
DIM i AS INTEGER;
DIM tmp AS INTEGER;
FOR i = 1 TO StringLen(mtag) {run variable i over the characters of mtag}
tmp = StringASCII(StringMid(mtag, i, 1)) - 48; {detect ASCII value}
IF (tmp>=0 AND tmp<10) THEN {if ASCII value represented "0" - "9"}
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 90
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
itag = StringToIntg(StringMid(mtag, i, 0)); {set itag to value from that position and
exit loop}
EXIT FOR;
ENDIF;
NEXT;
StringToReal() Function
In a script, you can convert a value contained in a string to a real value by using the StringToReal() function.
You can use this to read a value contained at the beginning of a string into a real tag for further mathematical
operations.
Note: This function also supports the exponential notation and converts a string expression 1e+6 correctly to
1000000.
Syntax
result = StringToReal (string)
Parameters
string
A literal string, message tagname, or string expression.
Remarks
The function checks the first character of the string. If it is a number, it attempts to read this and the following
characters as a real number until a non-numeric character is met. The function ignores leading spaces in the
string.
To extract the first real number from a string (message tag mtag) that is not at the beginning and store it in the
real tag rtag1, use the following script:
DIM i AS INTEGER;
DIM tmp AS INTEGER;
FOR i = 1 TO StringLen(mtag) {run variable i over the characters of mtag}
tmp = StringASCII(StringMid(mtag, i, 1)) - 48; {detect ASCII value}
IF (tmp>=0 AND tmp<10) THEN {if ASCII value represented "0" - "9"}
rtag = StringToReal(StringMid(mtag, i, 0)); {set rtag to value from that position and exit loop}
EXIT FOR;
ENDIF;
NEXT;
Example(s)
StringToReal("ABCD") returns 0.
StringToReal("13.4 mbar") returns 13.4.
StringToReal("Pressure is 13.4") returns 0.
DText() Function
In a script, you can convert a Boolean value to a string value by using the DText() function. You can use this
function to use customized message display animation links.
This function returns different string values depending on the value of a Boolean value.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 91
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Syntax
result = Dtext (Boolean, stringtrue, stringfalse)
Parameters
Boolean
A literal Boolean value, discrete tagname, or Boolean expression.
stringtrue
The string to be returned if Boolean is true. A literal string value, message tagname, or string expression.
stringfalse
The string to be returned if Boolean is false. A literal string value, message tagname, or string expression.
Example(s)
This script returns "Running" if the discrete tagname switch is TRUE, otherwise it returns "Stopped".
DText(switch,"Running","Stopped")
This script returns the On and Off Messages of another discrete tag switch2 depending on the value of the
discrete tag switch1.
DText(switch1,switch2.OnMsg,switch2.OffMsg)
GetWindowName() Function
Retrieves the name of the window under which the function has been called.
Syntax
The syntax of the script function is as follows:
resultcode = GetWindowName(tagname);
Resultcode indicates the success or failure of the script function. The resultcode can be a Discrete/Integer/Real
data type. Resultcode will be 1 or 0, based on the success or failure of the script function:
Resultcode is 1 when the script function is called from window context.
Resultcode is 0 when the script function is called from non-window context.
Note: Configuration of the return value for the script function is optional. This is similar to the existing script
functions in InTouch.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 92
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Parameter
TagName
The tagname is the out parameter for this function. This will be a message tag to retrieve the window name.
The parameter for the function can be any of the following:
InTouch tag
Dot field
Local variable in the script
Remote tag reference
Galaxy reference
The default text loaded by the script browser is:
GetWindowName(TagName);
Note: "TagName" is a message tag or Remote Tag Reference (RTR) which is of message type.
Return Value
The GetWindowName script function returns the window name with the return value of 1 in the following
scenarios:
Window scripts (All Condition Types)
Push button action scripts (All Condition Types)
The GetWindowName script function returns an empty string with return value of 0 in the following scenarios:
Application scripts
Key scripts
Condition scripts
Data change scripts
ActiveX event scripts
Quick script functions (Synchronous and Asynchronous)
OpenWindowList() Function
Shows a dialog box containing the list of InTouch windows that are currently open.
You can not use this function in an animation link.
Syntax
[result = ]OpenWindowsList();
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 93
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Example(s)
This script opens the Open Windows List dialog box and shows all InTouch windows that are currently open.
OpenWindowsList()
Note: When the Use In-Memory Window Cache WindowViewer option is enabled, closed windows may appear
in the list created by the OpenWindowList() function.
WindowState() Function
Checks if an InTouch window is open, is closed, or does not exist.
Syntax
result = WindowState (windowname)
Parameters
windowname
Name of the window. A literal string value, message tagname, or string expression.
Return Value
An integer value with the following meaning:
0 - InTouch window exists and is currently closed
1 - InTouch window exists and is currently open
2 - InTouch window does not exist
Example(s)
This script returns 0, if the InTouch window Main exists, but is not open.
WindowState("Main")
Use To
Show Open an InTouch window at the position defined in its location settings.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 94
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Use To
ShowHome Open the InTouch window(s) you specified in the Home Windows tab in
the WindowViewer Properties dialog box and closes any other
windows.
ShowTopLeftAt() Open an InTouch window at a specified position. The opened window
aligns its top left corner to the position. This function can also be used
to move an opened window.
Show() Function
Opens an InTouch window at its default position.
Syntax
Show windowname
Parameters
windowname
The name of the window to be opened. A literal string value, message tagname, or string expression.
Example(s)
This script opens the window Main.
Show "Main";
This script opens the window with the name that is stored in the wname message tag.
Show wname;
ShowAt() Function
Opens an InTouch window at a specified position. It also can move an already open InTouch window to a
specified position. The position is the center point of the window.
Note: The window will not be centered if one of its edges is off-screen.
Syntax
ShowAt (windowname, xpos, ypos)
Parameters
windowname
The name of the window to be opened or moved.
xpos
The horizontal position in pixels that the window center is to be moved to. A literal value, analog tagname,
or numeric expression.
ypos
The vertical position in pixels that the window center is to be moved to. A literal value, analog tagname, or
numeric expression.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 95
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Example(s)
This script opens the window Main so that it is centered at the position x:450, y:130.
ShowAt("Main",450,130);
This script opens the window called UserDialog and positions it, so that its center is over the center position of
the object that called this function (for example a button).
ShowAt("UserDialog",$ObjHor,$ObjVer);
ShowHome() Function
Opens the InTouch window(s) you specified in the Home Windows tab in the WindowViewer Properties dialog
box and closes any other windows.
Syntax
ShowHome;
ShowTopLeftAt() Function
Opens an InTouch window at a specified position. Can also be used to move an open window.
Syntax
ShowTopLeftAt (windowname, xpos, ypos)
Parameters
The name of the window to be opened or moved.
xpos
The horizontal position in pixels that the window left edge is to be moved to. A literal value, analog tagname,
or numeric expression.
ypos
The vertical position in pixels that the window top edge is to be moved to. A literal value, analog tagname, or
numeric expression.
Example(s)
This script opens the window Main so that its top left corner is positioned at x:450, y:130.
ShowTopLeftAt("Main",450,130);
WWMoveWindow() Function
Moves and resizes an opened InTouch window to a specified position and specified size. The new position and
new size apply temporarily while the specified window is open.
Syntax
WWMoveWindow (windowname, xpos, ypos, xsize, ysize)
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 96
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Parameters
windowname
The name of the window to be opened or moved.
xpos
The horizontal position in pixels that the window left edge is to be moved to. A literal value, analog tagname,
or numeric expression.
ypos
The vertical position in pixels that the window top edge is to be moved to. A literal value, analog tagname, or
numeric expression.
xsize
The horizontal size in pixels for the specified window. A literal value, analog tagname, or numeric expression.
ysize
The vertical size in pixels for the specified window. A literal value, analog tagname, or numeric expression.
Use To
Hide() Function
Hides (closes) an InTouch window.
Syntax
Hide windowname;
Parameters
windowname
The name of the window to be hidden. A literal string value, message tagname, or string expression.
Example(s)
This script hides the window called UserConfirmation.
Hide "UserConfirmation";
HideSelf() Function
Hides (closes) the currently active InTouch window.
Note: This function can only be used in an action QuickScript.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 97
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Syntax
HideSelf;
Example(s)
HideSelf;
ChangeWindowColor() Function
Changes the color of an open InTouch window and returns a result code.
Syntax
Result = ChangeWindowColor (windowname, rValue, gValue, bValue)
Parameters
windowname
The name of the window for which the color is to be changed. A literal string value, message tagname, or
string expression.
rValue
The intensity of the red color. A literal integer value, integer tagname, or integer expression in the range of 0
to 255.
gValue
The intensity of the green color. A literal integer value, integer tagname, or integer expression in the range
of 0 to 255.
bValue
The intensity of the blue color. A literal integer value, integer tagname, or integer expression in the range of
0 to 255.
Return Value
A value with the following meaning:
0 - Failure, window is not defined or RGB value is out of range.
1 - Success.
2 - Failure. The window exists, but it is not open.
SetWindowPrinter() Function
At run time, you can set the printer you want to use with the SetWindowPrinter() function.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 98
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Note: The printer set with this function is also the printer that is used with the PrintHT() function.
Syntax
SetWindowPrinter (printername)
Parameters
printername
The name of the printer, either as network share or as printer name as it appears in its property window. A
literal string value, message tagname, or string expression.
Example(s)
In this example, PRTSRV1 is the node name and PRT22SW1 is the share name given to the printer.
SetWindowPrinter("\\PRTSRV1\PRT22SW1");
In this example, Epson LX-300 is the name of the printer as seen in the Properties window of the printer.
SetWindowPrinter("Epson LX-300");
In this example, MyPrinter is a message tag containing the name of an installed windows printer or the path to a
shared network printer.
SetWindowPrinter(MyPrinter);
PrintWindow() Function
In a script, you can print an InTouch window with the PrintWindow() function.
Note: Scripts containing the PrintWindow() function cannot print the following Industrial graphic controls within
an InTouch window: ListBox, DateTimePicker, CalenderControl, EditBox, CheckBox, RadioButtonGroup,
ComboBox, AlarmClient or TrendClient.
Syntax
[result = ] PrintWindow (windowname, leftmargin, topmargin, width, height, options);
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 99
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Parameters
windowname
The name of the window to be printed. A literal string value, message tagname, or string expression.
leftmargin
Left margin offset (in inches). A literal numeric value, analog tagname, or numeric expression.
topmargin
Top margin offset (in inches). A literal numeric value, analog tagname, or numeric expression.
width
Printout width (in inches). Set this value to 0 for largest aspect ratio. A literal numeric value, analog
tagname, or numeric expression.
height
Printout height (in inches). Set this value to 0 for largest aspect ratio. A literal numeric value, analog
tagname, or numeric expression.
options
A discrete value, 0 or 1, that is only used if width and height are 0. A literal Boolean value, discrete tagname
or Boolean expression. Set to:
1 - The window is printed with the largest aspect ratio that is an integer multiple of the window size.
0 - The window is printed with the largest aspect ratio that fits on the page.
Note: If the window contains a bitmap, set options to 1 to prevent the bitmap from being stretched.
Return Value
0 - Printing job is not queued successfully, or window does not exist
1 - Printing job is queued successfully
PrintScreen() Function
You can write a script to print the entire WindowViewer screen with the PrintScreen() function.
Syntax
PrintScreen (ScreenOption, PrintOption)
Parameters
ScreenOption
Determines how much of the WindowViewer screen is to be printed. A literal integer value, integer
tagname, or integer expression.
1 - Print the client area, no menus (default)
2 - Print the entire window area, including menus
PrintOption
Determines how the printed image is to be stretched to fit on the printout.
o 1 - Best Fit:
image is stretched so that it fits either horizontally or vertically on the printout without changing the
aspect ratio. (default)
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 100
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
o 2 - Vertical Fit:
image is stretched so that it fits vertically on the printout without changing the aspect ratio. The image
may be cut off horizontally.
o 3 - Horizontal Fit:
image is stretched so that it fits horizontally on the printout without changing the aspect ratio. The
image may be cut off vertically.
o 4 - Stretch to Page:
image is stretched so that it fits horizontally and vertically on the printout. The aspect ratio may change
but the image is not truncated.
o Invalid options, including 0, default to Best Fit.
Note: Popup windows that extend beyond the WindowViewer screen area are cut off.
Example(s)
This script sends a printout of the current entire WindowViewer screen area without menus to the printer
queue. The printout contains the screen area stretched so that it fills the printout dimensions.
PrintScreen(1,4);
PrintHT() Function
In a script, you can create a button to print the historical trend by linking it to an action QuickScript that
executes the PrintHT QuickScript function.
Use the PrintWindow() function instead of the PrintHT() function when you want to print the entire window
instead of just the trend chart.
Note: Printing the Historical Trend using the Print option or the PrintHT() function will not print the x & y values.
Use PrintWindow() or PrintScreen() to print the x & y values.
Syntax
PrintHT(HistTrendTagname);
Parameter
HistTrendTagname
The history trend tag name for the history trend to be printed.
LaunchTagViewer() Function
You can start Tag Viewer only when WindowViewer is running, and only after Tag Viewer has been enabled in
WindowMaker.
For information about enabling Tag Viewer, see Configuring General WindowViewer Properties in the InTouch®
HMI Application Management and Extension Guide.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 101
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Syntax
LaunchTagViewer()
Remarks
The LaunchTagViewer() function can be executed from any script type except the application scripts OnStartup
and OnShutdown.
If Tag Viewer has not been enabled in WindowMaker, calling the function will not start Tag Viewer and a
warning message will appear in the logger.
You must have adequate security privileges to start Tag Viewer.
Use To
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 102
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Use To
Data Type
Integer (read only)
Example(s)
This script assigns the string "Welcome to xxxx" to the string Welcome where xxxx is the current year.
Welcome = "Welcome to " + StringFromIntg($Year,10)
Example(s)
This script assigns the string "October" to the string MonthName if the current month is 10.
IF $Month==10 THEN
MonthName="October";
ENDIF;
Data Type
Integer (read only)
Example(s)
This script assigns the string "It is a leap year!" to the string Msg2User if the current date is the 29th February.
IF $Day==29 AND $Month==2 THEN
Msg2Usr="It is a leap year!";
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 103
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
ENDIF;
Data Type
Integer (read only)
Example(s)
This script checks if it is 8 PM and the backup has not run yet (expressed by the discrete tag BackupAlreadyRun),
and if so, calls a QuickFunction script called RunBackup() and sets the BackupAlreadyRun flag to TRUE.
IF $Hour==20 AND BackupAlreadyRun==0 THEN
CALL RunBackup();
BackupAlreadyRun=1;
ENDIF;
Data Type
Integer (read only)
Example(s)
This script checks if it is 4:50 PM and if so, shows the window with the name Shift End.
IF $Minute==50 AND $Hour==16 THEN
Show "Shift End";
ENDIF;
Data Type
Integer (read only)
Example(s)
This script generates a sine wave function with an amplitude of 100 and a period of one minute.
100*Sin(6*$Second)
This script generates a series of 0’s and 1’s that change every second.
$second.00
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 104
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Syntax
$Msec
Data Type
Integer (read only)
Data Type
Integer (read only)
Example(s)
This script returns the number of seconds that have passed since midnight.
$Time/1000
Data Type
Integer (read only)
Example(s)
This script returns the current time.
StringFromTime(($Date*86400)+($Time/1000),3);
Data Type
Real (read only)
Example(s)
This script returns the current time.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 105
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
StringFromTime($DateTime*86400,3);
DateTimeGMT() Function
Returns the number of days (including fractions of a day) that have passed since January 01, 1970 in
Coordinated Universal Time (UTC).
Syntax
result = DateTimeGMT();
Return Value
Number of days since January 01, 1970 in UTC. A literal real value.
Example(s)
This script returns the current date/time in UTC.
StringFromTime(DateTimeGMT() * 86400.0, 3);
Use To
Data Type
String (read only)
Example(s)
This script may return 4/28/2006 depending on the short date format setting in the Regional Settings of the
operating system.
$DateString
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 106
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Data Type
String (read only)
Example(s)
This script may return 02:40:37 PM depending on the time format setting in the Regional Settings of the
operating system.
$TimeString
UTCDateTime() Function
Returns the UTC time, the UTC date and time, or the local time zone.
Syntax
result = UTCDateTime (format)
Parameters
format
Determines what content is returned. A literal string value, message tagname, or string expression with the
following possible values:
UTC_SHORT - the function returns the UTC time
UTC_LONG - the function returns the UTC date and time
UTC_LOCAL - the function returns the name of the time zone as set in the time zone settings of the local
operating system
Any other values return the UTC date and time in default format (ddd mm dd hh:mm:ss yyyy).
Example(s)
At 09:24 AM Monday January 6th 2003 in the Pacific time zone, the UTCDateTime() function returns the
following.
This script returns 17:24:05
UTCDateTime("UTC_SHORT")
This script returns 01/06/2003 17:24:05
UTCDateTime("UTC_LONG")
This script returns Pacific Standard Time -8:0: 1
UTCDateTime("UTC_LOCAL")
This script returns Mon Jan 06 17:24:05 2003.
UTCDateTime("Invalid")
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 107
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Use To
StringFromTime() Function
Converts a timestamp given in UTC time to local time and returns the result as a string. This function takes
Daylight Saving Time into account.
Note: This function is equivalent to the StringFromGMTTimeToLocal() function.
Syntax
result = StringFromTime (timestamp, format)
Parameters
timestamp
The number of seconds that have passed since midnight of January 1, 1970 in the UTC time zone. A literal
integer value, integer tagname, or integer expression.
format
Determines how the string result is shown. A literal integer value, integer tagname, or integer expression in
the range from 1 to 5 with following meaning:
1 - Shows the date according to the format set in the Regional Settings of the local operating system
2 - Shows the time according to the format set in the Regional Settings of the local operating system
3 - Shows the date and time as a 24 character string (ddd mmm dd hh:mm:ss yyyy)
4 - Shows the day of the week in short form
5 - Shows the day of the week in long form
Example(s)
This example assumes that the time zone on the local node is Pacific Standard Time (PST, UTC-0800). The UTC
time passed to the function is 12:00:00 AM on Friday, January 2, 1970. Since PST is 8 hours behind UTC, the
function returns the following results.
This script returns "1/1/70"
StringFromTime(86400,1)
This script returns "04:00:00 PM"
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 108
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
StringFromTime(86400,2)
This script returns "Thu Jan 01 16:00:00 1970"
StringFromTime(86400,3)
This script returns "Thu"
StringFromTime(86400,4)
This script returns "Thursday"
StringFromTime(86400,5)
wwStringFromTime() Function
Converts a timestamp given in local time to UTC time and returns the result as a string. This function takes
Daylight Saving Time into account.
Syntax
result = wwStringFromTime (timestamp, format)
Parameters
timestamp
The number of seconds that have passed since midnight of January 1, 1970 in the local time zone. A literal
integer value, integer tagname, or integer expression.
format
Determines how the string result is shown. A literal integer value, integer tagname, or integer expression in
the range from 1 to 5 with following meaning:
1 - Shows the date according to the format set in the Regional Settings of the local operating system
2 - Shows the time according to the format set in the Regional Settings of the local operating system
3 - Shows the date and time as a 24 character string (ddd mmm dd hh:mm:ss yyyy)
4 - Shows the day of the week in short form
5 - Shows the day of the week in long form
Example(s)
This example assumes that the time zone on the local node is Pacific Standard Time (PST, UTC-0800). The local
time passed to the function is 04:00:00 PM on Thursday, January 1, 1970. Since PST is 8 hours behind UTC, the
function returns the following results.
This script returns "1/2/70"
wwStringFromTime(57600,1)
This script returns "12:00:00 AM"
wwStringFromTime(57600,2)
This script returns "Fri Jan 02 00:00:00 1970"
wwStringFromTime(57600,3)
This script returns "Fri"
wwStringFromTime(57600,4)
This script returns "Friday"
wwStringFromTime(57600,5)
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 109
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
StringFromTimeLocal() Function
Converts a timestamp to a time and returns the result as a string.
Syntax
result = StringFromTimeLocal (timestamp, format)
Parameters
timestamp
The number of seconds that have passed since midnight of January 1, 1970. A literal integer value, integer
tagname, or integer expression.
format
Determines how the string result is shown. A literal integer value, integer tagname, or integer expression in
the range from 1 to 5 with following meaning:
1 - Shows the date according to the format set in the Regional Settings of the local operating system
2 - Shows the time according to the format set in the Regional Settings of the local operating system
3 - Shows the date and time as a 24 character string (ddd mmm dd hh:mm:ss yyyy)
4 - Shows the day of the week in short form
5 - Shows the day of the week in long form
Example(s)
This script returns "1/2/70"
StringFromTimeLocal(86400,1)
This script returns "12:00:00 AM"
StringFromTimeLocal(86400,2)
This script returns "Fri Jan 02 00:00:00 1970"
StringFromTimeLocal(86400,3)
This script returns "Fri"
StringFromTimeLocal(86400,4)
This script returns "Friday"
StringFromTimeLocal(86400,5)
wwIsDaylightSaving() Function
Returns whether daylight savings time is currently active.
Syntax
result = wwIsDaylightSaving()
Return Value
A Boolean value with following meaning:
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 110
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Parameters
appname
Path and file name of the application you want to start. A literal string value, message tagname, or string
expression.
Note: You need to know the path and file name of the application. If the application is in a directory that is part
of the Windows PATH environment variable, you only need to pass the file name (without path).
Example(s)
This script starts Microsoft Calculator.
StartApp "calc"
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 111
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
InfoAppTitle() Function
Returns the application title or Windows task list name of a specified application that is running.
Syntax
result = InfoAppTitle (appname)
Parameters
appname
Name of the application without the .exe extension. A literal string value, message tagname, or string
expression.
Example(s)
This script returns "Calculator"
InfoAppTitle("calc")
This script returns "Microsoft Excel"
InfoAppTitle("excel")
InfoAppActive() Function
Returns the running status of an application.
Syntax
result = InfoAppActive (apptitle)
Parameters
apptitle
The application title or Windows task list of the application for which you want to query the running status.
A literal string value, message tagname, or string expression.
Return Value
A Boolean value indicating:
0 - The application is not running
1 - The application is running
Example(s)
This script queries for the application Notepad, and if it is already running, activates it. Otherwise it launches a
new instance of Notepad. This way launching Notepad multiple times is avoided.
IF InfoAppActive(InfoAppTitle("Notepad"))==1
THEN
ActivateApp InfoAppTitle( "Notepad" );
ELSE
StartApp "Notepad";
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 112
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
ENDIF;
ActivateApp Function
Activates an already running Windows application.
Important: The ActivateApp() function does not work on 64-bit versions of the Windows operating system.
Syntax
ActivateApp apptitle;
Parameters
apptitle
The application title or Windows task list name of the running application you want to activate.
Example(s)
This script checks if a command prompt window is already open, and if so, activates it. Otherwise it starts the
command prompt window.
IF InfoAppActive( InfoAppTitle("cmd")) == 1 THEN
ActivateApp InfoAppTitle("cmd");
ELSE
StartApp "cmd";
ENDIF;
SendKeys Function
Simulates a sequence of key strokes.
Important: The SendKeys() function does not work on 64-bit versions of the Windows operating system.
Syntax
SendKeys sequence;
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 113
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Parameters
sequence
The sequence of keys strokes to be simulated. A literal string value, message tagname, or string expression.
In addition to regular characters on the keyboard (such as alphanumeric characters) you can also specify
control keys as a code:
{BACKSPACE} - Simulates the Backspace key
{BREAK} - Simulates the Break key
{CAPSLOCK} - Simulates the Caps Lock key
{DELETE} - Simulates the Delete key (or {DEL})
{DOWN} - Simulates Arrow Down key
{END} - Simulates the End key
{ENTER} - Simulates the Enter key (or ~)
{ESCAPE} - Simulates the ESC key (or {ESC})
{F1} .. {F12} - Simulate the F1 .. F12 keys
{HOME} - Simulates the Home key
{INSERT} - Simulates the Insert key
{LEFT} - Simulates the Arrow Left key
{NUMLOCK} - Simulates the Num Lock key
{PGDN} - Simulates the Page Down Key
{PGUP} - Simulates the Page Up key
{PRTSC} - Simulates the Print Screen key
{RIGHT} - Simulates the Arrow Right key
{TAB} - Simulates the Tab key
{UP} - Simulates the Up key
+ - Simulates the Shift key
use with parenthesis surrounding the key(s) you want to press in combination with the Shift
key.
^ - Simulates the Ctrl key
use with parenthesis surrounding the key(s) you want to press in combination with the Ctrl
key.
% - Simulates the Alt key
use with parenthesis surrounding the key(s) you want to press in combination with the Alt
key.
Remarks
Use the StartApp and/or ActivateApp() commands to activate another application before sending simulated keys
strokes to it.
Example(s)
This script simulates pressing the B key.
SendKeys "b";
This script simulates pressing the key combination Ctrl and P, which can be used to initiate the Printing dialog
box in another application.
SendKeys "^(p)";
This script simulates pressing F1 (which may open the help function), pressing the Tab key (which may place the
cursor in a search field), entering HAL, and pressing the Enter key (which may initiate the search).
SendKeys "{F1}{TAB}HAL{ENTER}";
This script simulates pressing Ctrl, Shift and the key 1, which is the same as switching to WindowMaker. This
powerful combination can be used for developing self-modifying (dynamic) InTouch HMI applications.
SendKeys "^(+(1))";
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 114
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
WWControl() Function
Restores, minimizes, maximizes, or closes a Windows application.
Syntax
WWControl (apptitle, control);
Parameters
apptitle
The application title or Windows task list name of the running application you want to restore, minimize,
maximize or close. A literal string value, message tagname, or string expression.
control
Determines the action you want to take on the specified Windows application. A literal string value, message
tagname, or string expression with following values:
Restore - activates and shows the application window
Minimize - activates and minimizes the application window
Maximize - activates and maximizes the application window
Close - closes the application
Remarks
To use this function in Windows Server 2003, you must be a member of the Administrators group, the
Performance Log Users group, or the Performance Monitor Users group on the local computer or you must have
been delegated the appropriate authority to write to the registry.
Example(s)
This script restores the calculator application if it is already running.
WWControl ("Calculator","Restore");
This script closes the WindowViewer.
WWControl (InfoAppTitle("View"),"Close");
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 115
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Use To
WWExecute() Function
Sends a command to an application, executes it, and returns a status result. You can use it to have Excel to run a
macro.
Important: The WWExecute() function does not work on 64-bit versions of the Windows operating system.
Syntax
Result = WWExecute (appname, topic, command)
Parameters
appname
The name of the application the command is sent to. A literal string value, message tagname, or string
expression.
topic
The name of the topic within the application that the command is sent to. A literal string value, message
tagname, or string expression.
command
The command to be sent. A literal string value, message tagname, or string expression.
Return Value
A value of-1, 0, or 1 indicating the following:
-1 - command not executed successfully. Possible causes are the application not running, the topic does not
exist or the command contains an error.
0 - command not executed successfully because the application is busy.
1 - command executed successfully.
Example(s)
This script instructs Microsoft Excel to execute the macro Macro1 by sending the command [Run("Macro1",0)]
to Excel.
Macro="Macro1";
Command="[Run(" + StringChar(34) + Macro + StringChar(34) + ",0)]";
WWExecute("excel","system",Command);
WWRequest() Function
Reads data from an item of an application. You can use it, for example, to read the value of a spreadsheet cell in
Microsoft Excel.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 116
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Important: The WWRequest() function does not work on 64-bit versions of the Windows operating system.
Syntax
Result = WWRequest(appname, topic, item, messagetag)
Parameters
appname
The name of the application. A literal string value, message tagname, or string expression.
topic
The name of the topic within the application. A literal string value, message tagname, or string expression.
item
The name of the item belonging to the topic and application. A literal string value, message tagname, or
string expression.
messagetag
A message tagname to retrieve the value of the item. The message tagname value can be converted into an
integer or real value by using the StringToIntg() or StringToReal() functions.
Return Value
A value of -1, 0, or 1 indicating the following:
-1 - data not read successfully. Possible causes are the application not running or the topic or item do not
exist.
0 - data not read successfully because the application is busy.
1 - data read successfully.
Example(s)
This script reads the value contained in Microsoft Excel book Book1.xls, sheet Sheet1 in Row 1, Column 1 to the
message tagname MTag and puts the value in the real tagname CellValue.
Result = WWRequest("excel","[Book1.xls]sheet1", "r1c1",Mtag);
CellValue=StringToReal(MTag);
If you are using a non-English operating system, you may need to use the StringReplace() function to change the
contents of MTag before converting it to a different data type. For example, for operating systems that use a
comma as a decimal separator, you may need to replace all commas with decimal dots in MTag before
converting it to a real data type.
WWPoke() Function
Writes data to an item of an application. You can use it, for example, to write the value into a spreadsheet cell in
Excel.
Important: The WWPoke() function does not work on 64-bit versions of the Windows operating system.
Syntax
result = WWPoke (appname, topic, item, string)
Parameters
appname
The name of the application. A literal string value, message tagname, or string expression.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 117
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
topic
The name of the topic within the application. A literal string value, message tagname, or string expression.
item
The item name belonging to the topic and application. A literal string value, message tagname, or string
expression.
string
The value to be written. A literal string value, message tagname, or string expression. You can use the
StringFromIntg(), StringFromReal() or Text() functions to convert the value of an integer or real tagname to a
message tagname.
Return Value
A value of-1, 0, or 1 indicating the following:
-1 - data not written successfully. Possible causes are the application not running or the topic or item do not
exist.
0 - data not written successfully because the application is busy.
1 - data written successfully.
Remarks
Do not use the WWPoke() or WWRequest() function to read and write data between InTouch applications on
different nodes or sessions. To read and write data between InTouch applications, use Access Names instead.
See Setting Up Access Namesin the InTouch® HMI Data Management Guide.
Example(s)
This script puts the value of the real tagname CellValue in the message tagname Mtag and writes the value to
the spreadsheet cell Row 1, Column 1 of sheet Sheet1 in Microsoft Excel book Book1.xls.
MTag = Text(CellValue,"0");
Result = WWPoke("excel","[Book1.xls]sheet1", "r1c1",Mtag);
Use To
Managing Files
In a script, you can copy, delete or move files.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 118
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
FileCopy() Function
Copies a source file to a destination file and returns a status result. This function may take a longer time to
execute and is executed in multiple stages:
1. FileCopy() function is called and an immediate result is returned, indicating success or failure of the file copy
initialization.
2. FileCopy() function executes the copy procedure in the background, and InTouch scripting continues
execution while the file copying is in progress. You can monitor the file copying progress with an integer tag.
3. FileCopy() function returns a file copy result, indicating success or failure of the file copy procedure.
If the destination folder is not available (i.e. another computer on the network), the function waits for up to 10
seconds to time out, and then posts a message in the Logger.
Syntax
result = FileCopy (sourcefile, destfile, progresstag)
Parameters
sourcefile
Full path and file name of the file to be copied. A literal string value, message tagname, or string expression.
You can use the wildcard characters (* and ?) in this parameter to copy just files matching a specified
criteria. The path name can also be a UNC path name.
destfile
Full path and file name (or just path name) of the destination. A literal string value, message tagname, or
string expression. The path name can also be a UNC path.
progresstag
Name of an integer tag enclosed in double quotes that will contain a value indicating the file copy progress.
A literal string value, message tagname (such as a message tag containing the value "IntTag.Name") or string
expression. The values have following meaning:
0 - FileCopy() procedure is still in progress.
1 - FileCopy() procedure has completed successfully.
-1 - FileCopy() procedure completed with errors.
Return Value
A value of -1, 0, or 1 indicating the following:
1 - FileCopy() function successfully called.
0 - Error when calling the FileCopy() function because another FileCopy() procedure is already in progress.
-1 - Error when calling the FileCopy() function because of a non-existent source file or the destination is read
only.
Example(s)
This script copies the file c:\MyData\output.log to the directory d:\archive and renames the file to output.txt.
The progress of the file copy is written to the integer tag Monitor.
Status=FileCopy("c:\MyData\output.log","d:\archive\output.txt","Monitor");
This script copies all files with file ending .txt in the c:\ root directory to the destination directory c:\Backup.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 119
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
FileDelete() Function
Deletes an individual file.
Syntax
result = FileDelete (filename)
Parameters
filename
The path name and file name of the file to delete. A literal string value, message tagname, or string
expression. UNC path names are supported.
Remarks
Do not use the wildcard characters (* and ?) with the FileDelete() function and do not use the FileDelete()
function in asynchronous QuickFunctions.
The FileDelete() function does not delete directories.
Return Value
A value indicating success or failure of the file deletion:
1 - file is deleted successfully
0 - file is not deleted successfully. Possible causes are attempts to delete a read only or a non-existent file.
Example(s)
This script deletes the file c:\Data.txt and returns 1 if the file was found and deleted successfully.
Status=FileDelete("c:\Data.txt");
FileMove() Function
Moves a source file to a destination file and returns a status result. It can be also used to rename a file. This
function may take a longer time to execute and executes in multiple stages:
1. FileMove() function is called and an immediate result is returned, indicating success or failure of the file
move initialization.
2. FileMove() function executes the move procedure in the background, InTouch scripting continues execution
while the file moving is in progress. You can monitor the file moving progress with an integer tag.
3. FileMove() function returns a file move result, indicating success or failure of the file moving procedure.
Do not use the FileMove() function in asynchronous QuickFunctions.
Syntax
result = FileMove (sourcefile, destfile, progresstag)
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 120
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Parameters
sourcefile
Full path and file name of the file to be moved. A literal string value, message tagname, or string expression.
You can use the wildcard characters (* and ?) in this parameter to move just files matching a specified
criteria. The path name can also be a UNC path name.
destfile
Full path and file name (or just path name) of the destination. A literal string value, message tagname, or
string expression. The path name can also be a UNC path.
progresstag
Name of an integer tag enclosed in double quotes that will contain a value indicating the file moving
progress. A literal string value, message tagname (such as a message tag containing the value "IntTag") or
string expression. The values have following meaning:
0 - FileMove() procedure is still in progress
1 - FileMove() procedure has completed successfully
-1 - FileMove() procedure completed with errors
Return Value
A value of-1, 0, or 1 indicating the following:
1 - FileMove() function successfully called
0 - Error when calling the FileMove() function because another FileMove() procedure is already in progress
-1 - Error when calling the FileMove() function. Possible errors are attempts to move a non-existent file.
Example(s)
This script moves the file c:\MyData\output.log to the directory d:\archive and renames the file to output.txt.
The progress of the file moving is written to the integer tag Monitor.
Status=FileMove("c:\MyData\output.log","d:\archive\output.txt","Monitor");
This script moves all files with file ending .txt in the c:\ root directory to the destination directory c:\Backup.
Status=FileMove("c:\*.txt", "c:\Backup", "Monitor");
This script moves a file whose full path and file name is contained in the message tag LogFile to the destination
directory c:\results\ and renames it to logxxx.txt where xxx is a timestamp.
Status=FileMove(LogFile, "c:\results\log" + $DateString + $TimeString + ".txt", "Monitor");
FileReadFields() Function
Reads the values contained in a csv file into a series of tagnames. You can use this function to load a set of
tagname values.
Commas are the only supported delimiter.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 121
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Parameters
filename
Name of the csv file to read the data from. A literal string value, a message tagname or a string expression.
offset
Location (in bytes) in the file to start reading. A literal integer value, integer tagname, or integer expression.
starttag
Name of the first tagname that receives the first read data item. The tagname must be enclosed with double
quotes and end in a number, such as "MyTag1". A literal string value, message tagname (such as a message
tagname containing the value "MyTag1"), or a string expression.
numberoffields
Number of data items to read from the csv file. A literal integer value, integer tagname, or integer
expression. The first data item is read into the tagname defined in the starttag parameter, subsequent data
items into tagnames with the incremented numeral suffix of the starttag parameter (MyTag1, MyTag2,
MyTag3, ...).
Return Value
Optional new file offset (in byte) after reading the data. This can be used to read the next set of data.
Example(s)
This script reads the values "Flour" to RecipeTag1, 27.23 to RecipeTag2, 14 to RecipeTag3, and 1 to RecipeTag4,
and returns the new file offset—if the csv file c:\set.csv contains the following data: Flour, 27.23,14,1 and if the
following tags are defined: RecipeTag1:message, RecipeTag2:real, Recipe3:integer, RecipeTag4:discrete.
FileReadFields("c:\set.csv",0,"RecipeTag1",4);
FileWriteFields() Function
Writes the values contained in a series of tagnames to a csv file. You can use this function to save a set of
tagname values.
Commas are the only supported delimiter.
Syntax
[result = ] FileWriteFields (filename, offset, starttag, numberoffields)
Parameters
filename
Name of the csv file to write the data to. A new file is created if it does not previously exist. A literal string
value, a message tagname, or a string expression.
offset
Location (in bytes) in the file to start writing to. Use -1 to write to the end of the file (append). A literal
integer value, integer tagname, or integer expression.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 122
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
starttag
Name of the first tagname that contains the first data item to be written. The tagname must be enclosed
with double quotes and end in a number, such as "MyTag1". A literal string value, message tagname (such as
a message tagname containing the value "MyTag1") or a string expression.
numberoffields
Number of data items to write to the csv file. A literal integer value, integer tagname, or integer expression.
The first data item is written from the tagname defined in the starttag parameter to the file, subsequent
data items from tagnames with the incremented numeral suffix of the starttag parameter (MyTag1, MyTag2,
MyTag3, ...).
Return Value
Optional new file offset (in byte) after writing the data. This can be used to write the next set of data.
Example(s)
A series of InTouch tags is defined as follows:
This script writes the values contained in RecipeTag1 to RecipeTag4 to the csv file c:\set.csv.
FileWriteFields("c:\set.csv",0,"RecipeTag1",4);
So that the file c:\set.csv will contain the following data:
Flour,27.23,14,1
FileReadMessage() Function
Reads a specified number of bytes (or one line) of string data from a file.
Syntax
[result = ] FileReadMessage (filename, offset, messagetag, charstoread)
Parameters
filename
Name of the file to read the data from. A literal string value, a message tagname, or a string expression.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 123
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
offset
Location (in bytes) in the file to start reading from. A literal integer value, integer tagname, or integer
expression.
messagetag
Message tagname that receives the first line or number of bytes from the file. Enclose the tagname with
double quotes when using the function within the Industrial Graphics Editor Script Editor.
charstoread
Number of bytes to read from the file. Set it to 0 to read until the next line feed (LF) character. A literal
integer value, integer tagname, or integer expression.
Return Value
Contains the new byte position after the read. You can use this for subsequent reads from the file.
Example(s)
This script reads the first line of data in the file c:\Data\File.txt to the message tagname MsgTag.
FileReadMessage ("c:\Data\File.txt",0,MsgTag, 0);
FileReadMessage ("c:\Data\File.txt",0,"InTouch:MsgTag", 0);
FileWriteMessage() Function
Writes a specified number of bytes (or one line) of string data to a file.
Syntax
[result = ] FileWriteMessage (filename, offset, messagetag, linefeed)
Parameters
filename
Name of the file to write the data to. A literal string value, a message tagname, or a string expression.
offset
Location (in bytes) in the file to start writing to. Set it to -1 to write data to the end of the file (append). A
literal integer value, integer tagname, or integer expression.
messagetag
Message tagname that contains the data to be written to the file.
linefeed
Specifies whether to write a line feed (LF) character after writing the data to the file. Set to 1 to write a line
feed character; otherwise, set it to 0. A literal Boolean value, discrete tagname, or Boolean expression.
Return Value
Contains the new byte position after the write. You can use this for subsequent writes to the file.
Example(s)
This script writes the value of a message tagname MsgTag to the end of the file c:\Data\File.txt.
FileWriteMessage("c:\Data\File.txt",-1,MsgTag,1);
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 124
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Use To
GetNodeName() Function
Returns the node name of the computer.
Syntax
GetNodeName (messagetag, nodenum);
Parameters
messagetag
Message tagname that will contain the node name. Enclose the tagname with double quotes when using the
function within the Industrial Graphics Editor Script Editor.
nodenum
Number of characters to retrieve from the node name. A literal integer value, integer tagname, or integer
expression in the range of 0 to 131.
Example(s)
This script retrieves the node name and assigns it to the NodeName message tagname.
GetNodeName(NodeName,131);
GetNodeName("InTouch:NodeName",131);
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 125
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
InfoDisk() Function
Returns either the total or free space on a local or network disk drive.
Syntax
result = InfoDisk (drive, infotype, trigger);
Parameters
drive
The drive letter for which you want to retrieve information. Only the first character of a string is used. A
literal string value, message tagname, string expression.
infotype
Specifies the information type. A literal integer value, integer tagname, or integer expression with following
possible values:
1 - function returns total size of disk drive (in bytes)
2 - function returns free space of disk drive (in bytes)
3 - function returns total size of disk drive (in kilobytes)
4 - function returns free space of disk drive (in kilobytes)
trigger
A tagname (or expression) that acts as a trigger to recalculate the disk information. If the trigger value
changes the disk information is recalculated. A discrete or analog taname, or a discrete or analog expression.
Remarks
The trigger tag only has meaning when the InfoDisk() function is used in an animation display link. If this function
is used in a script, you can specify any literal numeric value, analog tagname, or numeric expression.
Example(s)
Use this script in an animation display link to show the free space of disk drive C and update the information
every minute.
InfoDisk("C", 4, $Minute)
InfoFile() Function
Returns various information on a file or directory.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 126
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Syntax
result = InfoFile (filename, infotype, trigger)
Parameters
filename
The full file name or directory name you want to retrieve information about. A literal string value, message
tagname, or string expression. Can also include wildcard characters, such as "*" and "?".
infotype
The type of information you want to retrieve about the specified file or directory. A literal integer value,
integer tagname, or integer expression with following values and meaning:
1 - Existence. The InfoFile() function returns 1 if the file exists, 2 if the file is a directory and 0 if the file or
directory does not exist.
2 - Size. The InfoFile() function returns the file size in bytes.
3 - Creation timestamp. The InfoFile() function returns the time stamp as seconds that have passed since
midnight January 1, 1970. Use the StringFromTimeLocal() function to convert this value to a message
timestamp.
4 - Wildcard Search Match. The InfoFile() function returns the number of files that match a specified
wildcard search.
trigger
A tagname (or expression) that acts as a trigger to recalculate the file information. If the trigger value
changes, the file information is recalculated. A discrete or analog taname, or a discrete or analog expression.
Remarks
The trigger tag only has meaning when the InfoFile() function is used in an animation display link. If this function
is used in a script, you can specify any literal numeric value, analog tagname, or numeric expression.
Example(s)
This script returns 1 if the file c:\data\log.txt exists.
InfoFile("c:\data\log.txt",1,$minute)
This script returns 14223 if the file c:\data\log.txt has a file size of 14223 bytes.
InfoFile("c:\data\log.txt",2,$minute)
This script returns 1138245266 if the file c:\data\log.txt was created on January 26, 2006 at 11:14:26 AM.
InfoFile("c:\data\log.txt",3,$minute)
This script returns 14 if there are 14 files in the directory c:\data\ that have a txt ending.
InfoFile("c:\data\*.txt",4,$minute)
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 127
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Use To
InfoInTouchAppDir() Function
Returns the current InTouch application directory.
Syntax
result = InfoInTouchAppDir();
Return Value
A message tagname to contain the directory of the currently running InTouch application.
Remarks
The application directory name may be truncated when passed to a message tagname or shown in an animation
link due to the 131 characters limitation.
Example(s)
This script may return c:\documents and settings\user1\my documents\my intouch applications\packaging.
InfoInTouchAppDir()
InTouchVersion() Function
Returns the complete InTouch version number or just parts of it.
Syntax
result = InTouchVersion (infotype);
Parameters
infotype
Specifies how the version information is returned. A literal integer value, integer tagname, or integer
expression with the following meaning:
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 128
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
InTouchVersion(0) 10.5.1626.0521.0045.0012
InTouchVersion(1) 10
InTouchVersion(2) 5
InTouchVersion(3) 0
InTouchVersion(4) 1626
Security-Related Scripting
You can add and manage security within your InTouch application with various QuickScript functions and system
tags. For more information about security functions, see Securing InTouchin the InTouch® HMI Application
Management and Extension Guide.
Use To
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 129
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Use To
For more information about security functions, see Securing InTouchin the InTouch® HMI Application
Management and Extension Guide.
Use To
For more information about security functions, see Securing InTouchin the InTouch® HMI Application
Management and Extension Guide.
Use To
For more information about security functions, see Securing InTouchin the InTouch® HMI Application
Management and Extension Guide.
Use To
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 130
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Use To
For more information about security functions, see Securing InTouchin the InTouch® HMI Application
Management and Extension Guide.
Miscellaneous Scripting
InTouch scripting supports sound output so that you can associate human machine interaction with sounds.
InTouch scripting also supports getting and setting properties of Wizards.
PlaySound() Function
Plays a sound from a wave file or a Windows default sound.
Syntax
Playsound (soundname, flag)
Parameters
soundname
The name of the sound or wave file. A literal string value, message tagname, or string expression. If the
sound is defined as a name, it must be defined in the Win.ini file under the [Sounds] section, for example
MC="c:\test.wav"
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 131
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
flag
Specifies how the sound is played. A literal integer value, integer tagname, or integer expression with the
following meanings:
0 - Play sound one time synchronously (script execution waits until sound has finished playing).
1 - Play sound one time asynchronously (script execution does not wait until sound has finished playing).
9 - Play sound continuously (until the PlaySound() function is called again).
Example(s)
This script plays the sound of the file c:\welcome.wav one time and holds script execution until it has finished
playing.
PlaySound("c:\welcome.wav",0);
This script plays the sound Alert continuously. In the win.ini file [Sounds] section you need to associate the
sound name Alert with a sound file, such as:
Alert=c:\alert.wav.
PlaySound("Alert",9);
Use To
GetPropertyD() Function
Reads a discrete property in a wizard and returns a success code.
Syntax
result = GetPropertyD (controlname.property, dtag)
Parameters
controlname
The name of a wizard that supports properties. A literal string value, message tagname, or string expression.
property
The discrete property of the wizard that is to be read. Together with controlname can be a literal string
value, message tagname, or string expression.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 132
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
dtag
The discrete tagname that will receive the discrete property value.
Return Value
An integer error code. For more information about the error codes, see Understanding Windows Controls Error
Messagesin the InTouch® HMI Visualization Guide.
Example(s)
With a check box wizard Checkbox1 and a discrete tagname dtag you can check the visibility of the check box
with the following script function:
result=GetPropertyD("Checkbox1.visible",dtag);
This script sets dtag to 1, if the check box wizard is visible; otherwise, it sets dtag to 0.
SetPropertyD() Function
Sets a discrete property in a wizard and returns a success code.
Syntax
result = SetPropertyD(controlname.property, Boolean)
Parameters
controlname
The name of a wizard that supports properties. A literal string value, message tagname, or string expression.
property
The discrete property of the wizard that is to be set. Together with controlname can be a literal string value,
message tagname, or string expression.
Boolean
The Boolean value to pass to the wizard property. A literal Boolean value, discrete tagname or Boolean
expression.
Return Value
An integer error code. For more information about the error codes, see Understanding Windows Controls Error
Messages in the InTouch® HMI Visualization Guide.
Example(s)
With a check box wizard Checkbox1 and a discrete tagname dtag you can control the visibility of the check box
with the following script function:
result=SetPropertyD("Checkbox1.visible",dtag);
If you set dtag to 0 and call the script function above, the check box wizard becomes invisible.
GetPropertyI() Function
Reads an integer in a wizard and returns a success code.
Syntax
result = GetPropertyI (controlname.property, itag)
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 133
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Parameters
controlname
The name of a wizard that supports properties. A literal string value, message tagname, or string expression.
property
The integer property of the wizard that is to be read. Together with controlname can be a literal string value,
message tagname, or string expression.
itag
The integer tagname that will receive the integer property value.
Return Value
An integer error code. For more information about the error codes, see Understanding Windows Controls Error
Messages in the InTouch® HMI Visualization Guide.
Example(s)
With a radio button wizard Radiobutton1 and an integer tagname itag you can check the currently selected item
in the radio button group with the following script function:
result=GetPropertyI("Radiobutton1.value",itag);
This script sets itag to 1 (2, 3, ...) , if the first (second, third, ...) radio button is selected.
SetPropertyI() Function
Sets an integer property in a wizard and returns a success code.
Syntax
result = SetPropertyI (controlname.property, integer)
Parameters
controlname
The name of a wizard that supports properties. A literal string value, message tagname, or string expression.
property
The integer property of the wizard that is to be set. Together with controlname can be a literal string value,
message tagname, or string expression.
integer
The integer value to pass to the wizard property. A literal integer value, integer tagname, or integer
expression.
Return Value
An integer error code. For more information about the error codes, see Understanding Windows Controls Error
Messages in the InTouch® HMI Visualization Guide.
Example(s)
With a radio button wizard Radiobutton1 you can set the 2nd radio button with the following script function:
result=SetPropertyI("Radiobutton1.value",2);
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 134
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
GetPropertyM() Function
Reads a message property in a wizard and returns a success code.
Syntax
result = GetPropertyM (controlname.property, mtag)
Parameters
controlname
The name of a wizard that supports properties. A literal string value, message tagname, or string expression.
property
The message property of the wizard that is to be read. Together with controlname can be a literal string
value, message tagname, or string expression.
mtag
The message tagname that will receive the message property value.
Return Value
An integer error code. For more information about the error codes, see Understanding Windows Controls Error
Messages in the InTouch® HMI Visualization Guide.
Example(s)
With a check box wizard Checkbox1 and a message tagname mtag you can check the caption of the check box
with the following script function:
result=GetPropertyM("Checkbox1.caption",mtag);
This script sets mtag to the caption of the check box.
SetPropertyM() Function
Sets a message property in a wizard and returns a success code.
Syntax
result = SetPropertyM (controlname.property, message)
Parameters
controlname
The name of a wizard that supports properties. A literal string value, message tagname, or string expression.
property
The message property of the wizard that is to be set. Together with controlname can be a literal string value,
message tagname, or string expression.
message
The message value to pass to the wizard property. A literal string value, message tagname, or string
expression.
Return Value
An integer error code. For more information about the error codes, see Understanding Windows Controls Error
Messages in the InTouch® HMI Visualization Guide.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 135
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 6 – Built-In Functions
Example(s)
With a check box wizard Checkbox1 you can set the caption of the check box wizard dynamically with the
following script function:
result=SetPropertyM("Checkbox1.caption","Start Engine 1");
This script sets the caption of the check box Checkbox1 to "Start Engine 1".
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 136
Chapter 7
OLE_CreateObject() Function
Before you can reference an OLE object in a script, you must create it. When you do this you receive a pointer
that references the OLE object.
In a script, you can create an OLE object and assign a pointer by using the OLE_CreateObject() function.
Syntax
OLE_CreateObject(%pointer, classname);
Parameters
%pointer
The name of your choice for the pointer to the OLE object. It can contain alphanumeric characters (A-Z, 0-9)
and underscore. It is case-insensitive.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 137
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 7 – Scripting with OLE Objects
classname
The name of the OLE class. The class name is case-sensitive. A literal string value, message tagname, or
string expression.
Remarks
If you use the same object name to create another object, the object is updated to reference the new OLE class.
It is released from the old OLE class.
Example(s)
This script creates an OLE object called %WShell that references the class Wscript.Shell.
OLE_CreateObject(%WShell, "Wscript.Shell");
OLE_IsObjectValid() Function
In a script, you can verify that an OLE object is valid by using the OLE_IsObjectValid() function. This is not a
required step for working with OLE objects, but it is recommended to make sure that you do not come across
problems when working with OLE objects.
Syntax
result = OLE_IsObjectValid(%pointer)
Arguments
%pointer
The pointer referencing an OLE object that is to be tested.
result
A Boolean value indicating the following:
0 - The OLE object the pointer is referencing is invalid.
1 - The OLE object the pointer is referencing is valid.
Example(s)
This script creates an OLE object based on the Wscript.Shell class and creates a pointer %WS to reference it.
isvalid is a discrete tag that is TRUE if the OLE object is created successfully. Otherwise it is FALSE.
OLE_CreateObject(%WS, "Wscript.Shell");
isvalid = OLE_IsObjectValid(%WS);
OLE_ReleaseObject() Function
After you have used an OLE object in a script, you can release it and delete its pointer to free up system
resources. After you release an OLE object you cannot use its pointer to access properties and methods of the
associated OLE class.
Syntax
OLE_ReleaseObject(%pointer);
Arguments
%pointer
Name of the pointer that references the OLE Object. It can contain alphanumeric characters (A-Z, 0-9) and
underscore. It is case-insensitive.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 138
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 7 – Scripting with OLE Objects
Example(s)
This script releases the OLE object associated with the pointer %WShell and deletes the pointer %WShell.
OLE_ReleaseObject(%WShell);
Arguments
%pointer
The pointer that references the OLE object. Must be created with OLE_CreateObject() function or assigned
to another pointer before reading a property.
property
The name of the property to be read.
tagname
The tag to write the value to.
Example(s)
This script creates an OLE object based on the System.Random OLE class, creates a pointer %SR to reference it,
and assigns the value of the .NextDouble property of the Math.Random OLE object to a real tagname randtag.
At run time the real tagname Randtag receives a random double float value between 0 and 1.
OLE_CreateObject(%SR,"System.Random");
randtag = %SR.NextDouble;
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 139
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 7 – Scripting with OLE Objects
Arguments
%pointer
The pointer that references the OLE object. Must be created with OLE_CreateObject() function or assigned
to another pointer before writing to a property.
property
The name of the property to be written to.
value
The value to be written to the property. It can be a literal value, tagname or expression. Writing to an OLE
property from an animation input link directly is not supported.
Arguments
%pointer
The pointer that references the OLE object. Must be created with OLE_CreateObject() function or assigned
to another pointer before calling a method.
method
The name of the method that is part of the OLE object.
parameters
A list of parameters to pass to the method. These parameters must be separated by comma. Literal values,
tagnames or expressions.
Example(s)
This script creates an OLE object based on the OLE class Shell.Application, creates a pointer %sa to the OLE
object and calls the method .MinimizeAll(). This method minimizes all windows on your desktop.
OLE_CreateObject(%SA,"Shell.Application");
%SA.MinimizeAll();
Note: Optional parameters are not allowed in OLE InTouch HMI scripting. All parameters must be specified.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 140
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 7 – Scripting with OLE Objects
%newpointer
The name of a new pointer that should reference the same OLE object. It can contain alphanumeric
characters (A-Z, 0-9) and underscore. It is case-insensitive.
Example(s)
This script creates an OLE object based on the Wscript.Shell class and creates a pointer %WS to reference it. The
pointer %WS2 when set to %WS points to the same OLE object. It can be used to read from or write to
properties and call methods of the same OLE object.
OLE_CreateObject(%WS,"Wscript.Shell");
%WS2=%WS;
Note: You can use message tagnames in connection with pointers. If you assign a message tagname to a pointer,
it can get an ID value. You can use it to create more pointers to the same OLE object.
Function Description
OLE_GetLastObjectError() Function
This function returns the error number of the last OLE error.
Syntax
errnum = OLE_GetLastObjectError();
Arguments
errnum
The number of the last OLE error.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 141
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 7 – Scripting with OLE Objects
OLE_GetLastObjectErrorMessage() Function
This function returns the error message of the last OLE error.
Syntax
errmsg = OLE_GetLastObjectErrorMessage();
Arguments
errmsg
The error message of the last OLE error.
OLE_ResetObjectError() Function
In a script, use the OLE_ResetObjectError() function to reset the last OLE error so that the last OLE error number
is set to zero and last OLE error message is set to blank.
This can be used for identifying any errors in a batch of OLE functions.
Syntax
OLE_ResetObjectError()
OLE_ShowMessageOnObjectError() Function
By default, when an OLE error occurs, an error message dialog box is displayed.
In a script, you can specify whether or not to display the error message dialog box by using the function
OLE_ShowMessageOnObjectError().
Syntax
OLE_ShowMessageOnObjectError(Boolean)
Arguments
Boolean
A value that determines if an OLE error message dialog box is displayed or not. A literal Boolean value,
discrete tagname or Boolean expression with following meanings:
0 - no OLE error message dialog box is displayed when an OLE error occurs
1 - an OLE error message dialog box is displayed when an OLE error occurs
Example(s)
This script suppresses all OLE error message dialog boxes. When OLE errors occur, no error message dialog
boxes are displayed.
OLE_ShowMessageOnObjectError(0);
OLE_IncrementOnObjectError() Function
In a script, you can use the OLE_IncrementOnObjectError() function to designate an integer tagname as counter
for the number of OLE errors.
Syntax
OLE_IncrementOnObjectError(integertag)
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 142
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 7 – Scripting with OLE Objects
Parameters
integertag
The tagname that acts as a counter.
Remarks
If OLE error message dialog boxes are displayed, the counter tagname is only incremented after the OLE error
message dialog box is closed.
Example(s)
This script designates the integer tagname errorcount as error counter, hides the error message dialog boxes
and attempts to create an OLE object based on an invalid OLE class name. This creates an error and the tagname
value errorcount is incremented to 1.
errorcount = 0;
OLE_IncrementOnObjectError(errorcount);
OLE_ShowMessageOnObjectError(0);
OLE_CreateObject(%WS,"InVaLiD.cLaSs.nAmE");
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 143
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 7 – Scripting with OLE Objects
The Style tagname determines which icon and which buttons appear on the dialog box. Use the following values:
Warning icon 48
Information icon 64
To use a particular button, add one of the following values to the Style value:
Value Style
0 Only OK button
1 OK and Cancel buttons
2 Abort, Retry and Ignore buttons
3 Yes, No and Cancel buttons
4 Yes and No buttons
5 Retry and Cancel buttons
6 Cancel, Try Again and Continue buttons
The Result tagname contains the button number the user clicked. This can be used for conditional branching in
your InTouch script. Following result codes are possible:
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 144
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 7 – Scripting with OLE Objects
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 145
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 7 – Scripting with OLE Objects
Minimize Windows
In a script, you can use the following commands to minimize all windows on your desktop:
OLE_CreateObject(%WA,"Shell.Application");
%WA.MinimizeAll();
You can do similar tasks by calling these methods:
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 146
Chapter 8
You can use ActiveX controls to read from and write to tagnames and I/O references. In a script, you can
reference ActiveX controls.
You can also create scripts that execute when an event occurs for the ActiveX control. These scripts can be
re-used and imported into other applications.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 147
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 8 – Scripting ActiveX Controls
2. Click the name of the ActiveX control from the left pane. The right pane contains the names of properties
and methods that are supported by the ActiveX control.
3. Click the name of the method to use from the right pane and then click OK. The method name and default
parameters are pasted into the script window at the cursor position.
4. Configure the method parameters inside the parentheses, to your specifications.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 148
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 8 – Scripting ActiveX Controls
2. Click the name of the ActiveX control from the left pane. The right pane contains the names of properties
and methods of the selected ActiveX control.
3. Click the name of the property to use from the right pane. The property name is inserted into the script
window at the cursor position.
4. Assign the property name to a tag or use according to your specifications.
5. Click OK.
Example(s)
The following script reads the ToPriority property of the ActiveX control instance AlarmViewerCtrl1 into the
integer tagname topri.
topri = #AlarmViewerCtrl1.ToPriority;
The following script writes the value MS Comic to the Font property of the ActiveX control called
AlarmViewerCtrl1. This example changes the display font of the AlarmViewer ActiveX control dynamically.
#AlarmViewerCtrl1.Font = "MS Comic";
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 149
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 8 – Scripting ActiveX Controls
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 150
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 8 – Scripting ActiveX Controls
3. Click the event to associate. Brackets and ellipses appear in the Script column.
4. In the Script column of the corresponding row, click between the brackets.
5. Enter a new name and click OK. When a message appears, click OK. The ActiveX Event Scripts dialog box
appears.
6. Create the script according to your specifications.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 151
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 8 – Scripting ActiveX Controls
3. Click the event to associate. Brackets and ellipses appear in the Script column.
4. In the Script column of the corresponding row, click the ellipsis button. The Choose ActiveX Script dialog box
appears.
5. Click an ActiveX script and click OK.
6. Click OK again.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 152
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 8 – Scripting ActiveX Controls
4. Select the ActiveX Event Scripts check box and click Import. All ActiveX event scripts are imported into the
current InTouch HMI application.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 153
Chapter 9
Troubleshooting QuickScripts
You can troubleshoot QuickScripts by using the Log Viewer to display run time values of tagnames.
LogMessage() Function
Writes a user-defined message to the ArchestrA Log Viewer.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 154
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 9 – Troubleshooting QuickScripts
Category
misc
Syntax
LogMessage("Message_Tag");
Parameter
Message_Tag
String to log to the Log Viewer. Actual string or message tagname.
Remarks
This is a very powerful function for troubleshooting InTouch scripting. By strategically placing LogMessage()
functions in your scripts, you can determine the order of QuickScript execution, the performance of scripts, and
identify the value of tags both before they are changed and after they have been affected by the QuickScript.
Each message posted to the Log Viewer is stamped with the exact date and time.
Important: The percent (%) character formats diagnostic messages that appear in the SMC Log Viewer while
debugging scripts. WindowViewer can stop responding if the % character appears in a log string or a function
parameter. To eliminate errors caused by %, use two %% characters.
Example(s)
LogMessage("Report Script is Running");
The above statement would print the following to the Log Viewer:
94/01/14 15:21:14 WWSCRIPT Message:Report Script is Running.
LogMessage("The Value of MyTag is " + Text(MyTag, "#"));
MyTag = MyTag + 10;
LogMessage("The Value of MyTag is " + Text(MyTag, "#"));
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 155
AVEVA™ InTouch HMI Scripting and Logic Guide
Chapter 9 – Troubleshooting QuickScripts
2. In the left pane expand Log Viewer, expand Default Group, and then click Local. The Log Viewer messages
appear in the details pane.
© 2021 AVEVA Group plc and its subsidiaries. All rights reserved. Page 156
Index
A
action scripts
openingIXactionscriptsopening • 19
triggersIXactionscriptstriggers • 32
ActiveX
calling a method • 147
control browser • 147
inserting methods or properties in a script • 29
linking properties to tags • 149
ActiveX event scripts
creatingIXActiveXeventscriptscreating • 151
importingIXActiveXeventscriptsimporting • 153
openingIXActiveXeventscriptsopening • 19
re-usingIXActiveXeventscriptsreusing • 151
self-referencingIXActiveXeventscriptsselfreferencing • 152
triggersIXActiveXeventscriptstriggers • 32
AddPermission() function • 130
application scripts
openingIXapplicationscriptsopening • 19
triggersIXapplicationscriptstriggers • 32
AttemptInvisibleLogon() function • 129
B
branching
IF-THEN-ELSE • 60
C
ChangePassword() function • 130
comments in scriptsIXcommentsinscripts • 48
condition scripts
triggersIXconditionscriptstriggers • 32
converting
discrete value to string • 91
integer value to string • 89
string to integer value • 90
string to real value • 91
creating
scripts • 14
D
data change scripts
triggersIXdatachangescriptstriggers • 32
discrete values, converting to string • 91
dot fields, inserting • 29
DText() function • 91
E
editing scriptsIXeditingscripts • 14
editor • 15
F
functions
definition • 11
OLE_CreateObject() function • 137
OLE_GetLastObjectError() functionIXfunctionsOLEGetLastObjectErrorfunction • 141
OLE_GetLastObjectErrorMessage() function • 141
OLE_IsObjectValid() function • 138
OLE_ReleaseObject() function • 138
OLE_ResetObjectError() functionIXfunctionsOLEResetObjectErrorfunction • 142
OLE_ShowMessageOnObjectError() functionIXfunctionsOLEShowMessageOnObjectErrorfunction
• 142
G
GetAccountStatus() function • 130
I
indenting script statementsIXindentingscriptstatements • 48
inserting
dot fieldsIXinsertingdotfields • 29
inserting functions • 29
inserting tagnames • 29
integers, converting from string • 90
integers, converting to string • 89
InvisibleVerifyCredentials() function • 130
IsAssignedRole() function • 130
K
key scripts
triggersIXkeyscriptstriggers • 32
L
literal data valuesIXliteraldatavalues • 48
Log ViewerIXLogViewer • 155
LogMessage() functionIXLogMessagefunction • 154
Logoff() function • 129
LogonCurrentUser() function • 129
M
MEM OLE • 15
multiple triggersIXmultipletriggers • 33
O
OLE
counting error messagesIXOLEcountingerrormessages • 142
OLE objects
reading a property • 139
validity • 138
writing a property • 139
OLE_CreateObject() function • 137
OLE_GetLastObjectError() function • 141
OLE_GetLastObjectErrorMessage() function • 141
OLE_IsObjectValid() function • 138
OLE_ReleaseObject() function • 138
OLE_ResetObjectError() function • 142
OLE_ShowMessageOnObjectError() function • 142
P
periodic script executionIXperiodicscriptexecution • 33
PostLogonDialog() function • 129
Q
QueryGroupMembership() function • 130
QuickFunctions • 66
calling • 68
configuring • 66
creating • 66
definition • 11
deleting • 66
modifying • 66
QuickScripts
about the language • 11
setting check pointsIXQuickScriptssettingcheckpoints • 154
R
real values
converting from string • 91
converting to strings • 89
S
script editor • 15
script examples
monitor asynchronous functionsIXscriptexamplesmonitorasynchronousfunctions • 68
script language overview • 47
script triggersIXscripttriggers • 32
scripts
definition • 11
inserting ActiveX methods or propertiesIXscriptsinsertingActiveXmethodsorproperties • 29
inserting dot fields • 29
inserting functionsIXscriptsinsertingfunctions • 29
inserting keywords or operatorsIXscriptsinsertingkeywordsoroperators • 29
inserting tagnamesIXscriptsinsertingtagnames • 29
inserting window namesIXscriptsinsertingwindownames • 29
periodic execution • 33
statements • 48
statementsIXstatements • 48
strings
converting discrete value • 91
subroutinesIXsubroutines • 48
syntax
rulesIXsyntaxrules • 47
T
tag referencesIXtagreferences • 48
types of script triggersIXtypesofscripttriggers • 32
V
viewing log messages • 155
W
window scripts
openingIXwindowscriptsopening • 19
triggersIXwindowscriptstriggers • 32
windows
moving and resizing • 96