Scripting
Scripting
Scripting
formerly Wonderware
No part of this documentation shall be reproduced, stored in a ret rieval system, or transm itted by any
means, electronic, mechanical, photocopying, rec ording, 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 soft ware described in this
documentation is furnished under a license agreement. This soft ware 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, Int elaTrac,
InTouch, OASyS, PIPEPHASE, PRiSM, PRO/II, PROV ISION, 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 trademark s can be found at:
https://sw.aveva.com/legal. All other brands may be trademarks of their respective owners.
Publication date: Friday, February 21, 2020
Contact Information
AVEVA Group plc
High Cross
Madingley Road
Cambridge
CB3 0HB. UK
https://sw.aveva.com/
For information on how to cont act sales, customer training, and technical support, see
https://sw.aveva.com/contact.
AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Contents
Chapter 1 Common Scripting Environment ....................................................................... 7
Script Editing Styles and Syntax................................................................................................. 7
Required Syntax for Expressions and Scripts .............................................................................. 7
Simple Scripts........................................................................................................................... 7
Script Execution Types .............................................................................................................. 8
Startup Scripts .................................................................................................................... 8
OnScan Scripts ................................................................................................................... 8
Execute Scripts ................................................................................................................... 8
OffScan Scripts ................................................................................................................... 9
Shutdown Scripts ................................................................................................................ 9
Deployment Scripts ............................................................................................................. 9
Working with QuickScript Editor Features ................................................................................. 10
Color Indicators for Script Elements .................................................................................... 10
Autocomplet e.................................................................................................................... 10
Accepting Autocomplete Suggestions ................................................................................. 14
Multi-level Undo and Redo ................................................................................................. 14
Dynamic Referencing Considerations ................................................................................. 14
Run-Time Client Script Behavior ........................................................................................ 16
Opening a Client Application Window ................................................................................. 16
Closing a Client Application Window................................................................................... 16
Minimizing a Client Application Window .............................................................................. 17
Maximizing or Restoring a Client Application Window .......................................................... 17
Visual Indication of Script Errors ......................................................................................... 17
Line Numbers ................................................................................................................... 17
Log Functions ................................................................................................................... 17
3
AVEVA Application Server formerly Wonderware Application Server Scripting Guide Contents
4
Contents AVEVA Application Server formerly Wonderware Application Server Scripting Guide
LogTrace() .................................................................................................................. 71
LogWarning() .............................................................................................................. 72
SendKeys() ................................................................................................................. 72
SetAttributeV T() .......................................................................................................... 74
SetAttributeV T2()......................................................................................................... 74
SetBad() ..................................................................................................................... 75
SetGood() ................................................................................................................... 75
SetInitializing()............................................................................................................. 76
SetUncertain() ............................................................................................................. 76
SignedAlarmAck()........................................................................................................ 77
SignedWrite() .............................................................................................................. 80
WriteStatus() ............................................................................................................... 84
WWControl() ............................................................................................................... 85
String Functions ................................................................................................................ 85
DText() ....................................................................................................................... 85
StringASCII()............................................................................................................... 86
StringChar() ................................................................................................................ 86
StringCompare().......................................................................................................... 87
StringCompareNoCase().............................................................................................. 87
StringFromGMTTimeToLocal() ..................................................................................... 88
StringFromIntg() .......................................................................................................... 89
StringFromReal() ......................................................................................................... 89
StringFromTime() ........................................................................................................ 90
StringFromTimeLoc al() ................................................................................................ 91
StringInString() ............................................................................................................ 92
StringLeft () .................................................................................................................. 92
StringLen() .................................................................................................................. 93
StringLower() .............................................................................................................. 93
StringMid() .................................................................................................................. 94
StringReplace() ........................................................................................................... 94
StringRight()................................................................................................................ 95
StringSpace() .............................................................................................................. 96
StringTest() ................................................................................................................. 97
StringToIntg() .............................................................................................................. 97
StringToReal()............................................................................................................. 98
StringTrim() ................................................................................................................. 99
StringUpper() .............................................................................................................. 99
Text()........................................................................................................................ 100
WWStringFromTime() ................................................................................................ 100
System Functions............................................................................................................ 101
CreateObject()........................................................................................................... 101
Now() ....................................................................................................................... 101
WWDDE Functions ......................................................................................................... 102
WWExecute() ............................................................................................................ 102
WWPoke() ................................................................................................................ 103
WWRequest() ........................................................................................................... 103
QuickScript .NET Variables ................................................................................................... 104
Numbers and Strings ....................................................................................................... 106
QuickScript .NET Cont rol Structures....................................................................................... 107
IF … THE N … ELSEIF … ELSE … ENDIF ....................................................................... 107
IF … THE N … ELSEIF … ELSE … ENDIF and Attribut e Quality ........................................ 109
FOR … TO … S TEP … NE XT Loop ................................................................................. 109
FOR EACH … IN … NE XT .............................................................................................. 110
TRY ... CATCH ............................................................................................................... 111
WHILE Loop ................................................................................................................... 112
5
AVEVA Application Server formerly Wonderware Application Server Scripting Guide Contents
6
AVEVA Application Server formerly Wonderware Application Server Scripting Guide
C HAPTER 1
Common Scripting Environment
This section describes common styles, syntax, commands, and behaviors of scripts within AVEVA™
Application Server, formerly Wonderware.
Simple Scripts
Simple scripts implement logic such as assignments, math, and functions. An example of this type of
scripting is:
React_temp = 150;
ResultTag = (Sample1 + Sample2)/2;
{this is a comment}
7
AVEVA Application Server formerly Wonderware Application Server Scripting Guide Common Scripting Environment
Startup Scripts
Startup scripts are called when an object containing the script is loaded into memory, such as during
deployment, plat form, or engine start.
Startup instantiat es COM objects and .NE T objects. Depending on load and other factors, assignments
to object attributes from the Startup method may fail. Attributes that reside off-object are not available to
the Startup met hod.
OnScan Scripts
OnScan scripts are called the first time an AppEngine calls this object to ex ecute after the object’s scan
state changes to OnScan. The OnScan method initiat es local object attribut e values and provides more
flexibility in the creation of .NE T or COM objects.
Attributes that are off-engine are not available to the OnScan method.
Execute Scripts
Execute scripts are called each time the AppE ngine performs a scan and the object is OnScan.
The Execute script method is the work horse of the scripting exec ution types. Use the Execute method for
your run-time scripting to ensure that all attributes and values are available to the script.
®
If the Quality check-box is checked, the Execute method is similar to InTouch scripts with the following
conditional trigger types:
Periodic: When going OnScan, a script with a periodic trigger executes immediately (at the next
scheduled scan period of the AppEngine). It then executes periodically whenever the elapsed time
evaluates as true.
Data Change: Executes when a data value or quality changes bet ween scans.
For the following trigger types, data changes between each scan are not evaluated, only the value at the
beginning of each script is used for evaluation purpos es. For example, if a Boolean attribut e changes
from True to False to True again during a scan cycle, this change is not evaluat ed as a dat a change as
the value is True at the beginning of each scan cycle.
OnTrue: Executes if the expression validates from a false on one scan to a true on the next scan.
OnFalse: Executes if the ex pression validates from a true on one scan to a false on the next scan.
These scripts also have time-based considerations. A trigger period of 0 means that the script executes
every scan.
Time-based scripts, WhileTrue, WhileFalse, and Periodic are evaluated and ex ecuted based on the
elapsed time from a timestamp generated from the previous execution, not on an elapsed time counter. It
is possible that a change in the system clock can change the interval between execution of these scripts.
8
Common Scripting Environment AVEVA Application Server formerly Wonderware Application Server Scripting Guide
WhileTrue: Executes scan to scan as long as the expression validates as true at the beginning of the
scan.
WhileFalse: Executes scan to scan as long as the expression validat es as false at the beginning of
the scan.
For ex ample, a periodic script is set to run every 60 minutes. The script executes at 11:13 AM. We expect
it to execute 60 minutes later at 12:13 PM. However, a time synchronization event occurred and the
node’s time is adjusted from 11:33 AM to 11:30 AM.
The script still executes when the system time reaches 12:13 PM. But because of the time change, the
actual (True) time period that elapsed bet ween executions is 63 minutes.
OffScan Scripts
OffScan scripts are called when the object is taken OffScan. This script type is primarily used to clean up
the object and account for any needs to address as a result of the object no longer executing.
If an object is taken OffScan, either directly, or indirectly because its engine is taken OffScan, all
in-progress asynchronous scripts for that object are requested to shut down by setting a Boolean
shutdown attribute for the script to true. A well-written script checks this attribute before and after
time-consuming operations. If the script takes more than 30 seconds to complete, a warning appears in
the logger that the script is not responding to the shutdown command. However, the script is allowed to
complete and is not terminated by forc e. This all takes place on the engine’s main thread and could
potentially hang the engine. During this time, the script might also time out and as a result exit before
executing all its logic.
Shutdown Scripts
Shutdown scripts are called when the object is about to be removed from memory, usually as a result of
the AppEngine stopping. Shutdown scripts are primarily used to destroy COM objects and .NE T objects
and to free memory.
Deployment Scripts
Deploying objects is both a critical and a load-intensive process for a Galaxy. Implementing scripting in
the Startup and OnScan methods can adversely affect a Galaxy’s deployment and redundancy
performance.
While objects are being deployed, their Startup and, if deployed OnScan scripts are executed. These
scripts must complete within the deployment time-out period for the deployment to be successful.
Placing large numbers of scripts, or scripts that require heavy processing power into the Startup or
OnScan script methods can slow or cause a deployment or failover to fail. In addition to the load that is
placed on the system at deployment time, the type of scripting done in the Startup and OnScan methods
is also important becaus e these scripts execute in a sequence.
During deployment and restart, the Startup and OnScan script methods do not execute objects based on
execution order. Objects are started up and placed on scan based on their alphanumeric tag name within
their hosting Area.
Follow the recommendation below for each type of script method to help determine what scripting
practices to follow in each script method.
Do not place the following types of scripting in the Startup or OnScan methods:
Database access
File system access to .csv, .xml, .txt, and other file types
Off-object referencing
Dynamic referencing
9
AVEVA Application Server formerly Wonderware Application Server Scripting Guide Common Scripting Environment
Element Color
Keywords Blue
Syntax highlight ed while typing.
Strings Purple
Syntax highlight ed while typing.
Autocomplete
QuickScript autocomplete incorporates several features for use while authoring object and client scripts:
Provides an autocomplete Attribute reference when you type a generic object name, such as "me."
Run-time attributes appear in an autoc omplet e list box. Typing "InTouch:" displays an autocomplete
list of tagnames from the most recently selected ViewApp template.
Provides method parameter help in an autocomplete list box including context -specific suggestions
covering definitions, keywords, script elements, and programmatic constructs such as try ... catch or
while ... endwhile.
Automatic word completion of Attribute references, methods, programmatic constructs, and other
script elements.
These features serve as convenient documentation of method parameters and scripting syntax as well
as an enhanc ed input method.
Autocomplet e 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 cont ext from the icons
displayed with the list items.
10
Common Scripting Environment AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Icon Represents
MxBoolean attribute
MxInteger attribute
MxFloat attribute
MxDouble attribute
MxString attribut e
MxTime attribute
MxElapsedTime attribut e
MxReference attribute
MxStatus attribute
MxDataTypeEnum attribute
MxSecurityClassification attribute
MxDataQuality attribute
MxQualifiedStruct attribute
MxInternationalizedString attribute
.Net Method
.Net Property
11
AVEVA Application Server formerly Wonderware Application Server Scripting Guide Common Scripting Environment
Icon Represents
.Net Namespace
.Net Struct
.Net Class
.Net Interface
.Net Enumeration
QuickScript Keyword
Cont ained object name, or any partial attribute name such as a attribute, field
attribute, or primitive that has a dot in the name, or any attribute of Mx type
MxNone, or if there are several type choices among objects and attributes.
If the attribute cannot be exactly or unambiguously returned, this icon will appear.
Partial name example: For me.alarm.a1, typing "me.alar" will show the blue ball
icon for alarm.
MxNone example: input/output extension attribute WriteValue.
Rectangle
Rounded rectangle
Line
Text
Ellipse
12
Common Scripting Environment AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Icon Represents
Curve
Closed curve
Button
Polygon
Polyline
Connect
Image
Alarm control
Edit box
Arc
Pie
Chord
Circle
Status
Radio buttons
Checkbox
13
AVEVA Application Server formerly Wonderware Application Server Scripting Guide Common Scripting Environment
Icon Represents
Edit box
Combo box
Calendar
Date picker
List box
14
Common Scripting Environment AVEVA Application Server formerly Wonderware Application Server Scripting Guide
The attribute shows if the referencing script is complete. In this example you create Ref_Done.
IO_Item1 and IO_Item2 are the I/O points referenced in this example.
2. Create the script. The script in this example is called Set_Refs. The script has a trigger type of
WhileTrue with a 0 trigger period.
15
AVEVA Application Server formerly Wonderware Application Server Scripting Guide Common Scripting Environment
16
Common Scripting Environment AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Note: In addition to error tooltips, the script editor will also display the variable name and type in a tooltip
when hovering over a variable name in the script.
In some cases, more than one error will be underlined. This is not always possible because some errors
prevent the compiler from continuing past the erro r.
Line Numbers
The script editor displays line numbers in the left margin.
Line numbers of up to four digits will display when the script editor is not zoomed.
The line number may appear clipped for scripts longer than 9999 lines or when the script editor is
zoomed.
Use the right-click context menu Go To function to go to a specific line in the script.
Log Functions
QuickScript .NET functions include several log functions to capture and display information in the logger
under different log flags.
LogCustom() on page 69
LogE rror() on page 70
LogMessage() on page 71
LogTrace() on page 71
LogWarning() on page 72
17
AVEVA Application Server formerly Wonderware Application Server Scripting Guide Common Scripting Environment
Important: To use the LogCustom function, you must enable Log Custom in the System Management
Cons ole (SMC) Log Flag Editor. To us e the LogTrace function, you must enable Log Trace in the SMC
Log Flag Editor.
18
AVEVA Application Server formerly Wonderware Application Server Scripting Guide
C HAPTER 2
QuickScript .NET Functions
For information about other functions in this category, see third-party documentation.
Keep in mind the following limitations when you use the script functions:
Be aware of the .NE T datatypes.
Starting a GUI application from within a server script is not supported.
Although QuickScript supports import libraries built with .NE T CLR version 2.0.50727, it does not
support any of the new language features introduced with .NE T 2.0, such as generics.
Script Functions
This section describes the script functions included in the InTouc h OMI development environment. The
function documentation is organized into a set of folders that represents the same organization of the
functions in the Script Function Browser.
Graphic Client Functions on page 19
InTouch Functions on page 40
Math Functions on page 58
Miscellaneous Functions on page 65
String Functions on page 85
System Functions on page 101
WWDDE Functions on page 102
The Type folder contains a set of Microsoft .NE T script functions, which are not documented. Refer to
Microsoft .NE T documentation for descriptions of the functions.
GetCPQuality()
Returns the Quality value of a custom property. This function is available within any Industrial Graphics
client script, but is not supported in InTouch OMI ViewApps (works with InTouc h HMI only).
If used in an InTouc h OMI ViewApp, GetCP Quality() always returns a value of 0 (bad quality).
Syntax
Int GetCPQuality(String name)
Where String name is the name of the custom property whose quality is to be retrieved.
This script function takes the name of a custom property on the symbol. This argument is of type string
and it can be a referenc e or a constant.
If the custom property is type constant, GOOD is the quality always returned.
Note: For use with custom properties only. It does not apply to InTouch tags.
19
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Return Value
The Get CPQuality() script function returns a value 0 -255 of type Int eger, as per the OPC quality
standard. 192 is GOOD.
Example
cp2 = GetCPQuality("cp1");
Where cp1 and cp2 are custom properties and the data type of cp2 is Int eger.
GetCPTimeStamp()
Returns the time stamp of a custom property. This function is available within any Industrial Graphics
client script.
Syntax
DateTime GetCPTimeStamp(String name)
Where String name is the name of the custom property whos e time stamp is to be retrieved.
This script function takes the name of a custom property on the symbol. This argument is of type string
and it can be a referenc e or a constant.
Note: For use with custom properties only. It does not apply to InTouch tags.
Return Value
The Get CP TimeStamp() script function ret urns the time stamp of the custom property’s current value of
type DateTime. If the custom property value is a constant, then the return value is the time the value was
created.
Example
cp2 = GetCPTimeStamp("cp1");
Where cp1 and cp2 are custom properties and the data type of cp2 is DateTime.
HideContent()
Closes one or more matching content items within an InTouch OMI ViewApp. Multiple cont ent items can
be closed if they match the parameters that are specified in the HideContent call. The HideContent()
function uses a subset of the parameters that ShowContent() on page 25 uses.
The HideContent() function works only within a single level of the layout, and the level is defined by the
SearchScope parameter. By default, SearchScope is "Self," and searches within the layout that has
invok ed it. This function is available wit hin any Industrial Graphics client script or InTouch OMI layout
script. SearchScope parameters other than "Self" constrain the search for content to only layouts that are
directly associated with the Screen Profile, and not a nested layout. (A nested layout is a layout
embedded or contained in a pane of another layout.)
Note: While the HideContent() function is available in object scripts through bot h IntelliS ense and the
IDE function browser, its use in object scripts is not supported.
Category
Graphic Client
Syntax
Dim contentInfo as aaContent.ContentInfo;
contentInfo.Content = “SA_Valve_2Way";
contentInfo.Name =”SA_Valve_2Way1”;
contentInfo.ContentType = “Level_3”;
contentInfo.PaneName =”Pane 2”;
contentInfo.ScreenName =”Primary”;
contentInfo.SearchScope = aaContent.SearchScope.Self;
20
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
HideContent( contentInfo );
Parameter
Cont entInfo
The description of the content, along with the location of the content (screen and pane) to be hidden.
Data Type
aaContent.Content Info
Examples
Dim contentInfo as aaContent.ContentInfo;
contentInfo.Name = “Symbol21”;
HideContent( contentInfo );
Where "Symbol21" is the Name property of the content shown in the Layout Editor.
Note: E ven if you do not define any ContentInfo properties, you must pass the Content Info parameter in
the HideContent call (i.e., HideContent ( contentInfo )).
Content A unique name for an item, either in the Graphic String Optional
Toolbox or associated with an asset, that
specifies the content to be loaded into the pane.
Cont ent can be a symbol, a layout, or external
content.
Additional "Content" is the name of the item within the Graphic Toolbox or associated
information with an asset.
The content names are the names shown in the Graphic Toolbox. The
Properties tab of the Layout and ViewA pp editors lists content name as the
Cont ent property.
Relative names, for example, "Me.S1," can also be used to designate
content.
21
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Cont ent name must be unique. Application Server does not check for
duplicated names. If Cont ent is duplicated, all content with the same name is
closed.
If the same content item is used in multiple panes of the layout, and the
"Content" property is specified by the HideCont ent() method, all instances of
the content item are hidden. To hide a single instance of a content item that
appears more than once in the layout, use the "Name" property instead.
Example contentInfo.Content =
"UserDefinedObject_001.Symbol_001";
ScreenName Specifies the screen that contains the pane with String Optional
the content to be closed.
Additional ScreenNames are configured in the Screen Profile Editor. See Screen
information Profiles in the System Platform Help for additional information.
Example contentInfo.ScreenName = "Wall";
22
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
23
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Terms
Content type: specifies the type of content represent ed by a pane.
Content: the name of a graphic, layout, or external content item as it is listed within the the Graphic
Toolbox. This is displayed as the Content property in t he Layout E ditor when the content item is a dded to
a layout.
Name: the unique name assigned to an instance of a content item, when it is added to a layout. This is
displayed as the Name property in the Layout Editor when the content item is added to a layout, and can
be edited.
Layout: consists of one or more rectangular areas called panes that contain content shown in a
ViewApp. A layout is associated with a screen, or it can be embedded within a pane of another layout.
Embedded or Nested Layout: In the context of ShowContent and HideContent, an embedded layout is
a layout that is placed inside a pane of a containing layout. When SearchScope is "Self" (default),
embedded layouts are searched for content that matches the parameters specified in the
ShowContent/HideContent call.
Pane: rectangular area of a layout that can hold a single piece of content.
Primary screen: represents the main screen of a workstation that will show a running ViewA pp
Screen Profile: defines the physical characteristics of one or more client workstation screens that will
show a running ViewApp and how these screens are arranged with respect to each other.
Source screen: screen from which ShowContent or HideContent was called.
See Also
ShowContent () on page 25, HideS elf() on page 25
HideGraphic()
Closes an open graphic pop-up window shown in the ShowGraphic() script with the given identity name.
The HideGraphic() function has been extended to close InTouch Windows identified with a given identity
name. This function is available wit hin any Industrial Graphics client script.
Category
Graphic Client
Syntax
HideGraphic(string identity);
Parameter
Identity
The unique name of the instance that shows the graphic.
Examples
HideGraphic("i1");
Where "i1" is string Identity.
HideGraphic("InTouch:Window1");
Where "InTouch:Window1" is the string identity.
See Also
ShowGraphic () on page 30, HideS elf() on page 25
24
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
HideSelf()
Closes the displayed graphic or layout for which this script is configured. This script function is available
within any Industrial Graphics client script or a nested InTouch OMI Lay out script.
Category
Graphic Client
Syntax
HideSelf();
Remarks
For an Industrial Graphics script, you must call the script function within the symbol to hide the popup.
When used in an InTouch OMI Lay out script to hide a layout, the script function has no effect on a top
level layout; it will only close the layout when called from a nested (embedded) layout.
Example
HideSelf();
See Also
ShowGraphic () on page 30, HideGraphic() on page 24, ShowContent() on page 25, HideContent() on
page 20
Logoff()
Action script that automatically logs off the current user from a ViewApp.
Action scripts are graphic animations that are triggered by a user action such as a mouse click.
Category
Miscellaneous
Syntax
LogOff() ;
Parameter
None
Trigger
On Left-Click/Key/Touc h Down
Additional Information
A log off button can be added that uses the Logoff() method to allow the user t o log off from t he ViewApp.
Example
Logoff() ;
See Also
ShowLoginDialog() on page 39
ShowContent()
Loads a content item into an InTouc h OMI pane. This function is available within an Industrial Graphics
client script or layout script to show the content of pane.
25
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
To load a graphic into a modal or modeless popup window, use ShowGraphic() on page 30. You can use
ShowGraphic () for both InTouch OMI and InTouc h HMI ViewA pps. The ShowContent() method is for
InTouch OMI only.
Note: While the ShowContent () function is available in object scripts through both IntelliS ense and the
IDE function browser, its use in object scripts is not supported.
Category
Graphic Client
Syntax
Dim contentInfo as aaContent.ContentInfo;
contentInfo.Content = “SA_Valve_2Way”;
contentInfo.Name =”SA_Valve_2Way1”;
contentInfo.ContentType = “Level_3”;
contentInfo.PaneName =”Pane 2”;
contentInfo.ScreenName =”Primary>”;
contentInfo.SearchScope = aaContent.SearchScope.Self;
ShowContent( contentInfo );
Parameter
Cont entInfo
Description of the content to be shown and where to show it (which screen and pane)
Data Type
aaContent.Content Info
Example
Show content in a pane
dim contentInfo as aaContent.ContentInfo;
contentInfo.Content = "Symbol1";
contentInfo.Name = "S12";
contentInfo.ContentType = "Overview";
contentInfo.OwningObject = "Enterprise";
contentInfo.PaneName = "Pane 1";
contentInfo.ScreenName = "Wall";
contentInfo.PropertyOverrideValues = cpValues;
contentInfo.SearchScope = aaContent.SearchScope.PrimaryScreen;
ShowContent ( contentInfo );
aaContent.ContentInfo Properties
Cont entInfo is a predefined structure that contains the data members described in the following
table.
String properties can be a concatenation of string and/or custom properties.
26
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Note: See "Terms," below, for definitions of Content Type, Layout, Pane, Screen Profile, Primary
Screen, and Source Screen.
Content A unique name for an item, either in the Graphic String Required
Toolbox or associated with an asset, that
specifies the content to be loaded into the pane.
Cont ent can be a symbol, a layout, or external
content.
Additional "Content" is the name of the item within the Graphic Toolbox or associated
information with an asset. It can be a symbol, a layout, or external content item.
Symbol (graphic), layout, and external content names are listed in the
Graphic Toolbox and in the Toolbox tab of the Layout and ViewApp editors.
Relative names, for example, "Me.S1," can also be used to designate
content.
If t he specified content is already shown, invoking S howContent again closes
the open content and reopens it.
However, if the content is a symbol and you are using object wizards that
include Symbol Wizard custom property selections, and the symbol has an
owning object, use the symbol's abs olute name. This allows the correct
symbol configuration to be shown for the instance. See Owning Object,
below, for more information.
Cont ent name must be unique. Application Server does not check for
duplicated names. If Content is duplicated, open content with the same name
is closed, and the content with the duplicated name is opened in its place.
PropertyOverrides and other Cont entInfo parameters are updated wit h any
new specified values.
If the same content item is used in multiple panes of the layout, and the
"Content" property is specified by the HideCont ent() method, all instances of
the content item are hidden. To specify a single instance, use the "Name"
property instead.
Example contentInfo.Content =
"UserDefinedObject_001.Symbol_001";
27
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
contentInfo.Name = "Symbol_011";
Example
PaneName Specifies the pane in which to place the content. String Optional
Additional PaneNames are configured in the Layout Edi tor. See Layouts in the S ystem
information Platform Help for additional information.
Example contentInfo.PaneName = "Pane1";
28
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Example contentInfo.SearchScope =
aaContent.SearchScope.PrimaryScreen;
OwningObject Sets the owning object of the content shown by String Optional
the ShowContent() script function.
Additional Can be a concat enation of constant strings and reference strings.
Information
Can be browsed using the Display Automation Object Browser, or you can
type the name of the owning object.
Note: The OwningObject property sets references for the graphic, but is not
associated with the Graphic Name property if the symbol is part of an Object
Wizard. Therefore, if you are scripting a symbol with an owning object,
specify the owning object name as part of the Graphic Name property, for
example, UserDefined_001.Pump_001.
Example contentInfo.OwningObject = "Enterprise";
Terms
Content type: specifies the type of content represent ed by a pane.
Content: the name of a graphic, layout, or external content item as it is listed within the the Graphic
Toolbox. This is displayed as the Content property in t he Layout E ditor when the content item is added to
a layout.
Name: the unique name assigned to an instance of a content item, when it is added to a layout. This is
displayed as the Name property in the Layout Editor when the content item is added to a layout, and can
be edited.
Layout: consists of one or more rectangular areas called panes that contain content shown in a
ViewApp. A layout is associated with a screen, or it can be embedded within a pane of another layout.
Embedded or Nested Layout: In the context of ShowContent and HideContent, an embedded layout is
a layout that is placed inside a pane of a containing layout. When SearchScope is "Self" (default),
embedded layouts are searched for content that matches the parameters specified in the
ShowContent/HideContent call.
Pane: rectangular area of a layout that can hold a single piece of content.
Primary screen: represents the main screen of a workstation that will show a running ViewA pp
Screen Profile: defines the physical characteristics of one or more client workstation screens that will
show a running ViewApp and how these screens are arranged with respect to each other.
Source screen: screen from which ShowContent or HideContent was called.
29
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
See Also
HideContent () on page 20
ShowGraphic () on page 30
ShowGraphic()
Shows a graphic within a pop-up window. The ShowGraphic() function has been extended to call
InTouch Windows. This function is available within any Industrial Graphics client script.
Category
Graphic Client
Syntax
Show a graphic within a pop-up window
Dim graphicInfo as aaGraphic.GraphicInfo;
graphicInfo.Identity = "<Identity>";
graphicInfo.GraphicName = "<SymbolName>";
ShowGraphic( graphicInfo );
Call an InTouch window
Dim graphicInfo as aaGraphic.GraphicInfo;
graphicInfo0.Identity = "<InTouch:WindowName>";
ShowGraphic( graphicInfo );
Parameter
GraphicInfo
Data Type
aaGraphic.Graphic Info
Examples
Show graphic within a pop-up window
ShowGraphic (graphicInfo);
Show an InTouch window
Dim graphicInfo0 as aaGraphic.GraphicInfo;
graphicInfo0.Identity = "InTouch:Window1";
ShowGraphic( graphicInfo0 );
aaGraphic.GraphicInfo Properties
Any string properties can be a conc atenation of strings and/or custom properties.
Identity
A unique name that identifies which instance has opened the graphic.
Data Type
String
Additional Information
Mandatory
The same Identity is used in the HideGraphic() script function to close the pop-up window.
Valid Range
The name cannot contain more than 329 characters.
The name must contain at least one letter.
Valid characters are alphanumeric and special characters ($, #, _).
30
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Example
graphicInfo.Identity = "i1";
GraphicName
The name of the graphic to show.
Data Type
String
Valid Range
The name cannot contain more than 329 characters.
The name must contain at least one letter.
Valid characters are alphanumeric and special characters ($, #, _).
Additional Information
Mandatory
Browse using the Di splay Galaxy Browser or directly type the graphic name.
Galaxy name can come from:
o Graphic Toolbox, for example:
"Symbol_001"
o Instances, absolute or hierarchical, for example:
"Userdefined_001.Symbol1", "Userdefined_001.Pump_001.S1"
o Relative reference, for example:
"Me.Symbol_001"
Use an absolute name to specify the symbol name and owning object if you are using an Object
Wizard with Symbol Wizard custom property selections. This allows the correct symbol configuration
to be shown for the instance. See Owning Object, below, for more information.
If you type any invalid character or exceed the character limit, the system shows a warning message
at run time. There is no validation at design time.
The graphic name can be a concatenation of constant strings and reference strings. For
example:"Pump_001" + ".Symbol_001"; cp1 + ".Symbol_001", where the value of
cp1 = "Pump_001"; or Obj1.Str1 + ".Symbol_001", where the value of Obj.Str1
= "Pump_001".
Examples
Graphic Toolbox Reference
graphicInfo.GraphicName = "S1";
Absolute Reference
graphicInfo.GraphicName = "OwningObjectName.SymbolName";
OwningObject
The owning object of the graphic shown by the ShowGraphic() script function.
Data Type
String
Default Value
Empty
Additional Information
Optional
Can be a concat enation of constant strings and reference strings.
Can be browsed using the Di splay Automation Object Brow ser, or you can type the name of the
owning object.
31
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Note: The OwningObject property sets references for the graphic, but is not associated with the
GraphicName property if the symbol is part of an Object Wizard. Therefore, if you are scripting a
symbol with an owning object, specify the owning object name as part of the Graphic Name property,
for example, UserDefined_001.Pump_001.
Example
graphicInfo.OwningObject = "UserDefined_001";
HasTitleBar
Determines if the graphic is shown with a title bar.
Data Type
Boolean
Default Value
True
Example
graphicInfo.HasTitleBar = false;
WindowTitle
Specifies the title shown in the window title bar.
Data Type
String
Default Value
Empty
Valid Range
Limit 1024 characters
Additional Information
Can be a constant string, a reference, or an ex pression.
If you change the owning object for an Aut omationObject graphic, the window title is updated
accordingly.
If the WindowTitle parameter is empty, the value of the Identity parameter is shown on the title bar.
Example
graphicInfo.WindowTitle = "Graphic01";
WindowType
Specifies whether window type is modal or modeless.
Data Type
Enum
Default Value
Modeless
Valid Range
0, 1
Enumerations
WindowType Integer
Modal 0
Modeless 1
32
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Examples
graphicInfo.WindowType = aaGraphic.WindowType.<windowtype>;
graphicInfo.WindowType = 1;
HasCloseButton
Determines if the pop-up window has a close button.
Data Type
Boolean
Default Value
True
Example
graphicInfo.HasCloseButton = false;
Resizable
Determines if the pop-up window is resizable.
Data Type
Boolean
Default Value
False
Example
graphicInfo.Resizable = true;
WindowLocation
Specifies the loc ation of the pop-up window.
Data Type
Enum
Default Value
Cent er
Valid Range
One of 0–12
Enumerations
WindowLocation Integer
Cent er 0
Above 1
TopLeftCorner 2
Top 3
TopRight Corner 4
LeftOf 5
LeftSide 6
RightSide 7
Right Of 8
33
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
WindowLocation Integer
BottomLeftCorner 9
Bottom 10
BottomRightCorner 11
Below 12
Additional Information
If you have selected Desktop as the window relative position, Above, LeftOf, RightOf, and Below are
invalid.
For more information about the behavior of the WindowLocation parameter, see "Working with the
Show/ Hide Graphics Script Functions," in the Creating and Managing Industrial Graphics User
Guide.
Examples
graphicInfo.WindowLocation = aaGraphic.WindowLocation.<WindowLocation>;
graphicInfo.WindowLocation = 1;
WindowRelativePosition
Specifies the relative position of the pop-up window.
Data Type
Enum
Default Value
Desktop
Valid Range
One of 0–8
Enumerations
WindowRelativePosition Integer
Desktop 0
Window 1
ClientArea 2
ParentGraphic 3
ParentElement 4
Mouse 5
DesktopXY 6
WindowXY 7
ClientAreaXY 8
Examples
graphicInfo.WindowRelativePosition =
aaGraphic.WindowRelativePosition.<WindowRelativePosition>;
graphicInfo.WindowRelativePosition = 1;
34
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
RelativeTo
Specifies the size of the pop-up window relative to the graphic, desktop, or customized width and
height.
Data Type
Enum
Default Value
Graphic
Valid Range
One of 0–2
Enumerations
RelativeTo Integer
Graphic 0
Desk Top 1
CustomizedWidt hHeight 2
Additional Information
If you enter aaGraphic.RelativeTo.CustomizedWidthHeight, you can include the values of the height
and width in the script. Otherwise, the default values are used.
Examples
graphicInfo.RelativeTo = aaGraphic.RelativeTo.<RelativeTo>;
graphicInfo.RelativeTo = 1;
X
The horizont al position of the pop -up window.
Data Type
Integer
Default Value
0
Valid Range
-2,147,483,648 through 2,147,483,647
Additional Information
If X is beyond the integer range, an overflow message appears in the Logger at run time.
This parameter is applicable only if the value of the WindowRelativePosition parameter is
DesktopXY, WindowXY, or ClientAreaXY.
Unlike the ShowSymbol animation, there is no boundary for this value.
Examples
graphicInfo.X = 100;
Y
Specifies the vertical position of the pop -up window.
Data Type
Integer
Default Value
0
35
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Valid Range
-2,147,483,648 through 2,147,483,647
Additional Information
If Y is beyond integer range, a proper overflow message will appear in the Logger at run time.
This value is applicable only if WindowRelativeP osition is DesktopXY, WindowXY, or ClientAreaXY.
Unlike the ShowSymbol animation, there is no boundary for thi s value.
Examples
graphicInfo.Y = 100;
Width
Specifies the width of the pop-up window.
Data Type
Integer
Default Value
100
Valid Range
0–10000
Additional Information
Applicable only if RelativeTo is CustomizedWidthHeight
You can specify either t he height or the width of t he pop -up window. The system calculates the other,
based on the aspect ratio of the symbol.
If you enter an out-of-boundary value, the system shows an "Out of range" message at run time. If
the value > 10000, it is set at 10000. If the value < 0, it is set at 0.
Examples
graphicInfo.width = 500;
Height
Specifies the height of the pop-up window.
Data Type
Integer
Default Value
100
Valid Range
0–10000
Additional Information
Applicable only if RelativeTo is the value of the CustomizedWidthHeight parameter.
You can specify either t he height or the width of t he pop -up window. The system calculates the other,
based on the aspect ratio of the symbol.
If you enter an out-of-boundary value, the system shows an "Out of range" message at run time. If
the value > 10000, it is set at 10000. If the value < 0, it is set at 0.
Examples
graphicInfo.height = 500;
TopMost
Sets a value that indicates whether the ShowGraphic appears in the top most z-order window. A
ShowGraphic whose Topmost property is set to true appears above all windows whose TopMost
properties are set to fals e (same as Windows Task Manager).
Data Type
Boolean
36
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Default Value
False
Additional Information
ShowGraphic windows whose Topmost properties are set to true appear above all windows whose
Topmost properties are set to false. In a group of windows that have the Topmost property set to
true, the active window is the topmost window.
Note: Do not create scripts that launch a non -TopMost Modal dialog from a TopMost dialog. Users
will not be able to interact with the View if the Modal dialog is completely hidden by any TopMost
window.
Example
graphicInfo.TopMost = true;
ScalePercentage
Sets the scaling percentage of the pop-up window and the graphic it contains.
Data Type
Integer
Default Value
100
Valid Range
0–1000
Additional Information
If you enter an out-of-boundary value, the system shows an "Out of range" message at run time. If
the value > 1000, it is set at 1000. If the value < 0, it is set at 0.
Examples
graphicInfo.ScalePercentage = 150;
KeepOnMonitor
Specifies that a pop-up window should appear entirely within the boundaries of an application
window.
Data Type
Boolean
Default Value
True
Example
graphicInfo.KeepOnMonitor = true;
StretchGraphicToFitWindowSize
Determines if the graphic is scaled to the current size of the pop-up window.
Data Type
Boolean
Default Value
True
Additional Information
Applicable only if the value of the ScalePercent age parameter is greater than 100.
Examples
graphicInfo.StretchGraphicToFitWindowSize = false;
37
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
StretchWindowToScreenWidth
Determines if the pop-up window is scaled to the same width as the screen.
Data Type
Boolean
Default Value
False
Additional Information
Applicable only if the WindowRelativePosition parameter is Desktop, Window, Client Area,
ParentGraphic, or ParentElement.
Examples
graphicInfo.StretchWindowToScreenWidth = true;
StretchWindowToScreenHeight
Determines if the pop-up window is scaled to the same height as the screen.
Data Type
Boolean
Default Value
False
Additional Information
Applicable only if the WindowRelativePosition parameter is Desktop, Window, Client Area,
ParentGraphic, or ParentElement.
Examples
graphicInfo.StretchWindowToScreenHeight = true;
CustomProperties
Sets the custom properties of the symbol being shown.
Data Type
CustomPropertyValueP air[] array
Additional Information
The first three parameters are custom property name, value, and Is Constant.
Both custom property and the value can be a constant string, reference, or concatenation of strings.
If the paramet er IsConstant = True, the value is treated as a constant. Otherwis e, the value is treated
as a reference.
The array index starts at 1.
Examples
Dim cpValues [4] as aaGraphic.CustomPropertyValuePair;
cpValues[1] = new aaGraphic.CustomPropertyValuePair("CP1", 20, true);
cpValues[2] = new aaGraphic.CustomPropertyValuePair("CP2", Pump.PV.TagName,
true);
cpValues[3] = new aaGraphic.CustomPropertyValuePair("CP3", "CP"+var1, CP2 +
"001" + ".Speed", true);
cpValues[4] = new aaGraphic.CustomPropertyValuePair("CP3", "InTouch:Tag1",
false);
graphicInfo.CustomProperties = cpValues;
Remarks
Any parameter that has default value in the GraphicInfo is optional. If no input value specified for these
parameters, the default values are used at run time. Any parameter except the Enum data type can be a
constant, reference, or expression.
38
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
For more information, see "Working wit h the Show/Hide Graphics Script Functions" in the Creating and
Managing Industrial Graphics User Guide.
Examples for ShowGraphic
Basic script example:
Dim graphicInfo as aaGraphic.GraphicInfo;
graphicInfo.Identity = "Script_001";
graphicInfo.GraphicName = "Symbol_001";
ShowGraphic( graphicInfo );
Advanced script example:
Dim graphicInfo as aaGraphic.GraphicInfo;
Dim cpValues [2] as aaGraphic.CustomPropertyValuePair;
cpValues[1] = new aaGraphic.CustomPropertyValuePair("CP1", 20, true);
cpValues[2] = new aaGraphic.CustomPropertyValuePair("CP2", "Pump.PV.TagName",
false);
graphicInfo.Identity = "i1";
graphicInfo.GraphicName = "S1";
graphicInfo.OwningObject = "UserDefined_001";
graphicInfo.WindowTitle = "Graphic01";
graphicInfo.Resizable = false;
graphicInfo.CustomProperties=cpValues;
ShowGraphic( graphicInfo );
Where "i1" is string Identity and the symbol "S1" contains custom property CP1 and CP2.
See Also
HideS elf() on page 25
ShowLoginDialog()
Action script that shows a login dialog box with fields to enter a username and password. A typical login
interface includes a login button that is selected by the user to show the Login dialog box with fields to
enter a username and password.
Action scripts are graphic animations that are triggered by a user action such as a mouse click.
Category
Miscellaneous
Syntax
ShowLoginDialog() ;
Parameter
None
Trigger
On Left-Click/Key/Touc h Down
Additional Information
A log off button can be added that uses the Logoff() method to allow the user t o log off from t he ViewApp.
Example
ShowLoginDialog() ;
See Also
Logoff() on page 25
39
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
InTouch Functions
The following InTouch functions can be used within the script editor contained in the Industrial Graphic
Editor. In all functions that specify tag names as parameters, you can use InTouch tags from your
InTouch application.
InTouch script functions can be used only in symbol scripts. InTouch script functions do not work in
ArchestrA object scripts. Even though the object script will not work, no error or warning is generated.
Note: Using the Convert to Industrial Graphic option in InTouch scripts may wrongly append the term
"InTouch:" to the script function name. To avoid errors, remove the term "InTouch:" from the script
function name.
AddPermission() Function
Assigns a certain InTouch access level to a given user group on the local system or on the domain. When
a user belonging to t hat group logs on to t he InTouch HMI after t he AddPermission() function is called, he
or she receives the specified access level.
Category
security
Syntax
DiscreteTag=AddPermission( "Domain", "Group", AccessLevel);
Arguments
Domain
Name of the domain or local computer in which the group is located.
Group
Windows user group.
AccessLevel
InTouch access level that you want to associate with the given group.
Remarks
Valid for operating system security only. When this function is called, it checks for the presenc e of the
specified group in the specified domain or workgroup. If successful, TRUE is returned, and the specified
Access Level is associated with the group for subsequent user log ons. In all other cases, (that is, if an
invalid value is specified for any of the arguments) FALSE is returned.
This function is typically configured to run on application start up. It does not affect users that are currently
logged on. Only users that log on after AddPermission() is successfully called receive the access level
associated with their group.
Examples
DiscreteTag=AddPermission( "corporate_hq", "InTouchAdmins", 9000);
DiscreteTag=AddPermission( "johns01", "InTouchUsers", 5000);
See Also
PostLogonDialog(), InvisibleVerifyCredentials(), IsAssignedRole(), AttemptInvisibleLogon(),
QueryGroupMembership()
AttemptInvisibleLogon() Function
The AttemptInvisibleLogon() function can be used in a script to log on a user to InTouch using the
supplied credentials. The us er is not required to enter a password or user ID.
40
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Category
security
Syntax
DiscreteTag=AttemptInvisibleLogon( "UserId", "Password", "Domain" );
Arguments
UserId
A valid user account name.
Password
Password of the user.
Domain
Name of the local c omput er, work group, or domain to which the user belongs. This argument applies
only if the current security type is operating system-based.
Return Value
Returns TRUE if authentication is successful. Otherwise, it returns FALSE.
Remarks
An attempt is made to log on to the InTouch HMI using the supplied credentials.
If the logon attempt succeeds, then TRUE is returned and the $OperatorDomain, $OperatorName,
$AccessLevel, and $Operator system tags are updated accordingly.
If the log on attempt fails, then FA LSE is returned, and the currently logged on us er (if any) continues
to be the current user.
The Domain argument is only valid for operating system-bas ed security. If ArchestrA security mode is in
use and if ArchestrA security is in turn using operating system-based security, the UserId argument
should contain the fully qualified user name with domain name or computer name.
Examples
When security is operating system-bas ed:
DiscreteTag=AttemptInvisibleLogon("UserId", "Password", "Domain" );
When security is either InTouch-based or ArchestrA-based:
DiscreteTag=AttemptInvisibleLogon("UserId", "Password", "" );
See Also
PostLogonDialog(), InvisibleVerifyCredentials(), IsAssignedRole(), QueryGroupMembership(),
AddPermission()
ChangePassword() Function
Shows the Change Password dialog box, allowing the logged on operator to change his/her password.
Category
security
Syntax
[Result=]ChangePassword();
Return Value
Returns one of the following int eger values:
0 = Cancel was pressed.
1 = OK was pressed.
41
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Remarks
If the operat or uses a touch screen, the operator can use the alphanumeric keyboard to enter the new
password.
Example
The following script can be plac ed on a button or called from a condition script or data change script.
Errmsg=ChangePassword();
EnableDisableKeys() Function
Enables/disables key filters for the Alt, Escape, and Windows keys.
Category
View
Syntax
EnableDisableKeys(AltKey, EscKey, WinKey);
Parameters
AltKey
Integer to enable or disable key filters for the Alt key:
1 = enable filter (disable Alt key)
0 = disable filter (enable Alt key)
EscKey
Integer to enable or disable key filters for the Escape key:
1 = enable filter (disable Esc key)
0 = disable filter (enable Esc key)
WinKey
Integer to enable or disable key filters for the Windows key:
1 = enable filter (disable Win key)
0 = disable filter (enable Win key)
Remarks
Disabling the Alt key also disables the Win+L key combination (for locking the Windows desktop). Win+L
is the shortcut for another combination of keys that involves the Alt key. Thus, disabling the Alt key also
disables the shortcut for locking the Windows desktop.
Disabling the Esc key disables it for all actions.
Example(s)
EnableDisableKeys(0,0,0); // enable all three keys
EnableDisableKeys(1,1,1); // disable all three keys
EnableDisableKeys(0,0,1); // enable Alt and Escape keys, disable Windows key.
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, indic ating success or failure of the
file copy initialization.
42
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
2. FileCopy() function executes the copy procedure in th e background, and InTouc h 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 t he 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 cont aining the value
"Int Tag.Name") or string expression. The values have following meaning:
0 - FileCopy() procedure is still in progress.
1 - FileCopy() procedure has complet ed 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 bec ause another FileCopy() procedure is already in
progress.
-1 - E rror 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:\arc hive and renames the file to
output.txt. The progress of the file copy is written to the integer tag Monit or.
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.
Status=FileCopy("c:\*.txt", "c:\Backup", "Monitor");
This script copies a file whose full pat h 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=FileCopy(LogFile, "c:\results\log" + $DateString + $TimeString + ".txt",
"Monitor");
FileDelete() Function
Delet es an individual file.
Syntax
result = FileDelete (filename)
43
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
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 FileDel et e()
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 delet e 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 ret urns a status result. It can be also used to rename a file.
This function may take a longer time to execut e 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 res ult, indicating success or failure of the file moving
procedure.
Do not use the FileMove() function in asynchronous QuickFunctions.
Syntax
result = FileMove (sourcefile, destfile, progresstag)
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 quot es that will contain a value indicating the file mo ving
progress. A literal string value, message tagname (such as a message tag cont aining the value
"Int Tag") 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
44
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Return Value
A value of-1, 0, or 1 indicating the following:
1 - FileMove() function successfully called
0 - Error when calling the FileMove() function becaus e 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 cs v file into a series of tagnames. You can use this function t o load a set
of tagname values.
Commas are the only supported delimiter.
This function can only be used for synchronous calls.
Syntax
[result = ] FileReadFields (filename, offset, starttag, numberoffields)
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 "My Tag1"), or a string expression.
numberoffields
Number of data items to read from the cs v file. A literal integer value, integer tagname, or integer
expression. The first data item is read into the tagname defined in the starttag paramet er,
subsequent data items into tagnames with the inc remented numeral suffix of the starttag paramet er
(MyTag1, MyTag2, My Tag3, ...).
Return Value
Optional new fil e offset (in byte) after reading the data. This can be used to read the next set of data.
45
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
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);
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 dat a from. A literal string value, a message tagname, or a string
expression.
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 quot es when using the function wit hin 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
Cont ains 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);
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.
46
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
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 "My Tag1". A literal string value, message
tagname (such as a message tagname containing the value "MyTag 1") or a string expression.
numberoffields
Number of data items to write to the cs v 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 (My Tag1, 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:
RecipeTag3 Integer 14
RecipeTag4 Discrete 1
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
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 dat a to. A literal string value, a message t agname, 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. v
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
Cont ains the new byte position after the write. You can use this for subsequent writes to the file.
47
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
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);
GetAccountStatus() Function
Returns the number of days until the user’s password expires.
Category
security
Syntax
Result=GetAccountStatus(Domain, UserID);
Arguments
Domain
Name of the domain or local computer in which the us er account is located.
UserI D
Windows user account name that is part of the loc al computer, workgroup, or domain.
Return Value
This function also returns the following values:
Result Description
-4 Account disabled
Remarks
Use this script function wit h operating system-based security. Do not use this function with the ArchestrA
security mode.
If the GetAccountStatus() function is used with ArchestrA security, the script attempts to retrieve the
account information directly from the domain controller. This works as long as the ArchestrA Galaxy
Repository is using operating system security with the same domain.
Example(s)
Status = GetAccountStatus("Corporate_HQ","Operator");
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 wit h double quotes when
using the function within the Industrial Graphics Editor Script Editor.
48
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
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);
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 .ex e extension. A literal string value, message tagname, or string
expression.
Example(s)
This script returns "Calc ulator"
InfoAppTitle("calc")
This script returns "Microsoft Excel"
InfoAppTitle("excel")
InfoDisk() Function
Returns either the total or free spac e on a local or net work 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.
49
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
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 updat e the
information every minute.
InfoDisk("C", 4, $Minute)
InfoFile() Function
Returns various information on a file or directory.
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 ex pression. Can also include wildcard characters, such as "*" and "?".
infotype
The type of information you want to retrieve ab out 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 ret urns the time stamp as seconds that have passed
since midnight January 1st 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 26th January 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.
50
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
InfoFile("c:\data\*.txt",4,$minute)
InfoInTouchAppDir() Function
Returns the current InTouch application directory.
Syntax
result = InfoInTouchAppDir();
Return Value
A message tagname to cont ain 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:
0- function returns the whole version number
1- function returns just the major version number
2- function returns just the minor version number
3- function returns just the patch level
4- function returns just the build level
Example(s)
InTouchV ersion(1) 10
InTouchV ersion(2) 5
InTouchV ersion(3) 0
51
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
InvisibleVerifyCredentials() Function
The InvisibleVerify Credentials() function can be used in a synchronous QuickScript to verify the
credentials of the given user without logging the user on to the InTouch HMI.
Category
security
Syntax
AnalogTag=InvisibleVerifyCredentials( "UserId", "Password", "Domain" );
Arguments
UserId
Windows operating system user account name that is part of local computer, work group, or domain.
Password
Password for the account.
Domain
The Windows domain for the account.
Remarks
If the supplied combination of user, password, and domain are valid then the corresponding access level
associated with the user is returned as an integer. Otherwise, -1 is returned.
Note: The InvisibleVerifyCredentials() function must be run from a synchronous QuickScript. The
function always returns -1 if run from an asynchronous QuickScript.
This function does not change the currently logged on user. The Domain argument is only valid for
operating system-based security. If ArchestrA security is in use and if ArchestrA security is in turn using
operating system-based security, the UserId argument should contain the fully qualified user name with
domain name or computer name.
Example
AnalogTag=InvisibleVerifyCredentials( "john", "Password", "corporate_hq" );
See Also
PostLogonDialog(), Attempt InvisibleLogon(), IsAssignedRole(), QueryGroupMembership(),
AddPermission()
IsAssignedRole() Function
Determines whether the currently logged on user is a member of the specified user role. Only applies to
ArchestrA security.
Category
security
Syntax
DiscreteTag=IsAssignedRole( "RoleName" );
Arguments
RoleName
The role associated with an Application Server us er.
52
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Remarks
Valid for ArchestrA security mode only and applies to the currently logged on us er. If a user is currently
logged on and has the RoleName role assigned in the Galaxy IDE, then TRUE is returned. Otherwise,
FALSE is returned.
Example
DiscreteTag=IsAssignedRole( "Administrators" );
See Also
AttemptInvisibleLogon(), PostLogonDialog(), InvisibleVerifyCredentials(), QueryGroupMembership(),
AddPermission()
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.
Syntax
LaunchTagViewer()
Remarks
The LaunchTagViewer() function can be ex ecuted from any script type except the application scripts
OnStartup and OnS hutdown.
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.
LogonCurrentUser() Function
Logs on to InTouch with a user account that is currently logged on to the Windows operating system.
InTouch configured with OS security: the user is logged on to WindowViewer.
InTouch configured with Arc hestrA security: the user must be a member of ArchestrA OS user-based
or OS group-based security.
InTouch configured with A rchestrA OS user -based or OS group-based security and the user account
is configured with smart card credentials: user is logged on using the smart card credentials. The
user is logged off if the smart card is removed from the reader.
Category
security
Syntax
IntegerResult = LogonCurrentUser();
Return Value
Returns -1 and no change to the values assigned to $ Operator, $OperatorName, $OperatorDomain, and
$AccessLevel if the logon fails.
Remarks
This function is available only in InTouc h scripting, not in ArchestrA client scripting.
Example
IntegerResult = LogonCurrentUser();
53
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
See Also
PostLogonDialog(), InvisibleVerifyCredentials(), IsAssignedRole(), AttemptInvisibleLogon(),
QueryGroupMembership(), AddPermission()
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"
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);
PostLogonDialog() Function
Shows the InTouch Logon dialog box and returns TRUE.
Category
security
Syntax
DiscreteTag=PostLogonDialog();
Examples
DiscreteTag=PostLogonDialog();
See Also
InvisibleV erifyCredentials(), AttemptInvisibleLogon(), IsAssignedRole(), QueryGroupMembership(),
AddPermission()
PrintScreen() Function
You can write a script to print the entire WindowViewer screen with the PrintScreen() function.
Syntax
PrintScreen (ScreenOption, PrintOption)
54
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
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 )
o 2 - Vertical Fit:
image is stretched so that it fits vertically on the print out 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 m ay
change but the image is not truncated.
o Invalid options, including 0, default to Best Fit.
Note: Popup windows that extend bey ond 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 print out contains the screen area stretched so that it fills the printout dimensions.
PrintScreen(1,4);
QueryGroupMembership() Function
Determines whet her the currently logged on user is a member of the specified user group. Only applies
to operating system security.
Category
security
Syntax
DiscreteTag=QueryGroupMembership( "Domain", "Group" );
Arguments
Domain
Name of the domain or local computer in which the group is located
Group
Name of the group.
Remarks
Valid for operating system security mode only and applies to the currently logged on us er. If a user is
currently logged on and if he or she is part of the group located on the dom ain, then TRUE is returned.
Otherwise, FALSE is returned.
55
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
The QueryGroupMembership() function works with operating system-based security and with ArchestrA
security only when the ArchestrA security is set to operating system-based security.
Examples
DiscreteTag=QueryGroupMembership( "corporate_hq", "InTouchAdmins" );
DiscreteTag=QueryGroupMembership( "JohnS01", "InTouchUsers" );
See Also
PostLogonDialog(), InvisibleVerifyCredentials(), IsAssignedRole(), AttemptInvisibleLogon(),
AddPermission()
ShowHome() Function
Opens the InTouch window(s) you s pecified in the Home Windows tab in the WindowViewer Properties
dialog box and closes any other windows.
Syntax
ShowHome();
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"
SwitchDisplayLanguage() Function
Switches the display of visible, static texts and alarm fields in a desired language for which translated
strings are provided.
Category
misc
Syntax
SwitchDisplayLanguage(LocaleID);
Parameter
LocaleI D
The language in which static text strings and alarm fields are to be shown at run time.
Example(s)
In this example, German is the language to be shown at run time.
SwitchDisplayLanguage(1031);
56
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
See Also
$Language system tag
TseGetClientId() Function
Returns a string version of the client ID (the TCP/IP address of the client) if the View application is
running on a Terminal Server client. This client ID is used internally to generat e SuiteLink server names
and logger file names. Otherwise, the TseGetClientId() function returns an empty string.
Syntax
MessageResult=TseGetClientId();
Example
The client IP address 10.103.202.1 is saved to the MsgTag tag.
MsgTag=TseGetClientID();
TseGetClientNodeName() Function
Returns the client node name if the View application is running on a Terminal Server client assigned a
name that can be identified by Windows. Otherwise, the TseGetClientNodeName() function returns an
empty string.
Syntax
MessageResult=TseGetClientNodeName();
Example
The client node name is returned as the value assigned to the MsgTag tag.
MsgTag=TseGetClientNodeName();
TseQueryRunningOnClient() Function
Returns a non-zero integer value if the View applic ation is running on a Terminal Services client.
Otherwise, it returns a zero.
Syntax
Result=TseQueryRunningOnClient();
Return Value
Returns 0 if View is not running on a Terminal Services client.
Example
Int Tag is set to 1 if WindowViewer is running on a Terminal Services client.
IntTag=TseQueryRunningOnClient;
TseQueryRunningOnConsole() Function
The TseQueryRunningOnConsole() function can be run from a script to indicate whether the View
application is running on a Terminal Services console.
Syntax
Result=TseQueryRunningOnConsole();
Return Value
Returns a non-zero integer value if the View applic ation is running on a Terminal Services console.
Otherwise, the TseQueryRunningOnConsole() function returns a zero.
57
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Example
Int Tag is set to 1 if WindowViewer is running on a Terminal Services console.
IntTag=TseQueryRunningOnConsole();
Math Functions
Use math functions to return the ans wer to the specified mathematical expression.
In QuickScript, all mathematical operations are calculated internally as double, regardless of the operand
data type. Following standard mathematical rules, the res ult is always rounded in division operations to
maintain accuracy. Rounding only occurs on the end result, not intermediate values, and the quotient will
match the target data type. This is the standard methodology for SCA DA and DCS systems, and
provides the data int egrity, precision retention, time stamps, and overall data quality propagation and
aggregation needed for these systems.
If you want to round at each step instead of only at the final result, you can leverage the support built into
QuickScript for . NE T libraries and utilize the System.Math.Floor and System.Math.Round met hods to
explicitly round the intermediat e steps. As an example, consider the following script:
dim dividend as integer;
dim divisor as integer;
dim quotient as integer;
dim remainder as integer;
dividend = 8;
divisor = 3;
LogMessage("Value of dividend = " + dividend);
LogMessage("Value of divisor = " + divisor);
quotient = dividend/divisor;
LogMessage("Value of quotient = " + quotient);
remainder = dividend mod divisor;
LogMessage ("Value of remainder = " + remainder);
dividend = divisor*quotient +remainder;
LogMessage ("Value of dividend = " + dividend);
The result is: 8 / 3 = 3
If, instead, you want to drop t he remainder (not rounding the final result to the nearest integer), you could
add a call to the Mat h.Floor method and use the following:
dim dividend as integer;
dim divisor as integer;
dim quotient as integer;
dim remainder as integer;
dividend = 8;
divisor = 3;
LogMessage("Value of dividend = " + dividend);
LogMessage("Value of divisor = " + divisor);
// *** Add call to Math.Floor. This drops the remainder rat her than rounding the
internal Double result to integer
quotient = System.Math.Floor(dividend/divisor);
58
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Abs()
Returns the absolute value (unsigned equivalent) of a specified number.
Category
Math
Syntax
Result = Abs( Number );
Parameter
Number
Any number or numeric attribut e.
Examples
Abs(14); ' returns 14
Abs(-7.5); ' returns 7.5
ArcCos()
Returns an angle between 0 and 180 degrees whose cosine is equal to the number specified.
Category
Math
Syntax
Result = ArcCos( Number );
Parameter
Number
Any number or numeric attribut e with a value bet ween -1 and 1 (inclusive).
Examples
ArcCos(1); ' returns 0
ArcCos(-1); ' returns 180
See Also
Cos() on page 60, Sin() on page 63, Tan() on page 64, ArcSin() on page 59, ArcTan() on page 60
ArcSin()
Returns an angle between -90 and 90 degrees whose sine is equal to the number specified.
Category
Math
Syntax
Result = ArcSin( Number );
Parameter
Number
Any number or numeric attribut e with a value bet ween -1 and 1 (inclusive).
Examples
ArcSin(1); ' returns 90
ArcSin(-1); ' returns -90
59
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
See Also
Cos() on page 60, Sin() on page 63, Tan() on page 64, ArcCos() on page 59, ArcTan() on page 60
ArcTan()
Returns an angle between -90 and 90 degrees whose tangent is equal to the number specified.
Category
Math
Syntax
Result = ArcTan( Number );
Parameter
Number
Any number or numeric attribut e.
Examples
ArcTan(1); ' returns 45
ArcTan(0); ' returns 0
See Also
Cos() on page 60, Sin() on page 63, Tan() on page 64, ArcCos() on page 59, ArcSin() on page 59
Cos()
Returns the cosine of an angle in degrees.
Category
Math
Syntax
Result = Cos( Number );
Parameter
Number
Any number or numeric attribut e.
Examples
Cos(90); ' returns 0
Cos(0); ' returns 1
This example shows how to use the function in a math equation:
Wave = 50 * Cos(6 * Now().Second);
See Also
Sin() on page 63, Tan() on page 64, ArcCos() on page 59, ArcSin() on page 59, ArcTan() on page 60
Exp()
Returns the result of the ex ponent e raised to a power.
Category
Math
Syntax
Result = Exp( Number );
60
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Parameter
Number
Any number or numeric attribut e.
Example
Exp(1); ' returns 2.718...
Int()
Returns the next integer less than or equal to a specified number.
Category
Math
Syntax
IntegerResult = Int( Number );
Parameter
Number
Any number or numeric attribut e.
Remarks
When handling negative real (float) numbers, this function returns the integer farthest from zero.
Examples
Int(4.7); ' returns 4
Int(-4.7); ' returns -5
Log()
Returns the natural log (base e) of a number.
Category
Math
Syntax
RealResult = Log( Number );
Parameter
Number
Any number or numeric attribut e.
Remarks
Natural log of 0 is undefined.
Examples
Log(100); ' returns 4.605...
Log(1); ' returns 0
See Also
LogN() on page 62, Log10() on page 61
Log10()
Returns the base 10 log of a number.
61
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Category
Math
Syntax
Result = Log10( Number );
Parameter
Number
Any number or numeric attribut e.
Example
Log10(100); ' returns 2
See Also
Log() on page 61, LogN() on page 62
LogN()
Returns the values of the logarithm of x to base n.
Category
Math
Syntax
Result = LogN( Number, Base );
Parameters
Number
Any number or numeric attribut e.
Base
Integer to set log base. You could also specify an integer attribute.
Remarks
Base 1 is undefined.
Examples
LogN(8, 3); ' returns 1.89279
LogN(3, 7); ' returns 0.564
See Also
Log() on page 61, Log10() on page 61
Pi()
Returns the value of Pi.
Category
Math
Syntax
RealResult = Pi();
Example
Pi(); ' returns 3.1415926
62
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Round()
Rounds a real number to a specified precision and returns the result.
Category
Math
Syntax
RealResult = Round( Number, Precision );
Parameters
Number
Any number or numeric attribut e.
Precision
Sets the precision to which the number is rounded. This value can be any number or a numeric
attribute.
Examples
Round(4.3, 1); ' returns 4
Round(4.3, .01); ' returns 4.30
Round(4.5, 1); ' returns 5
Round(-4.5, 1); ' returns -4
Round(106, 5); ' returns 105
Round(43.7, .5); ' returns 43.5
See Also
Trunc () on page 65
Sgn()
Determines the sign of a value (whether it is positive, zero, or negative) and returns the result.
Category
Math
Syntax
IntegerResult = Sgn( Number );
Parameter
Number
Any number or numeric attribut e.
Return Value
If the input number is positive, the result is 1. Negative numbers ret urn a -1, and 0 returns a 0.
Examples
Sgn(425); ' returns 1;
Sgn(0); ' returns 0;
Sgn(-37.3); ' returns -1;
Sin()
Returns the sine of an angle in degrees.
Category
Math
63
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Syntax
Result = Sin( Number );
Parameter
Number
Angle in degrees. Any number or numeric attribute.
Examples
Sin(90); ' returns 1;
Sin(0); ' returns 0;
This example shows how to use the function in a math ex pression:
wave = 100 * Sin (6 * Now().Second);
See Also
Cos() on page 60, Tan() on page 64, ArcCos() on page 59, ArcSin() on page 59, ArcTan() on page 60
Sqrt()
Returns the square root of a number.
Category
Math
Syntax
RealResult = Sqrt( Number );
Parameter
Number
Any number or numeric attribut e.
Example
This example takes the value of me.PV and returns the square root as the value of x:
x=Sqrt(me.PV);
Tan()
Returns the tangent of an angle given in degrees.
Category
Math
Syntax
Result = Tan( Number );
Parameter
Number
The angle in degrees. Any number or numeric attribute.
Examples
Tan(45); ' returns 1;
Tan(0); ' returns 0;
This example shows how to use the function in a math ex pression:
Wave = 10 + 50 * Tan(6 * Now().Second);
See Also
Cos() on page 60, Sin() on page 63, ArcCos() on page 59, ArcSin() on page 59, ArcTan() on page 60
64
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Trunc()
Trunc ates a real (floating point ) number by simply eliminating the portion to the right of the decimal point,
including the decimal point, and ret urns the result.
Category
Math
Syntax
NumericResult = Trunc( Number );
Parameter
Number
Any number or numeric attribut e.
Remarks
This function accomplishes the same result as placing t he contents of a float type attribute into an integer
type attribute.
Examples
Trunc(4.3); ' returns 4;
Trunc(-4.3); ' returns -4;
See Also
Round() on page 63
Miscellaneous Functions
Functions in the miscellaneous group perform a variety of purposes, such as logging data or querying
attributes.
ActivateApp()
Restores, minimizes, maximizes, or closes another currently running Windows application.
Category
Miscellaneous
Syntax
ActivateApp( TaskName );
Parameter
Task Name
The task this function activates.
Remarks
Task Name is the exact text string, including spac es, that appears on the Task Bar or in Windows Task
Manager. You can see the task name by opening Task Manager.
Example
ActivateApp("Calculator");
Filtering Events
To get only specific events, filters can be introduced before getting events from the event service. The
filtering should be done before the StartRequestingE vent () method is called.
The following datatypes are supported when filtering the events.
65
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Integer
Float
String
Bool
DateTime
Double
Short
Array
The following table shows the comparison types that are supported for filtering events.
Compari son
Keyword Description
eq Means EqualTo. Returns all the events matching the filtered criteria.
beginswith Means StartsWith. Returns all the events matching the filtered criteria.
Applies only to string data type filtering
lt Means Lesser Than. Applies to all supported data types excluding string.
It does not support arrays.
le Means Lesser or Equal. Applies to all supported data types excluding
string. It does not support arrays.
gt Means Great er Than. Applies to all supported data types excluding
string. It does not support arrays.
ge Means Great er or Equal. Applies to all supported data types excluding
string. It does not support arrays.
between Checks will be made only to paired supplied values. Returns all the
events matching the filtered criteria. It supports numeric and date data
types.
neg, nbegins, nlt, nle, A keyword 'n' before the comparis on keyword Means NOT of.
ngt, nge, nbetween
DateTimeGMT()
Returns a number representing the number of days and fractions of days since January 1, 1970, in
Coordinated Universal Time (UTC), regardless of the local time zone.
Category
Miscellaneous
Syntax
Result=DateTimeGMT();
Parameters
None
Example
MessageTag = StringFromTime(DateTimeGMT() * 86400.0, 3);
66
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
IsBad()
Returns a Boolean value indicating if the quality of the specified attribute is Bad.
Category
Miscellaneous
Syntax
BooleanResult = IsBad( Attribute1, Attribute2, … );
Parameter(s)
Attribute1, Attribute2, ...AttributeN
Names of one or more attribut es for which you want to determine Bad quality. You can include a
variable-lengt h list of attributes.
Return Value
If any of the specified attributes has Bad quality, then true is returned. Otherwise, false is returned.
Examples
IsBad(TIC101.PV);
IsBad(TIC101.PV, PIC102.PV);
See Also
IsGood() on page 67, IsInitializing() on page 67, IsUncert ain() on page 68, IsUsable() on page 68
IsGood()
Returns a Boolean value indicating if the quality of the specified attribute is Good.
Category
Miscellaneous
Syntax
BooleanResult = IsGood( Attribute1, Attribute2, … );
Parameter(s)
Attribute1, Attribute2, and so on
Name of the attribut e(s) for which you want to determine Good quality. You can include a
variable-lengt h list of attributes.
Return Value
If all of the specified attributes have Good quality, then true is returned. Otherwise, false is returned.
Examples
IsGood(TIC101.PV);
IsGood(TIC101.PV, PIC102.PV);
See Also
IsBad() on page 67, IsInitializing() on page 67, IsUncertain() on page 68, IsUsable() on page 68
IsInitializing()
Returns a Boolean value indicating if the quality of the specified attribute is Initializing.
Category
Miscellaneous
67
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Syntax
BooleanResult = IsInitializing( Attribute1, Attribute2, … );
Parameter(s)
Attribute1, Attribute2, and so on
Name of the attribut e(s) for which to determine Initializing quality. You can include a variable-length
list of attributes.
Return Value
If any of the specified attributes has Initializing quality, then true is returned. Otherwise, false is returned.
Examples
IsInitializing(TIC101.PV);
IsInitializing(TIC101.PV, PIC102.PV);
See Also
IsBad() on page 67, IsGood() on page 67, IsUncertain() on page 68, IsUsable() on page 68
IsUncertain()
Returns a Boolean value indicating if the quality of the specified attribute is Unc ertain.
Category
Miscellaneous
Syntax
BooleanResult = IsUncertain( Attribute1, Attribute2, … );
Parameter(s)
Attribute1, Attribute2, and so on
Name of the attribut e(s) to determine Uncertain quality. You can include a variable-length list of
attributes.
Return Value
If all of the specified attribut es have Uncertain quality, then true is returned. Otherwise, false is returned.
Examples
IsUncertain(TIC101.PV);
IsUncertain(TIC101.PV, PIC102.PV);
See Also
IsBad() on page 67, IsGood() on page 67, IsInitializing() on page 67, IsUsable() on page 68
IsUsable()
Returns a Boolean value indicating if the specified attribute is usable for calculations.
Category
Miscellaneous
Syntax
BooleanResult = IsUsable( Attribute1, Attribute2, … );
Parameter(s)
Attribute1, Attribute2, ...AttributeN
Name of one or more attribut es for which you want to determine unusable quality. You can include a
variable-lengt h list of attributes.
68
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Return Value
If all of the specified attributes have either Good or Uncert ain quality, then true is returned. Otherwise,
false is returned.
Remarks
To qualify as usable, the attribute must have Good or Uncertain quality. In addition, eac h float or double
attribute cannot be a NaN (not a number).
Examples
IsUsable(TIC101.PV);
IsUsable(TIC101.PV, PIC102.PV);
See Also
IsBad() on page 67, IsGood() on page 67, IsInitializing() on page 67, IsUncertain() on page 68
LogCustom()
Writes a user-defined custom flag message in the Log Viewer.
Category
Miscellaneous
Syntax
LogCustom( CustomFlag, msg );
Parameter
CustomFlag
Creates a new log flag based on the first parameter string. The first call creates the custom flag.
msg
The message to writ e to the Log Viewer. Actual string or a string attribute.
Remarks
The log flag is disabled by default.
The message is always logged under the component "ObjectName.ScriptName". For ex ample,
"WinPlatform_001.script1: msg", which identifies what object and what script wit hin the object logged the
error.
LogCustom() is similar to LogMessage(), but displays the message in the custom log flag when Log
Custom is enabled.
The parameter help tooltip and Function Browser sample parameter list will show "LogCustom(
CustomFlag, msg )" rather than "LogCustom( CustomFlag, Message )". "Message" is a reserved
keyword.
Example
LogCustom(EditBox1.text, "User-defined message.";
This statement writes to the Log Viewer as follows:
10/24/2005 12:49:14 PM ScriptRuntime
<ObjectName.ScriptName>: <LogFlag EditBox1> User-defined message.
LogDataChangeEvent()
Logs an application change event to the Galaxy Historian.
Note: The LogDataChangeE vent() function works only in object scripts, not in symbol scripts.
69
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Category
Miscellaneous
Syntax
LogDataChangeEvent(AttributeName, Description, OldValue, NewValue, TimeStamp);
Parameters
AttributeName
Attribute name as a tag name.
Description
Description of the object.
OldValue
Old value of the attribute.
NewValue
New value of the attribute.
TimeStamp
The time stamp associated with the logged event. The timestamp can be UTC or local time. The
TimeStamp parameter is optional. The timestamp of the logged event defaults to Now() if a
TimeStamp parameter is not included.
Remarks
A symbol script still compiles if the LogDat aChangeE vent() function is included. However, a warning
message is written to the log at run time that the function is inoperable.
Example
This example logs an event when a pump starts or stops with a timestamp of the current time when the
event occurred.
LogDataChangeEvent(TC104.pumpstate, "Pump04", OldState, NewState);
LogError()
Writes a user-defined error message in the Log Viewer with a red error log flag.
Category
Miscellaneous
Syntax
LogError( msg );
Parameter
msg
The message to writ e to the Log Viewer. Actual string or a string attribute.
Remarks
The log flag is enabled by default.
The message is always logged under the component "ObjectName.ScriptName". For ex ample,
"WinPlatform_001.script1: msg", which identifies what object and what script wit hin the object logged the
error.
LogE rror() is similar to LogMessage(), but displays the message in red.
The parameter help tooltip and Function Browser sample parameter list will show "LogE rror( msg )"
rather than "LogE rror( Message )". "Message" is a reserved keyword.
70
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Example
LogError("User-defined error message.");
This statement writes to the Log Viewer as follows:
10/24/2005 12:49:14 PM ScriptRuntime
<ObjectName.ScriptName>: User-defined error message.
LogMessage()
Writes a user-defined message to the Log Viewer.
Category
Miscellaneous
Syntax
LogMessage( msg );
Parameter
msg
The message to writ e to the Log Viewer. Actual string or a string attribute.
Remarks
This is a very powerful function for troubleshooting scripting. By strategically placing LogMessage()
functions in your scripts, you can determine the order of script execution, performance of scripts, and
identify the value of attributes both before they are changed and after they are affected by the script.
Each message posted to the Log Viewer is stamped with the exact date and time. The message always
begins with the component "Tagname.ScriptName" so you can tell what object and what script within the
object posted the message to the log.
Examples
LogMessage("Report Script is Running");
The above statement writes the following to the Log Viewer:
10/24/2005 12:49:14 PM ScriptRuntime <Tagname.ScriptName>:Report Script is
Running.
MyTag=MyTag + 10;
LogMessage("The Value of MyTag is " + Text(MyTag, "#"));
LogTrace()
Writes a user-defined trace message in the Log Vie wer.
Category
Miscellaneous
Syntax
LogTrace( msg );
Parameter
msg
The message to writ e to the Log Viewer. Actual string or a string attribute.
Remarks
The log flag is disabled by default.
The message is always logged under the component "ObjectName.ScriptName". For ex ample,
"WinPlatform_001.script1: msg", which identifies what object and what script wit hin the object logged the
error.
71
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
LogTrace() is similar to LogMessage(), but displays the message as Trace when Log Trac e is enabled.
The parameter help tooltip and Function Browser sample parameter list will show "LogTrace( msg )"
rather than "LogTrace( Message )". "Message" is a reserved keyword.
Example
LogTrace("User-defined trace message.");
This statement writes to the Log Viewer as follows:
10/24/2005 12:49:14 PM ScriptRuntime
<ObjectName.ScriptName>: User-defined trace message.
LogWarning()
Writes a user-defined error message in the Log Viewer with a yellow warning log flag.
Category
Miscellaneous
Syntax
LogWarning( msg );
Parameter
msg
The message to writ e to the Log Viewer. Actual string or a string attribute.
Remarks
The log flag is disabled by default.
The message is always logged under the component "ObjectName.ScriptName". For ex ample,
"WinPlatform_001.script1: msg", which identifies what object and what script wit hin the object logged the
error.
LogWarning() is similar to LogMessage(), but displays the message as a yellow warning message.
The parameter help tooltip and Function Browser sample parameter list will show "LogWarning( msg )"
rather than "LogWarning( Message )". "Message" is a reserved keyword.
Example
LogWarning("User-defined warning message.")
This statement writes to the Log Viewer as follows:
10/24/2005 12:49:14 PM ScriptRuntime
<ObjectName.ScriptName>: User-defined warning message.
SendKeys()
Sends keystrokes to an application. To the receiving application, the keys appear to be entered from the
keyboard. You can use SendK eys() within a script to enter data or send commands to an application.
Most keyboard keys can be used in a SendKeys() statement. Each key is represented by one or more
characters, such as A for the letter A or {E NTE R} for the Enter key.
Category
Miscellaneous
Syntax
SendKeys( KeySequence );
Parameter
KeySequence
Any key sequence or a string attribute.
72
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Remarks
To specify more than one key, concatenate the codes for eac h character. For example, to specify the
dollar sign ($) key followed by a (b), enter $b.
The following lists the valid send key codes for unique keyboard keys:
Key Code
BREAK {BREAK}
CAPSLOCK {CAPSLOCK }
DOWN {DOW N}
END {END}
F1...F12 {F1}...{F12}
HOME {HOME}
INSE RT {INSERT}
LEFT {LEFT}
NUMLOCK {NUMLOCK }
PAGE UP {PGUP }
PRTSC {PRTS C}
RIGHT {RIGHT}
TAB {TAB}
UP {UP}
HOME {HOME}
Special keys (SHIFT, CTRL, and A LT) have their own key codes:
Key Code
SHIFT + (plus)
CTRL ^ (caret )
ALT % (percent)
73
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Enhancements to the Microsoft Hardware Abstraction Layer in Windows prevents the SendKeys()
function from operating on some computers.
Examples
To use two special keys together, use a second set of parentheses. The following statement holds down
the CTRL key while pressing the ALT key, followed by p:
SendKeys ("^(%(p))");
Commands can be preceded by the ActivateApp() command to direct the keystrokes to the proper
application.
The following statement gives the computer focus to Calc ulator and sends the key combination 1234:
ActivateApp("Calculator");
SendKeys("^(1234)");
SetAttributeVT()
Sets the value and timestamp of an object attribute. For buffered values, only the last calculated value is
captured for historization.
Category
Miscellaneous
Syntax
SetAttributeVT( Attribute, Value, TimeStamp);
Parameter
Attribute
Name of the object attribute whose value and timestamp are modified. The specified attribute must
belong to the object to which the script is attached.
Value
Value of the attribute, which can be a referenc e. The quality is always set to Good.
TimeStamp
Timestamp that can be a reference, a variable, or a string interpreted as the computer’s local time or
UTC. The timestamp is converted internally to UTC format before the attribute’s value is sent to the
run-time component.
Remarks
Interim calculated buffered values are NOT historized. Use SetAttributeV T2() if historization of interim
values is needed.
Timestamp can be set only for object attributes that support a timestamp. At compile time, the script
cannot detect whether the attribute specified with the SetAttributeV T() function supports a timestamp or
not. No warning is issued if the attribut e does not support a timestamp.
Example
This example sets an integer value and timestamp for an attribute that indicates pump RPM.
SetAttributeVT(me.PV, TC104.PumpRPM, LCLTIME);
SetAttributeVT2()
Sets the value and timestamp of an object attribute. This function is identical to SetAttributeV T(), but
SetAttributeV T2() allows interim calculated data for buffered values to be historized once per scan cycle.
Category
Miscellaneous
74
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Syntax
SetAttributeVT2( Attribute, Value, TimeStamp);
Parameter
Attribute
Name of the object attribute whose value and timestamp are modified. The specified attribute must
belong to the object to which the script is attached.
Value
Value of the attribute, which can be a referenc e. The quality is always set to Good.
TimeStamp
Timestamp that can be a reference, a variable, or a string interpreted as the computer’s local time or
UTC. The timestamp is converted internally to UTC format before the attribute’s value is sent to the
run-time component.
Remarks
In contrast to SetAttributeV T(), SetAttribut eV T2() allows historization of int erim calculated buffered
values.
Timestamp can be set only for object attributes that support a timestamp. At compile time, the script
cannot detect whether the attribute s pecified with the SetAttribut eV T2() function supports a timestamp or
not. No warning is issued if the attribut e does not support a timestamp.
Example
This example sets an integer value and timestamp for an attribute that indicates pump RPM (interim
calculated values for buffered data are historized).
SetAttributeVT2(me.PV, TC104.PumpRPM, LCLTIME);
SetBad()
Sets the quality of an attribute to Bad.
Category
Miscellaneous
Syntax
SetBad( Attribute );
Parameter
Attribute
The attribute for which you want to set the quality to Bad.
Remarks
The specified attribute must be within the object to which the script is attached.
Example
SetBad(me.PV);
See Also
SetGood() on page 75, SetInitializing() on page 76, SetUncert ain() on page 76
SetGood()
Sets the quality of an attribute to Good.
75
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Category
Miscellaneous
Syntax
SetGood( Attribute );
Parameter
Attribute
The attribute for which you want to set the quality to Good.
Remarks
The specified attribute must be within the object to which the script is attached.
Example
SetGood(me.PV);
See Also
SetBad() on page 75, SetInitializing() on page 76, Set Uncert ain() on page 76
SetInitializing()
Sets the quality of an attribute to Initializing.
Category
Miscellaneous
Syntax
SetInitializing( Attribute );
Parameter
Attribute
The attribute for which you want to set the quality to Initializing.
Remarks
The specified attribute must be within the object to which the script is attached.
Example
SetInitializing(me.PV);
See Also
SetBad() on page 75, SetGood() on page 75, SetUncertain() on page 76
SetUncertain()
Sets the quality of an attribute to Uncertain.
Category
Miscellaneous
Syntax
SetUncertain( Attribute );
Parameter
Attribute
The attribute for which you want to set the quality to Uncertain.
76
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Remarks
The specified attribute must be within the object to which the script is attached.
Example
SetUncertain(me.PV);
See Also
SetBad() on page 75, SetGood() on page 75, SetInitializing() on page 76
SignedAlarmAck()
Acknowledges one or more alarms on ArchestrA attributes, optionally requiring a signature if any of the
indicated alarms falls within a designated priority range.
This function is support ed only for client scripting and not object scripting.
Category
Miscellaneous
Syntax
int SignedAlarmAck(String Alarm_List,
Boolean Signature_Reqd_for_Range,
Integer Min_Priority,
Integer Max_Priority,
String Default_Ack_Comment,
Boolean Ack_Comment_Is_Editable,
String TitleBar_Caption,
String Message_Caption
);
Parameters
Alarm_List
The list of alarms to be acknowledged. The list must be a single text string with each alarm name
separated by a spac e or a comma.
Data Type
String
Valid Range
Limit 1024 characters
Additional Information
Can be a constant string, a reference, or an ex pression.
Only alarms on ArchestrA attributes are supported.
If there is any invalid alarm in the list, then none of the alarms are acknowledged.
Examples
Example 1:
"UD1.analog_001.HiHi"
The collection is repres ented as a text string, with alarms separated by blanks and/or commas.
Example 2:
"UD1.analog_001.HiHi UD9.x14.dev.major"
Example 3:
"UD1.analog_001.HiHi, UD9.x14.dev.major"
Example 4, an array of strings such as:
Pump1.AlarmArray[1] = "Pump1.Level.HiHi"
77
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Pump1.AlarmArray[2] = "Pump1.Level.LoLo"
uses the function as follows:
SignedAlarmAck(Pump1.AlarmArray[ ], ...)
The script passes to the function the following single string:
"Pump1.Level.HiHi, Pump1.Level.LoLo"
Signature_Reqd_for_Range
Indicates whether a signature is required for acknowledging alarms.
Data Type
Bool
Additional Information
Can be a constant, a reference, or an expression.
Min_Priority
Represents the minimum priority value of the range for which the signat ure is required.
Data Type
Integer
Valid Range
1-999; must be less than or equal to the Max_P riority value.
Additional Information
Can be a constant, a reference, or an expression.
Max_Priority
Represents the maximum priority value of the range for which the signature is required.
Data Type
Integer
Valid Range
1-999; must be great er than or equal to the Min_P riority value.
Additional Information
Can be a constant, a reference, or an expression.
Default_Ack _Comment
Comment to be shown in the Acknowledge Alarms dialog box.
Data Type
String
Valid Range
Limit 200 characters
Additional Information
Can be a constant, a reference or an expression.
If the parameter is empty, then no default comment is shown in the Acknowledge Alarms dialog
box.
Ack _Comment_Is_ Editable
Indicates whether the run-time user can modify the acknowledgement comment.
Data Type
Bool
Additional Information
Can be a constant, a reference, or an expression.
If set to False, the Comment box in the Acknowledge Alarms dialog box is unavailable.
78
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
TitleBar_Caption
Shows a title in the title bar of the Acknowledge Alarms dialog box.
Data Type
String
Valid Range
Limi 1024 characters
Additional Information
Can be a constant, a reference, or an expression.
If the TitleBar_Caption is empty, the default title, Acknowledge Alarms, is shown.
Message_Caption
Shows a customizable message to the run-time user in the Acknowledge Alarms dialog box.
Data Type
String
Valid Range
Limit 250 characters
Additional Information
Can be a constant, a reference, or an expression.
Use the parameter to provide more information on the alarm to the run-time user.
This message is not propagated to the event record.
Return Values
Return values indicate success or failure status. A non -zero value indicates type of failure.
79
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Note: A return value of zero does not indicate if the alarms are acknowledged, only that the function
wrot e to the AckMsg attributes. The alarms may not be acknowledged due to insufficient permission or if
the alarms have already been acknowledged.
Remarks
For more information about using the SignedAlarmAck() function, see the topic Signature Security for
Ack nowledging Alarms, under "Adding and Maintaining Symbol Scripts" in the Creating and Managing
Industrial Graphics User Guide.
Examples
Dim n as Integer;
n = SignedAlarmAck("UD1.analog_001.HiHi UD9.x14.dev.major", true, 1, 250,
"Acknowledged by script", true, "Acking Tank Alarms", "Acknowledge the tank
alarms");
Using an array of strings:
dim arr[2] as String;
arr[1] = "UD1.analog_001.HiHi";
arr[2] = "UD9.x14.dev.major";
n = SignedAlarmAck(arr[], true, 200, 500, "Acked by script", true, "Acking
Tank Alarms", "Please acknowledge the tank alarms.");
SignedWrite()
Performs a write to an A utomationObject attribute that has a Secured Write or Verified Write security
classification.
Category
Miscellaneous
Syntax
int SignedWrite(string Attribute,
object Value,
string ReasonDescription,
Bool Comment_Is_Editable,
80
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Enum Comment_Enforcement,
string[] Predefined_Comment_List
);
Brackets [ ] indicate an array.
Parameters
Attribute
The attribute to be updated.
Data Type
String
Additional Information
Can be a constant string, a reference, or an ex pression.
Supports bound and nested bound references.
For detailed examples of Attribute paramet er uses, see the topic Examples of Using the Attribute
Parameter in the SignedWrite() Function under "Managing Symbols" in the Creating and Managing
Industrial Graphics User Guide.
Examples
Example 1:
"UserDefined_001.temp"
Example 2:
"Pump15" + ".valve4"
Example 3:
With UDO_7 containing two string attributes, namestrA and namestrB set to the values "Tank1" and
"Tank5" respectively, the following script writes to Tank1. Level or Tank5.Level according to whet her
strselect is "A" or "B":
Dim strselect As String;
Dim x As Indirect;
{ logic to set strselect to "A" or "B" }
x.BindTo ("UDO_7.namestr" + strselect);
SignedWrite(x + ".Level", 243, "Set " + x + " Level", true, 0, null);
Value
The value to be written.
Data Type
Object
Valid Range
Must match data type of the attribut e being updated.
Additional Information
Can be a constant value, a reference, an expression, or NULL if nothing is to be ent ered.
Reas onDescription
Text that explains the purpose of the target attribut e and the impact of changing it.
Data Type
String
Valid Range
Maximum of 256 characters.
Additional Information
Can be a constant string, a reference, or an ex pression.
81
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
The ReasonDescription is passed to the indicated Attribute as part of the write operation. The object
also includes the us er’s writ e comment, if any. A Field Attribute description is used for the
Reas onDescription parameter only if the attribute is a Field Attribute and it has a description (is not
null). Otherwise, the Short Description for the corresponding ApplicationObject is used for the
Reas onDescription parameter.
Comment_is _Editable
Indicates whether user can edit the write comment.
Data Type
Bool
Additional Information
Can be a constant value, a reference, or an expression.
If set to True: The comment text box is enabled with exceptions. If Comment_Is_Editable is true and
if the Comment_ E nforcement parameter is PredefinedOnly, the comment text box is disabled. At run
time, the user can only select a comment from the predefined comment list.
If the Comment _ Enforcement parameter is not PredefinedOnly, the comment list and box are
enabled. You can select a comment from the comment list and modify it in the comment box.
If the predefined list is empty, the comment list is not shown in the dialog box.
If set to False: The predefined comment list does not appear in the Secured Write or Verified Write
dialog boxes. The editable comment text box is disabled.
Comment_E nforcement
Cont ains choices of Optional, Mandatory and PredefinedOnly.
Data Type
Enum
Enumerations
Optional = 0
The run-time user can enter a comment or leave it blank.
Mandatory = 1
The run-time user must add a comment, either by selecting from the comment list or by entering a
comment in the comment box.
PredefinedOnly = 2
The run-time user can select a comment from the comment list only. The comment text box is
disabled.
Additional Information
Can be a constant, a reference, or an expression.
Predefined_Comment_List
An array of strings that can be used as predefined comments.
Data Type
String[]
Valid Range
Maximum of 20 comments, each with a maximum of 200 characters.
Additional Information
The array can be empty (number of elements is 0).
Can be a constant, a reference, an expression, or NULL if empty. Can reference an attribut e that
contains an array of strings.
If no predefined comment is entered, the predefined comment list is disabled at run time.
If Comment_Is_Editable is False, the predefined comment is still placed in the editable comment text
box, but the user cannot modify it at run time.
Return Values
Return values indicate success or failure status. A non-zero value indicates type of failure.
82
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
83
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
If you configure the custom property CP as shown in the following script, the function attempts to resolve
CP and determine if it has a reference. If it has a reference, then the reference is retrieved and the write
is performed on the reference.
SignedWrite("CP", value, reason, editable, enforcement, null);
For more information about using the SignedWrite() function, see the topic Work ing wit h the
SignedWrite() Function for Secured and Verified Writes under "Managing Symbols" in the Creating and
Managing Industrial Graphics User Guide.
Examples
SignedWrite ("UserDefined_001.temp", 185, "This will change the oven
temperature", true, 1, null);
The following example shows the user an array of predefined comments:
Dim n as Integer;
n = SignedWrite("UserDefined_001.temp", 185, "This will change the oven
temperature", true, 1, UserDefined_001.OvenCommentArray[ ]);
where UserDefined_001.OvenCommentArray is an attribute containing an array of strings.
WriteStatus()
Returns the enumerated write status of the last write to the specified attribute.
Category
Miscellaneous
Syntax
Result = WriteStatus( Attribute );
Parameter
Attribute
The attribute for which you want to ret urn write status.
Return Value
The return statuses are:
MxStatusOk
MxStatusPending
MxStatusWarning
MxStatusCommunicationE rror
MxStatusConfigurationError
MxStatusOperationalError
MxStatusSecurityError
MxStatusSoftwareE rror
MxStatusOtherError
Remarks
If the attribut e has never been written to, this function returns MxStatusOk. This function always returns
MxStatusOk for attributes that do not support a calculated (non-Good) quality.
Example
WriteStatus(TIC101.SP);
84
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
WWControl()
Restores, minimizes, maximizes, or closes an application.
Category
Miscellaneous
Syntax
WWControl( AppTitle, ControlType );
Parameters
AppTitle
The name of the application title to be controlled. Actual string or a string attribute.
Cont rolType
Determines how the application is controlled. Possible values are shown below. These actions are
identical to clicking on their corresponding selections in the application's Control Menu. Actual string
or a string attribute.
"Restore" = Activates and shows the application's window.
"Minimize" = Activates a window and shows it as an icon.
"Maximize" = Activates and shows the application's window.
"Close" = Closes an application.
Example
WWControl("Calculator","Restore");
See Also
ActivateApp() on page 65
String Functions
Use string functions to work with character strings and string values.
DText()
Returns one of two possible strings, depending on the value of the Discrete paramet er.
Category
String
Syntax
StringResult = DText( Discrete, OnMsg, OffMsg );
Parameters
Discrete
A Boolean value or Boolean attribute.
OnMsg
The message that is shown when the value of Discrete equals true.
OffMsg
The message shown when Discrete equals false.
Example
StringResult = DText(me.temp > 150, "Too hot", "Just right");
85
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
StringASCII()
Returns the ASCII value of the first character in a specified string.
Category
String
Syntax
IntegerResult = StringASCII( Char );
Parameter
Char
Alphanumeric character or string or string attribut e.
Remarks
When this function is processed, only the single character is tested or affected. If the string provided to
StringASCII contains more than one character, only the first character of the string is tested.
Examples
StringASCII("A"); ' returns 65;
StringASCII("A Mixer is Running"); ' returns 65;
StringASCII("a mixer is running"); ' returns 97;
See Also
StringChar() on page 86, StringFromIntg() on page 89, StringFromReal() on page 89, StringFromTime()
on page 90, StringInString() on page 92, StringLeft() on page 92, StringLen() on page 93, StringLower()
on page 93, StringMid() on page 94, StringReplace() on page 94, StringRight() on page 95,
StringSpace() on page 96, StringTest() on page 97, StringToI ntg() on page 97, StringToReal() on page
98, StringTrim() on page 99, StringUpper() on page 99, Text() on page 100
StringChar()
Returns the character corresponding to a specified ASCII code.
Category
String
Syntax
StringResult = StringChar( ASCII );
Parameter
ASCII
ASCII code or an integer attribute.
Remarks
Use the StringChar function to add ASCII characters not normally represented on the keyboard to a
string attribut e.
This function is also useful for SQL commands. The where expression sometimes requires double
quotation marks around string values, so use StringChar(34).
Example
In this example, a [ Carriage Return (13)] and [Line Feed (10)] are added to the end of St ringAttribute and
passed to ControlString. Inserting characters out of the normal 32 -126 range of displayable ASCII
characters can be very useful for creating control codes for external devices such as print ers or modems.
ControlString = StringAttribute+StringChar(13)+StringChar(10);
86
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
StringCompare()
Compares a string value with another string.
Category
String
Syntax
StringCompare( Text1, Text2 );
Parameters
Text1
First string in the comparison.
Text2
Second string in the comparison.
Return Value
The return value is zero if the strings are identical, -1 if Text1’s value is less than Text2, or 1 if Text1’s
value is greater than Text2.
Example
Result = StringCompare ("Text1","Text2"); (or)
Result = StringCompare (MText1,MText2);
Where Result is an Integer or Real tag and MText1 and MText2 are Memory Message
tags.
See Also
StringASCII() on page 86, StringChar() on page 86, StringFromIntg() on page 89, StringFromReal() on
page 89, StringFromTime() on page 90, StringFromTimeLocal() on page 91, StringInString() on page 92,
StringLeft() on page 92, StringLen() on page 93, StringLower() on page 93, StringMid() on page 94,
StringReplace() on page 94, StringRight() on page 95, StringSpace() on page 96, StringTest() on page
97, StringToIntg() on page 97, StringToReal() on page 98, StringTrim() on page 99, StringUpper() on
page 99, Text() on page 100
StringCompareNoCase()
Compares a string value with another string and ignores the case.
Category
String
Syntax
SStringCompareNoCase( Text1, Text2 );
Parameters
Text1
First string in the comparison.
Text2
Second string in the comparison.
Return Value
The return value is zero if the strings are identical (ignoring case), -1 if Text1’s value is less than Text2
(ignoring case), or 1 if Text1’s value is greater than Text2 (ignoring case).
Example
Result = StringCompareNoCase ("Text1","TEXT1"); (or)
87
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
StringFromGMTTimeToLocal()
Converts a time value (in seconds since Jan-01-1970) to a particular string representation. This is the
same as StringFromTime().
Category
String
Syntax
MessageResult=StringFromGMTTimeToLocal(SecsSince1-1-70,StringType);
Parameters
SecsSince1-1-70
Is converted to the StringTy pe specified and the result is stored in MessageResult.
StringType
Determines the display method:
1 = Displays the date in the same format set from the windows control Panel. (Similar to that
displayed for $DateString.)
2 = Displays the time in the same format set from the Windows control Panel. (Similar to that
displayed for $TimeString.)
3 = Displays a 24-character string indicating both the date and time: "Wed Jan 02 02: 03:55 1993"
4 = Displays the short form for the day of the week: "Wed"
5 = Displays the long form for the day of the week: "Wednesday"
Remarks
Any adjustments necessary due to Daylight Savings Time are automatically applied to the return result.
Therefore, it is not necessary to make any manual adjustments to the input value to convert to DS T.
Example
This example assumes that the time zone on the local node is Pacific Standard Time (UTC-0800). The
UTC time passed to the function is 12:00: 00 AM on Friday, 1/2/1970. Since PST is 8 hours behind UTC,
the function will return the following results:
StringFromGMTTimeToLocal(86400, 1); ' returns "1/1/1970"
StringFromGMTTimeToLocal(86400, 2); ' returns "04:00:00 PM"
StringFromGMTTimeToLocal(86400, 3); ' returns "Thu Jan 01 16:00:00 1970"
StringFromGMTTimeToLocal(86400, 4); ' returns "Thu"
StringFromGMTTimeToLocal(86400, 5); ' returns "Thursday"
88
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
See Also
StringASCII() on page 86, StringChar() on page 86, StringFromIntg() on page 89, StringFromReal() on
page 89, StringFromTime() on page 90, StringFromTimeLocal() on page 91, StringInString() on page 92,
StringLeft() on page 92, StringLen() on page 93, StringLower() on page 93, StringMid() on page 94,
StringReplace() on page 94, StringRight() on page 95, StringSpace() on page 96, StringTest() on page
97, StringToIntg() on page 97, StringToReal() on page 98, StringTrim() on page 99, StringUpper() on
page 99, Text() on page 100
StringFromIntg()
Converts an integer value into its string repres entation in another base and returns the result.
Category
String
Syntax
SringResult = StringFromIntg( Number, numberBase );
Parameters
Number
Number to convert. Any number or an integer attribut e.
numberB ase
Base to use in conversion. Any number or an integer attribut e.
Examples
StringFromIntg(26, 2); ' returns "11010"
StringFromIntg(26, 8); ' returns "32"
StringFromIntg(26, 16); ' returns "1A"
See Also
StringASCII() on page 86, StringChar() on page 86, StringFromReal() on page 89, StringFromTime() on
page 90, StringInString() on page 92, StringLeft() on page 92, StringLen() on page 93, StringLower() on
page 93, StringMid() on page 94, StringReplac e() on page 94, StringRight() on page 95, StringSpace()
on page 96, StringTest() on page 97, StringToIntg() on page 97, StringToReal() on page 98, StringTrim()
on page 99, StringUpper() on page 99, Text () on page 100
StringFromReal()
Converts a real value into its string repres entation, either as a floating-point number or in exponential
notation, and returns the result.
Category
String
Syntax
StringResult = StringFromReal( Number, Precision, Type );
Parameters
Number
Converted to the Precision and Type specified. Any number or a float attribute.
Precision
Specifies how many decimal places is shown. Any number or an integer attribute.
Type
A string value that determines the display method. Possible values are:
f = Display in floating-point notation.
89
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
StringFromTime()
Converts a time value (in seconds since January 1, 1970) into a particular string representation and
returns the result.
Category
String
Syntax
StringResult = StringFromTime( SecsSince1-1-70, StringType );
Parameters
SecsSince1-1-70
Converted to the StringType specified.
StringType
Determines the display method. Possible values are:
1 = Shows the dat e in the same format set from the Windows Control Panel.
2 = Shows the time in the same format set from the Windows Control Panel.
3 = Shows a 24-character string indicating both the date and time: "Wed Jan 02 02:03:55 1993"
4 = Shows the short form for a day of the week: "Wed"
5 = Shows the long form for a day of the week: "Wednesday"
Remarks
The time value is UTC equivalent: number of elapsed seconds since January 1, 1970 GMT. The value
returned reflects the local time.
Examples
StringFromTime(86400, 1); ' returns "1/2/1970"
StringFromTime(86400, 2); ' returns "12:00:00 AM"
StringFromTime(86400, 3); ' returns "Fri Jan 02 00:00:00 1970"
StringFromTime(86400, 4); ' returns "Fri"
StringFromTime(86400, 5); ' returns "Friday"
90
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
See Also
StringASCII() on page 86, StringChar() on page 86, StringFromIntg() on page 89, StringFromReal() on
page 89, StringFromTime() on page 90, StringInString() on page 92, StringLeft() on page 92, StringLen()
on page 93, StringLower() on page 93, StringMid() on page 94, StringReplace() on page 94,
StringRight() on page 95, StringSpac e() on page 96, StringTest() on page 97, StringToIntg() on page 97,
StringToReal() on page 98, StringTrim() on page 99, StringUpper() on page 99, Text() on page 100
StringFromTimeLocal()
Converts a time value (in seconds since Jan-01-1970) into a particular string represent ation. The value
returned also represents local time.
Category
String
Syntax
MessageResult=StringFromTimeLocal(SecsSince1-1-70,
StringType);
Parameters
SecsSince1-1-70
Is converted to the StringTy pe specified and the result is stored in MessageResult.
StringType
Determines the display method:
1 = Displays the date in the same format set from the windows control Panel. (Similar to that
displayed for $DateString.)
2 = Displays the time in the same format set from the Windows control Panel. (Similar to that
displayed for $TimeString.)
3 = Displays a 24-character string indicating both the date and time: "Wed Jan 02 02: 03:55 1993"
4 = Displays the short form for the day of the week: "Wed"
5 = Displays the long form for the day of the week: "Wednesday"
Remarks
Any adjustments necessary due to Daylight Savings Time will automatically be applied to the return
result. Therefore, it is not necessary to make any manual adjus tments for DS T to the input value.
Example
StringFromTimeLocal (86400, 1); ' returns "1/2/1970"
StringFromTimeLocal (86400, 2); ' returns "12:00:00 AM"
StringFromTimeLocal (86400, 3); ' returns "Fri Jan 02 00:00:00 1970"
StringFromTimeLocal (86400, 4); ' returns "Fri"
StringFromTimeLocal (86400, 5); ' returns "Friday"
See Also
StringASCII() on page 86, StringChar() on page 86, StringFromIntg() on page 89, StringFromReal() on
page 89, StringFromTime() on page 90, StringInString() on page 92, StringLeft() on page 92, StringLen()
on page 93, StringLower() on page 93, StringMid() on page 94, StringReplace() on page 94,
StringRight() on page 95, StringSpac e() on page 96, StringTest() on page 97, StringToIntg() on page 97,
StringToReal() on page 98, StringTrim() on page 99, StringUpper() on page 99, Text() on page 100
91
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
StringInString()
Returns the position in a string of text where a specified string first occurs.
Category
String
Syntax
IntegerResult = StringInString( Text, SearchFor, StartPos, CaseSens );
Parameters
Text
The string that is searched. Actual string or a string attribute.
SearchFor
The string to be searched for. Actual string or a string attribute.
StartPos
Determines the position in the text where the search begins. Any number or an integer attribut e.
CaseSens
Determines whet her the search is case-sensitive.
0 = Not case-sensitive
1 = Case-sensitive
Any number or an integer attribute.
Remarks
If multiple occurrences of SearchFor are found, the location of the first is returned.
Examples
StringInString("The mixer is running", "mix", 1, 0) ' returns 5;
StringInString("Today is Thursday", "day", 1, 0) ' returns 3;
StringInString("Today is Thursday", "day", 10, 0) ' returns 15;
StringInString("Today is Veteran's Day", "Day", 1, 1) ' returns 20;
StringInString("Today is Veteran's Day", "Night", 1, 1) ' returns 0;
See Also
StringASCII() on page 86, StringChar() on page 86, StringFromIntg() on page 89, StringFromReal() on
page 89, StringFromTime() on page 90, StringLeft() on page 92, StringLen() on page 93, StringLower()
on page 93, StringMid() on page 94, StringReplace() on page 94, StringRight() on page 95,
StringSpace() on page 96, StringTest() on page 97, StringToI ntg() on page 97, StringToReal() on page
98, StringTrim() on page 99, StringUpper() on page 99, Text() on page 100
StringLeft()
Returns a specified number of characters in a string value, starting with the leftmost string character.
Category
String
Syntax
StringResult = StringLeft( Text, Chars );
Parameters
Text
Actual string or a string attribute.
Chars
Number of characters to return or an integer attribute.
92
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Remarks
If Chars is set to 0, the entire string is returned.
Examples
StringLeft("The Control Pump is On", 3) ' returns "The";
StringLeft("Pump 01 is On", 4) ' returns "Pump";
StringLeft("Pump 01 is On", 96) ' returns "Pump 01 is On";
StringLeft("The Control Pump is On", 0) ' returns "The Control Pump is On";
See Also
StringASCII() on page 86, StringChar() on page 86, StringFromIntg() on page 89, StringFromReal() on
page 89, StringFromTime() on page 90, StringInString() on page 92, StringLen() on page 93,
StringLower() on page 93, StringMid() on page 94, StringReplace() on page 94, StringRight() on page
95, StringSpace() on page 96, StringTest() on page 97, StringToIntg() on page 97, StringToReal() on
page 98, StringTrim() on page 99, StringUpper() on page 99, Text() on page 100
StringLen()
Returns the number of characters in a string.
Category
String
Syntax
IntegerResult = StringLen( Text );
Parameter
Text
Actual string or a string attribute.
Remarks
All the characters in the string attribute are counted, including blank spaces and those not normally
shown on the screen.
Examples
StringLen("Twelve percent") ' returns 14;
StringLen("12%") ' returns 3;
StringLen("The end." + StringChar(13)) ' returns 9;
The carriage ret urn character is ASCII 13.
See Also
StringASCII() on page 86, StringChar() on page 86, StringFromIntg() on page 89, StringFromReal() on
page 89, StringFromTime() on page 90, StringInString() on page 92, StringLeft() on page 92,
StringLower() on page 93, StringMid() on page 94, StringReplace() on page 94, StringRight() on page
95, StringSpace() on page 96, StringTest() on page 97, StringToIntg() on page 97, StringToReal() on
page 98, StringTrim() on page 99, StringUpper() on page 99, Text() on page 100
StringLower()
Converts all uppercase characters in text string to lowerc ase and returns the result.
Category
String
Syntax
StringResult = StringLower( Text );
93
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Parameter
Text
String to be converted to lowercase. Actual string or a string attribute.
Remarks
Lowercas e characters, symbols, numbers, and other special characters are not affected.
Examples
StringLower("TURBINE") ' returns "turbine";
StringLower("22.2 Is The Value") ' returns "22.2 is the value";
See Also
StringASCII() on page 86, StringChar() on page 86, StringFromIntg() on page 89, StringFromReal() on
page 89, StringFromTime() on page 90, StringInString() on page 92, StringLeft() on page 92, StringLen()
on page 93, StringMid() on page 94, StringReplace() on page 94, StringRight() on page 95,
StringSpace() on page 96, StringTest() on page 97, StringToI ntg() on page 97, StringToReal() on page
98, StringTrim() on page 99, StringUpper() on page 99, Text() on page 100
StringMid()
Extracts a specific number of characters from a starting point within a string and returns the extracted
character string as the result.
Category
String
Syntax
StringResult = StringMid( Text, StartChar, Chars );
Parameters
Text
Actual string or a string attribute to extract a range of characters.
StartChar
The position of the first character within the string to extract. Any number or an integer attribute.
Chars
The number of characters within the string to return. Any number or an integer attribute.
Remarks
This function is slightly different than the StringLeft() on page 92 function and StringRight() on page 95
function in that it allows you to specify both the start and end of the string that is to be extracted.
Examples
StringMid("The Furnace is Overheating",5,7); ' returns "Furnace";
StringMid("The Furnace is Overheating",13,3); ' returns "is ";
StringMid("The Furnace is Overheating",16,50); ' returns "Overheating"
See Also
StringASCII() on page 86, StringChar() on page 86, StringFromIntg() on page 89, StringFrom Real() on
page 89, StringFromTime() on page 90, StringInString() on page 92, StringLeft() on page 92, StringLen()
on page 93, StringLower() on page 93, StringReplace() on page 94, StringRight() on page 95,
StringSpace() on page 96, StringTest() on page 97, StringToI ntg() on page 97, StringToReal() on page
98, StringTrim() on page 99, StringUpper() on page 99, Text() on page 100
StringReplace()
Replaces or changes specific parts of a provided string and returns the result.
94
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Category
String
Syntax
StringResult = StringReplace( Text, SearchFor, ReplaceWith, CaseSens,
NumToReplace, MatchWholeWords );
Parameters
Text
The string in which characters, words, or phrases will be replaced. Actual string or a string attribute.
SearchFor
The string to search for and replac e. Actual string or a string attribute.
ReplaceWith
The replacement string. Actual string or a string attribute.
CaseSens
Determines whet her the search is case-sensitive. (0=no and 1=yes) Any number or an integer
attribute.
NumToReplace
Determines the number of occurrences to replace. Any number or an integer attribute. To indicate all
occurrences, set this value to -1.
MatchWholeWords
Determines whet her the function limits its replacement to whole words. (0=no and 1=yes) A ny
number or an integer attribute. If MatchWholeWords is turned on (set to 1) and the Searc hFor is set
to "and", the "and" in "handle" are not replaced. If the MatchWholeWords is turned off (set to 0), it is
replaced.
Remarks
Use this function to replace characters, words, or phrases within a string.
The StringReplace() on page 94 function does not recognize special characters, such as @ # $ % & * ( ).
It reads them as delimiters. For example, if the function StringReplace() on page 94
(abc#,abc#,1234, 0,1,1) is processed, there is no replacement. The # sign is read as a delimiter instead
of a character.
Examples
StringReplace("In From Within","In","Out",0,1,0) ' returns "Out From Within"
(replaces only the first one);
StringReplace("In From Within","In","Out",0,-1,0) ' returns "Out From without"
(replaces all occurrences);
StringReplace("In From Within","In","Out",1,-1,0) ' returns "Out From Within"
(replaces all that match case);
StringReplace("In From Within","In","Out",0,-1,1) ' returns "Out From Within"
(replaces all that are whole words);
See Also
StringASCII() on page 86, StringChar() on page 86, StringFromIntg() on page 89, StringFromReal() on
page 89, StringFromTime() on page 90, StringInString() on page 92, StringLeft() on page 92, StringLen()
on page 93, StringLower() on page 93, StringMid() on page 94, StringRight() on page 95, StringSpac e()
on page 96, StringTest() on page 97, StringToIntg() on page 97, StringToReal() on page 98, StringTrim()
on page 99, StringUpper() on page 99, Text () on page 100
StringRight()
Returns the specified number of characters starting at the right -most character of text.
95
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Category
String
Syntax
StringResult = StringRight( Text, Chars );
Parameters
Text
Actual string or a string attribute.
Chars
The number of characters to return or an integer attribute.
Remarks
If Chars is set to 0, the entire string is returned.
Examples
StringRight("The Pump is On", 2) ' returns "On";
StringRight("The Pump is On", 5) ' returns "is On";
StringRight("The Pump is On", 87) ' returns "The Pump is On";
StringRight("The Pump is On", 0) ' returns "The Pump is On";
See Also
StringASCII() on page 86, StringChar() on page 86, StringFromIntg() on page 89, StringFromReal() on
page 89, StringFromTime() on page 90, StringInString() on page 92, StringLeft() on page 92, StringLen()
on page 93, StringLower() on page 93, StringMid() on page 94, StringReplace() on page 94,
StringSpace() on page 96, StringTest() on page 97, StringToI ntg() on page 97, StringToReal() on page
98, StringTrim() on page 99, StringUpper() on page 99, Text() on page 100
StringSpace()
Generat es a string of spac es either wit hin a string attribut e or within an expression and returns the result.
Category
String
Syntax
StringResult = StringSpace( NumSpaces );
Parameter
NumSpaces
Number of spac es to return. Any number or an integer attribute.
Examples
All spaces are represented by the "×" character:
StringSpace(4) ' returns "××××";
"Pump" + StringSpace(1) + "Station" ' returns "Pump×Station";
See Also
StringASCII() on page 86, StringChar() on page 86, StringFromIntg() on page 89, StringFromReal() on
page 89, StringFromTime() on page 90, StringInString() on page 92, StringLeft() on page 92, StringLen()
on page 93, StringLower() on page 93, StringMid() on page 94, StringReplace() on page 94,
StringRight() on page 95, StringTest() on page 97, StringToIntg() on page 97, StringToReal() on page
98, StringTrim() on page 99, StringUpper() on page 99, Text() on page 100
96
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
StringTest()
Tests the first character of text to determine whet her it is of a certain type and returns the result.
Category
String
Syntax
DiscreteResult = StringTest( Text, TestType );
Parameters
Text
String that function acts on. Actual string or a string attribute.
TestType
Determines the type of test. Possible values are:
1 = Alphanumeric character ('A -Z', 'a-z' and '0-9')
2 = Numeric character ('0- 9')
3 = Alphabetic character ('A-Z' and 'a-z')
4 = Uppercase character ('A-Z')
5 = Lowercase character ('a'-'z')
6 = Punctuation character (0x21-0x2F)
7 = ASCII characters (0x00 - 0x7F)
8 = Hexadecimal characters ('A -F' or 'a-f' or '0-9')
9 = Printable character (0x20-0x7E)
10 = Control character (0x00-0x1F or 0x7F)
11 = White Space characters (0x09-0x0D or 0x20)
Remarks
StringTest() on page 97 function returns true to DiscreteResult if the first character in Text is of the type
specified by TestType. Otherwise, false is returned. If the StringTest() on page 97 function contains more
than one character, only the first character of the attribute is tested.
Examples
StringTest("ACB123",1) ' returns 1;
StringTest("ABC123",5) ' returns 0;
See Also
StringASCII() on page 86, StringChar() on page 86, StringFromIntg() on page 89, StringFromReal() on
page 89, StringFromTime() on page 90, StringInString() on page 92, StringLeft() on page 92, StringLen()
on page 93, StringLower() on page 93, StringMid() on page 94, StringReplace() on page 94,
StringRight() on page 95, StringSpace() on page 96, StringToIntg() on page 97, StringToReal() on page
98, StringTrim() on page 99, StringUpper() on page 99, Text() on page 100
StringToIntg()
Converts the numeric value of a string to an integer value and returns the result.
Category
String
97
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Syntax
IntegerResult = StringToIntg( Text );
Parameter
Text
String that function acts on. Actual string or a string attribute.
Remarks
When this statement is evaluated, the system reads the first character of the string for a numeric value. If
the first character is other than a number, the string's value is equated to zero (0). Blank spaces are
ignored. If the first character is a number, the system continues to read the subsequent characters until a
non-numeric value is detected.
Examples
StringToIntg("ABCD"); ' returns 0;
StringToIntg("22.2 is the Value"); ' returns 22 (since integers are whole
numbers);
StringToIntg("The Value is 22"); ' returns 0;
See Also
StringASCII() on page 86, StringChar() on page 86, StringFromIntg() on page 89, StringFromReal() on
page 89, StringFromTime() on page 90, StringInString() on page 92, StringLeft() on page 92, StringLen()
on page 93, StringLower() on page 93, StringMid() on page 94, StringReplace() on page 94,
StringRight() on page 95, StringSpace() on page 96, StringTest() on page 97, StringToReal() on page
98, StringTrim() on page 99, StringUpper() on page 99, Text() on page 100
StringToReal()
Converts the numeric value of a string to a real (floating point) value and returns the result.
Category
String
Syntax
RealResult = StringToReal( Text );
Parameter
Text
String that function acts on. Actual string or a string attribute.
Remarks
When this statement is evaluated, the system reads the first character of the string for a numeric value. If
the first character is other than a number (blank spaces are ignored), the string's value is equated to z ero
(0). If t he first character is found to be a number, the system continues to read the subsequent characters
until a non-numeric value is encountered.
Examples
StringToReal("ABCD"); ' returns 0;
StringToReal("22.261 is the value"); ' returns 22.261;
StringToReal("The Value is 2"); ' returns 0;
See Also
StringASCII() on page 86, StringChar() on page 86, StringFromIntg() on page 89, StringFromReal() on
page 89, StringFromTime() on page 90, StringInString() on page 92, StringLeft() on page 92, StringLen()
on page 93, StringLower() on page 93, StringMid() on page 94, StringReplace() on page 94,
StringRight() on page 95, StringSpac e() on page 96, StringTest() on page 97, StringToIntg() on page 97,
StringTrim() on page 99, StringUpper() on page 99, Text () on page 100
98
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
StringTrim()
Removes unwanted spaces from text and returns the res ult.
Category
String
Syntax
StringResult = StringTrim( Text, TrimType );
Parameter
Text
String that is trimmed of spaces. Actual string or a string attribut e.
TrimType
Determines how the string is trimmed. Possible values are:
1 = Remove leading spaces to the left of the first non-space character
2 = Remove trailing spaces to the right of the last non-spac e character
3 = Remove all spaces except for single spaces between words
Remarks
The text is searched for white-spaces (AS CII 0x09-0x 0D or 0x20) that are to be removed. TrimType
determines the met hod used by the function:
Examples
All spaces are represented by the "×" character.
StringTrim("×××××This×is×a××test×××××", 1) ' returns "This×is×a××test×××××";
StringTrim("×××××This×is×a××test×××××", 2) ' returns "×××××This×is×a××test";
StringTrim("×××××This×is×a××test×××××", 3) ' returns "This×is×a×test";
The StringReplace() on page 94 function can remove ALL spaces from a specified a string attribute.
Simply replace all the space characters wit h a "null."
See Also
StringASCII() on page 86, StringChar() on page 86, StringFromIntg() on page 89, StringFromReal() on
page 89, StringFromTime() on page 90, StringInString() on page 92, StringLeft() on page 92, StringLen()
on page 93, StringLower() on page 93, StringMid() on page 94, StringReplace() on page 94,
StringRight() on page 95, StringSpac e() on page 96, StringTest() on page 97, StringToIntg() on page 97,
StringToReal() on page 98, StringUpper() on page 99, Text() on page 100
StringUpper()
Converts all lowercase text characters to uppercase and returns the result.
Category
String
Syntax
StringResult = StringUpper( Text );
Parameter
Text
String to be converted to uppercase. Actual string or a string attribute.
Remarks
Uppercas e characters, symbols, numbers, and other special characters are not affected.
99
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Examples
StringUpper("abcd"); ' returns "ABCD";
StringUpper("22.2 is the value"); ' returns "22.2 IS THE VALUE";
See Also
StringASCII() on page 86, StringChar() on page 86, StringFromIntg() on page 89, StringFromReal() on
page 89, StringFromTime() on page 90, StringInString() on page 92, StringLeft() on page 92, StringLen()
on page 93, StringLower() on page 93, StringMid() on page 94, StringReplace() on page 94,
StringRight() on page 95, StringSpac e() on page 96, StringTest() on page 97, StringToIntg() on page 97,
StringToReal() on page 98, StringTrim() on page 99, Text() on page 100
Text()
Converts a number to text based on a specified format.
Category
String
Syntax
StringResult = Text( Number, Format );
Parameters
Number
Any number or numeric attribut e.
Format
Format to use in conversion. Actual string or a string attribute.
Examples
Text(66,"#.00"); ' returns 66.00;
Text(22.269,"#.00"); ' returns 22.27;
Text(9.999,"#.00"); ' returns 10.00;
The following example shows how to use this function within another function:
LogMessage("The current value of FreezerRoomTemp is:" + Text (FreezerRoomTemp,
"#.#"));
In the following example, MessageTag is set to "One=1 Two=2".
MessageTag = "One + " + Text(1,"#") + StringChar(32) + "Two +" + Text(2,"#");
See Also
StringFromIntg() on page 89, StringToI ntg() on page 97, StringFromReal() on page 89, StringToReal()
on page 98
WWStringFromTime()
Converts a time value given in local time into UTC time (Coordinated Universal Time), and displays the
result as a string.
Category
String
Syntax
MessageResult = wwStringFromTime(SecsSince1-1-70,StringType);
Parameters
SecsSince1-1-70
Integer Type. Number of Seconds elapsed since Jan 01 00:00: 00 1970.
100
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
StringType
Determines the display method:
1 = Displays the date in the same format set from the windows control Panel. (Similar to that
displayed for $DateString.)
2 = Displays the time in the same format set from the Windows control Panel. (Similar to that
displayed for $TimeString.)
3 = Displays a 24-character string indicating both the date and time: "Wed Jan 02 02: 03:55 1993"
4 = Displays the short form for the day of the week: "Wed"
5 = Displays the long form for the day of the week: "Wednesday"
Remarks
Any adjustments necessary due to Daylight Savings Time will automatically be applied to the return
result. Therefore, it is not necessary to make any manual adjustments for DS T to the input value.
Example
This example assumes that the time zone on the local node is Pacific Standard Time (UTC-0800). The
local time passed to the function is 04:00:00 PM on Thursday, 1/1/1970. Since PS T is 8 hours behind
UTC, the function will return the following results:
wwStringFromTime(57600, 1) will return "1/2/70"
wwStringFromTime(57600, 2) will return "12:00:00 AM"
wwStringFromTime(57600, 3) will return "Fri Jan 02 00:00:00 1970"
wwStringFromTime(57600, 4) will return "Fri"
wwStringFromTime(57600, 5) will return "Friday"
System Functions
Use system functions to interact with the operating system or other core system functions, such as
ActiveX objects.
CreateObject()
Creates an ActiveX (COM) object.
Category
System
Syntax
ObjectResult = CreateObject( ProgID );
Parameter
ProgI D
The program ID (as a string) of the object to be created.
Example
CreateObject("ADODB.Connection");
Now()
Returns the current time.
Category
System
Syntax
TimeValue = Now();
101
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Remarks
The return value can be formatted using .NE T functions.
WWDDE Functions
Use WWDDE functions when working wit h the DDE protocol.
WWExecute()
Using the DDE prot ocol, executes a command to a specified application and topic and returns the status.
Category
WWDDE
Syntax
Status = WWExecute( Application, Topic, Command );
Parameters
Application
The application to which you want to send an exec ute command. Actual string or a string attribute.
Topic
The topic within the application. Actual string or a string attribute.
Command
The command to send. Actual string or a string attribute.
Return Value
Status is an Integer attribute to which 1, -1, or 0 is written. The WWExecute() function returns 1 if the
application is running, the topic exists, and the command was sent successfully. It returns 0 when the
application is busy, and -1 when there is an error.
Remarks
Note: The three WWDDE functions Execute(), Poke() and Request() exist for legacy purposes.
Examples
The following statement executes a macro in Excel:
Macro="Macro1!TestMacro";
Command="[Run(" + StringChar(34) + Macro + StringChar(34)
+ ",0)]";
WWExecute("excel","system",Command);
When WWExecute("excel","system",Command); is processed, the following is sent to Excel (and
TestMac ro runs):
[Run("Macro1!TestMacro")];
The following script executes a macro in Microsoft Access:
WWExecute("MSAccess","system","MyMacro");
102
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
WWPoke()
Using the DDE protocol, pokes a value to a specified application, topic, and item and returns the status.
Category
WWDDE
Syntax
Status = WWPoke( Application, Topic, Item, TextValue );
Parameters
Application
The application to which you want to send the Poke command. Actual string or a string attribute.
Topic
The topic within the application. Actual string or a string attribute.
Item
The item to poke within the topic. Actual string or a string attribute.
TextValue
The value to poke. If the value you want to send is a number, you can convert it using the Text () on
page 100, StringFromInt g() on page 89, or StringFromReal() on page 89 functions. Actual string or a
string attribut e.
Return Value
Status is an Integer attribute to which 1, -1, or 0 is written. The WWPoke() function returns 1 if the
application is running, the topic and item exist, and the value was sent successfully. It returns 0 if the
application is busy, and -1 if there is an error.
Remarks
Note: The three WWDDE functions Execute(), Poke() and Request() exist for legacy purposes.
The value TextValue is sent to the particular application, topic, and item specified.
Example
The following statement converts a value to text and pokes the result to an Excel spreadsheet cell:
String=Text(Value,"0");
WWPoke("excel","[Book1.xls]sheet1","r1c1",String);
The behavior for WWPoke() from within the application "View" to "View" is undefined and is not
supported. The WWPoke() command is not guaranteed to succeed in this instance, and the command
will probably time-out without the desired results.
See Also
Text() on page 100, StringFromIntg() on page 89, StringFromReal() on page 89
WWRequest()
Using the DDE protocol, makes a one -time request for a value from a particular application, topic, and
item and returns the status.
103
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Category
WWDDE
Syntax
Status = WWRequest( Application, Topic, Item, Attribute );
Parameters
Application
The application from which you want to request data. Actual string or a string attribute.
Topic
The topic within the application. Actual string or a string attribute.
Item
The item within the topic. Actual string or a string attribut e.
Attribute
A string attribute, enclos ed in quotation marks, that contains the requested value from the
application, topic, and item. Actual string or a string attribute.
Return Value
Status is an integer attribute to which 1, -1, or 0 is written. The WWRequest() function returns 1 if the
application is running, the topic and item exist, and the value was returned successfully. It returns 0 if the
application is busy, and -1 if there is an error.
Remarks
Note: The three WWDDE functions Execute(), Poke() and Request() exist for legacy purposes.
The DDE value in the particular application, topic, and item is returned into Attribute.
The value is returned as a string into a string attribute. If the value is a number, you can then convert it
using the StringToInt g() on page 97 or StringToReal() on page 98 functions.
Example
The following statement requests a value from an Excel spreadsheet cell and converts the res ulting
string into a value:
WWRequest("excel","[Book1.xls]sheet1","r1c1",Result);
Value=StringToReal(Result);
See Also
StringToI ntg() on page 97, StringToReal() on page 98
104
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Each variable must be declared in the script by a separate DIM statement followed by a semicolon. Enter
DIM statements in the Declarations area of t he Script tab page. The DIM statement syntax is as follows:
DIM <variable_name> [ ( <upper_bound>
[, <upper_bound >[, < upper_bound >]] ) ]
[ AS <data_type> ];
where:
<variable_name> Name that begins with a letter (A-Z or a-z) and whos e remaining characters
can be any combination of letters (A-Z or a-z), digits (0-9) and underscores
(_). The variable name is limited to 255 Unicode characters.
<upper_bound> Referenc e to the upper bound (a number bet ween 1 and 2,147,483,647,
inclusive) of an array dimension. Three dimensions are supported in a DIM
statement, each being nested in the syntax structure. After the upper bound is
specified, it is fixed after the declaration. A statement similar to Visual Basic’s
ReDim is not supported.
The lower bound of each array dimension is always 1.
AS Optional keyword for declaring the variable’s datatype.
If you omit the AS clause from the DIM statement, the variable, by default, is
declared as an Integer datatype. For example:
DIM LocVar1;
is equivalent to:
In contrast to attribute names, variable names must not contain dots. Variable names and the data type
identifiers are not case sensitive. If there is a naming conflict between a declared variable and anot her
named entity in the script (for example, attrib ute name, alias or name of an object leveraged by the
script), the variable name takes precedence over the other named entities. If the variable name is the
same as an alias name, a warning message appears when the script is validated to indicate that the alias
is ignored.
The syntax for specifying the entire array is "[ ]" for both local array variables and for attribute references.
For example, to assign an attribute array to a local array, the syntax is:
locarr[] = tag.attr[];
DIM statements can be located any where in the script body, but they must prec ede the first referencing
script statement or expression. If a local variable is referenced before the DIM statement, script validation
done when you save the object containing the script prompts you to define it.
105
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Caution: The validation mentioned above occurs only when you save the object containing the script.
This is not the script syntax validation done when you click the Validate Script button.
Do not cascade DIM statements. For example, the following examples are invalid:
DIM LocVar1 AS Integer, LocVar2 AS Real;
DIM LocVar3, LocVar4, LocVar5, AS Message;
To declare multiple variables, you must enter separate DIM statements for each variable.
When used on the right side of an equation, declared local variables always cause expressions on the
left side to have Good quality. For example :
dim x as integer;
dim y as integer;
x = 5;
y = 5;
me.attr = 5;
me.attr = x;
me.attr = x+y;
In each case of me.attr, quality is Good.
When you use a variable in an expression to the right of the operator, its Quality is treated as Good for
the purpose of data quality propagation.
You can use null to indicate that there is no object currently assigned to a variabl e. Using null has the
same meaning as the key word "null" in C# or "nothing" in Visual Basic. Assigning null to a variable makes
the variable eligible for garbage collection. You may not use a variable whose value is null. If you do, the
script terminates and an error message appears in the logger. You may, however, test a variable for null.
For example:
IF myvar == null THEN ...
It is not possible to pass attributes as parameters for system objects. To work around this issue, use a
local variable as an intermediary or explicitly convert the attribut e to a string using an appropriate
function call when calling the system object.
106
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
or
[<sign>] <digit>+ [.<digit>* [<exponent>]];
where:
sign ::= + or -
digit ::= 0-9 (can be one or more decimal digits)
exponent = e (or E) followed by a sign and then digit(s)
Float constants are applicable as values for variables of type float, real, or double. For example, float
constants do not take the number of bytes into account. Script validation detects an overflow when a
float, real, or double variable has been assigned a float constant that exceeds the maximum value.
If no digits appear before the period (.), at least one must appear after it. If nei ther an exponent part nor
the period appears, a period is assumed to follow the last digit in the string.
If an attribute reference exists that has a format similar to a float constant with an exponent (such as
"5E3"), then use the Attribute qualifier, as follows:
Attribute("5E3")
Strings must be surrounded by double quot ation marks. They are referred to as quoted strings. The
double-double quote indicates a single double -quote in the string. For ex ample, the string:
Joe said, "Look at that."
can be represent ed in QuickScript .NET as:
"Joe said, ""Look at that."""
107
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
String, Message Cannot be mapped. Using an expression that results in a string type as the
Boolean_expression res ults in a script validation error.
Time Cannot be mapped. Using an expression that results in a time type as the
Boolean_expression res ults in a script validation error.
ElapsedTime Cannot be mapped. Using an expression that results in an elapsed time type
as the Boolean_expression res ults in a script validation error.
Object Using an expression that results in an object type. Validates, but at run
time, the object is converted to a Boolean. If the type cannot be converted to
a Boolean, a run-time exception is raised.
The first block of statements is executed if Boolean_expression evaluates to True. Optionally, a second
block of statements can be defined after the keyword ELSE. This block is executed if the
Boolean_expression evaluates to False.
To help decide between multiple alt ernatives, an optional ELSEIF clause can be used as often as
needed. The ELSEIF clause mimics switch statements offered by other programming languages. For
example:
IF value == 0 Then
Message = "Value is zero";
ELSEIF value > 0 Then
Message = "Value is positive"; ELSEIF value < 0 Then
Message = "Value is negative";
ELSE
108
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
ENDIF;
See Sample Scripts for more ideas about using this type of control structure.
109
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Note: FOR-NE XT loops can be nested. The number of levels of nesting possible depends on memory
and resource availability.
110
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Note: Statements inside the Catch block may reference the reserved ERROR variable, which is a .NE T
System.Exception thrown from the Try block. The statements in the Catch block run only if an exception
is thrown from the Try block.
while reader.Read()
me.name = reader.GetString(0);
LogMessage(me.name);
endWhile;
catch
LogMessage(error);
111
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
endtry;
if reader <> null and not reader.IsClosed then
reader.Close();
endif;
if command.Connection.State == System.Data.ConnectionState.Open then
command.Connection.Close();
endif;
WHILE Loop
WHILE loop performs a function or set of functions within a script several times during a single execution
of a script while a condition is true. The general format of the WHILE loop is as follows:
WHILE <Boolean_expression>
[statements]
[EXIT WHILE;]
[statements]
ENDWHILE;
Where: Boolean_ex pression is an expression that can be evaluat ed as a Boolean as defined in the
description of IF…THE N statements.
It is possible to exit the loop from the body of the loop through the E XIT W HILE statement.
The WHILE loop is executed as follows:
1. The script evaluates whether the Boolean_expression is true or not. If not, program exec ution exits
the loop and continues after the ENDWHILE statement.
2. The statements in the body of the loop are executed. The loop can be exited through the E XIT
WHILE statement.
3. Steps 1 through 2 are repeated.
Note: WHILE loops can be nested. The number of levels of nesting possible depends on memory and
resource availability.
~ Complement
- Negation
- Subtraction
* Multiplication
112
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
** Power
/ Division
^ Exclusive OR
| Inclusive OR
= Assignment
AND Logical A ND
MOD Modulo
OR Logical OR
Precedence Operator
1 (highest) ( )
2 - (negation), NOT, ~
3 **
4 *, /, MOD
5 +, - (subtraction)
6 SHL, SHR
8 ==, <>
9 &
10 ^
113
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
Precedence Operator
11 |
12 =
13 AND
14 (lowest) OR
The arguments of the listed operat ors can be numbers or attribut e values. Putting parentheses around
an argument is optional. Operator names are not case-sensitive.
Parentheses ( )
Parentheses specify the correct order of evaluation for the operat or(s ). They can also make a complex
expression easier to read. Operator(s) in parentheses are evaluated first, preempting the other rules of
precedence that apply in the absence of parent heses. If the precedence is in question or needs to be
overridden, use parentheses.
In the example below, parentheses add B and C toget her before multiplying by D:
( B + C ) * D;
Negation ( - )
Negation is an operator that acts on a single component. It converts a positive integer or real number into
a negative number.
Complement ( ~ )
This operator yields the one's complement of a 32-bit integer. It converts each zero-bit to a one-bit and
each one-bit to a zero-bit. The one's complement operator is an operator that acts on a single
component, and it accepts an integer operand.
Power ( ** )
The Power operator ret urns the result of a number (the base) raised to the power of a second number
(the power). The base and the power can be any real or integer numbers, subject to the following
restrictions:
A zero base and a negative power are invalid.
Example: "0 ** - 2" and "0 ** -2.5"
A negative base and a fractional power are invalid.
Example: "-2 ** 2.5" and "-2 ** -2.5"
Invalid operands yield a zero result.
The result of the operation should not be so large or so small that it cannot be represented as a real
number. Example:
1 ** 1 = 1.0
3 ** 2 = 9.0
10 ** 5 = 100,000.0
114
QuickScript .NET Functions AVEVA Application Server formerly Wonderware Application Server Scripting Guide
For example, in the data change script below, each time the value of "Number" changes, "Setpoint"
changes as well:
Number=1;
Setpoint.Name = "Setpoint" + Text(Number, "#" );
Where: The result is "Setpoint1."
Modulo (MOD)
MOD is a binary operator that divides an integer quantity to its left by an integer quantity to its right. The
remainder of the quotient is the result of the MOD operation. Example:
97 MOD 8 yields 1
63 MOD 5 yields 3
Assignment ( = )
Assignment is a binary operator which accepts integer, real, or any type of operand. Each statement can
contain only one assignment operator. Only one name can be on t he left side of the as signment operator.
Read the equal sign (=) of the assignment operator as "is assigned to" or "is set to."
Note: Do not confuse the equal sign with the equivalency sign (==) used in comparisons.
115
AVEVA Application Server formerly Wonderware Application Server Scripting Guide QuickScript .NET Functions
116
AVEVA Application Server formerly Wonderware Application Server Scripting Guide
C HAPTER 3
Sample QuickScript .NET Scripts
This section includes sample scripts to help you to understand the QuickScript .NET scripting language.
Important Note s: The sample scripts provided with a number of the Application Server scripting
functions should work as written in most Windows operati ng system and installed software
environments, but might not work with all possible hardware, operating system, and software
combinations. We recommend that you modify the example scripts as necessary to fit your specific
environment.
Some sample scripts include references to public websites as examples. You may need to replace those
URLs with a current and verified URLs.
Note: The Micros oft Office Excel dll file name and location may vary, depending on whic h version of
Excel is installed.
2. Open the Excel spreadsheet you want to access. In the following sample script, the Excel file name
and path are: C:\documents\sample.xlsx
app = CreateObject("Excel.Application");
app.Visible=true;
wb = app.Workbooks.Open("C:\documents\sample.xlsx");
ws = wb.ActiveSheet;
ws.Range("A1").Value = 100;
ws.Range("A2").Value = 200;
ws.Range("A3").Value = "=A1*A2";
LogMessage(ws.Range("A3").Value);
wb.Visible=true;
wb.Close(false);
117
AVEVA Application Server formerly Wonderware Application Server Scripting Guide Sample QuickScript .NET Scripts
ws = wb.ActiveSheet;
ws.Range.("A1").value = 20;
ws.Range.("A2").value = 30;
ws.Range.("A3").value = "=A1*A2";
LogMessage(ws.Range("A3").Value);
wb.Close(false);
' Requires input string uda me.zipcode and output float uda me.temperature.
' First, generate a wrapper for the web service (.Net SDK must be installed).
' To generate wrapper, run the following commands from the DOS prompt:
' set path=%path%;C:\Program Files\Microsoft Visual Studio
.NET\FrameworkSDK\Bin
' wsdl http://www.vbws.com/services/weatherretriever.asmx
' csc /target:library WeatherRetriever.cs
' Next import the generated WeatherRetriever.dll library into your galaxy.
' Now write your script:
dim wr as WeatherRetriever;
wr = new WeatherRetriever;
me.temperature = wr.GetTemperature(me.zipcode);
118
Sample QuickScript .NET Scripts AVEVA Application Server formerly Wonderware Application Server Scripting Guide
119
AVEVA Application Server formerly Wonderware Application Server Scripting Guide Sample QuickScript .NET Scripts
120
Sample QuickScript .NET Scripts AVEVA Application Server formerly Wonderware Application Server Scripting Guide
121
AVEVA Application Server formerly Wonderware Application Server Scripting Guide Sample QuickScript .NET Scripts
122
Sample QuickScript .NET Scripts AVEVA Application Server formerly Wonderware Application Server Scripting Guide
);
123
AVEVA Application Server formerly Wonderware Application Server Scripting Guide Sample QuickScript .NET Scripts
Note: You can use .BindTo with an attribut e on another engine, but this requires additional scripting of
the bind to ensure good quality. For more information, see Binding to Off-engine Attributes on page 124.
Important: If you have an existing application that uses the same Indirect variable with scripting more
than one time for the items extended to device integration (DI) items or for DI items direct ly, and you
enable Advanced Communication Management in the IDE, these scripts behave differently or do not
execute as expected.
124
Sample QuickScript .NET Scripts AVEVA Application Server formerly Wonderware Application Server Scripting Guide
In the "waiting for reference" state, use IsGood() to check the quality of the indirect variables. When
all references show good quality, change to the normal ex ecut ion state. The variables then are
usable.
You can implement a TimeOut state if required. For example, the remote engine might be Off Scan.
The following script examples illustrate these guidelines.
if (scriptState==0) then;
' normal script logic
' perform normal tasks
' ...
endif;
if (scriptState==1) then;
' wait for remote references
' in this example we want two valid references
endif;
As an alternative, you can use a WHILE-triggered script to allow evaluation at every scan cycle.
Generally, WHILE loops are not recommended, but can be used to ensure exec ution.
In Declarations:
dim x as indirect;
dim y as boolean;
if not y then
125
AVEVA Application Server formerly Wonderware Application Server Scripting Guide Sample QuickScript .NET Scripts
if IsGood(x) then
LogMessage(x);
me.z = false;
endif;
126
AVEVA Application Server formerly Wonderware Application Server Scripting Guide
Index
CreateObject() • 101
A Creating a Look-up Table and Doing a Look-up
Abs() • 59 on It • 118
Accepting Autocomplete Suggestions • 14 Creating an XML Document and Saving it to
Accessing an Excel Spreadsheet Using an Disk • 119
Imported Ty pe Library • 117
Accessing an Excel Spreadsheet Using D
CreateObject • 117
DateTimeGMT() • 66
ActivateA pp() • 65
Deployment Scripts • 9
AddPermission() Function • 40
deployment timeout period • 9
and system resources • 9
deployment timeout period, scripts • 9
AND, OR, and NOT • 116
description • 16
ArcCos() • 59
DText() • 85
ArcSin() • 59
dynamic reference scripting • 14
ArcTan() • 60
dynamic references • 14
Assignment ( = ) • 115
dynamic referencing • 14
AttemptInvisibleLogon() Function • 40
Dynamic Referencing Considerations • 14
Autocomplet e • 10
Dynamically Binding an Indirect Variable to a
Referenc e • 123
B
Binding to Off-engine Attributes • 124 E
Bitwise AND ( & ) • 115
EnableDisableKeys() Function • 42
entries • 7
C errors • 14
Calling a Web Service to Get the Temperature Exclusive OR (^) and Inclusive OR ( | ) • 115
for a Specified Zip Code • 118 Execute method • 14
Calling a Web Service to Send an E -mail Execute Scripts • 8
Message • 118 Executing a SQL Parameterized INSERT
ChangePassword() Function • 41 Command • 119
Closing a Client Application Window • 16 Exp() • 60
closing a client application window cont aining
scripts • 16 F
Color Indicators for Script Elements • 10
FileCopy() Function • 42
Common Scripting Environment • 7
FileDelete() Function • 43
Comparisons ( <, >, <=, >=, ==, <> ) • 116
FileMove() Function • 44
Complement ( ~ ) • 114
FileReadFields() Function • 45
Cont act Information • 2
FileReadMessage() Function • 46
converting • 114
FileWriteFields() Function • 46
Cos() • 60
127
AVEVA Application Server formerly Wonderware Application Server Scripting Guide Index
FileWriteMessage() Function • 47
Filling a String Array and Using It • 120
Filling a Two-Dimensional Integer Array and
L
LaunchTagViewer() Function • 53
Using It • 120
Line Numbers • 17
Filtering E vents • 65
Loading an XML Document from Disk and
FOR … TO … S TEP … NE XT Loop • 109
Doing Look-ups on It • 121
FOR EACH … IN … NE XT • 110
Log Functions • 17
Formatting a Number Using a .NE T Format
Log() • 61
'Picture' • 120
Log10() • 61
Formatting a Time Using a .NE T Format
LogCustom() • 69
'Picture' • 120
LogDataChangeE vent() • 69
LogDataChangeE vent() script function • 69
G LogE rror() • 70
GetAccountStatus() Function • 48 LogMessage() • 71
GetCPQuality() • 19 LogN() • 62
GetCP TimeStamp() • 20 Logoff() • 25
GetNodeName() Function • 48 LogonCurrentUser() Function • 53
Getting the Directories Under the C Drive • 120 LogTrace() • 71
Graphic Client Functions • 19 LogWarning() • 72
H M
HideContent () • 20 Math Functions • 58
HideGraphic() • 24 Maximizing or Restoring a Client Application
HideS elf() • 25 Window • 17
memory load and scripts • 9
memory load during deployment • 9
I memory types • 114
IF … THE N … ELSEIF … ELSE … ENDIF • 107
message types • 114
IF … THE N … ELSEIF … ELSE … ENDIF and
message types, concatenating • 114
Attribute Quality • 109
Minimizing a Client Application Window • 17
InfoA ppTitle() Function • 49
minimizing a client application window
InfoDisk() Function • 49
containing scripts • 17
InfoFile() Function • 50
Miscellaneous Functions • 65
InfoInTouchA ppDir() Function • 51
Modulo (MOD) • 115
Int() • 61
Multi-level Undo and Redo • 14
InTouch Functions • 40
Multiplication ( * ), Division ( / ), Addition ( +
InTouchV ersion() Function • 51
),Subtraction ( - ) • 114
InvisibleV erifyCredentials() Function • 52
IsAssignedRole() Function • 52
IsBad() • 67 N
IsGood() • 67 Negation ( - ) • 114
IsInitializing() • 67 Now() • 101
IsUnc ertain() • 68 Numbers and Strings • 106
IsUsable() • 68
O
OffScan Scripts • 9
128
Index AVEVA Application Server formerly Wonderware Application Server Scripting Guide
129
AVEVA Application Server formerly Wonderware Application Server Scripting Guide Index
T
Tan() • 64
Text() • 100
timestamps • 69, 74
Trunc () • 65
TRY ... CATCH • 111
TseGetClient Id() Function • 57
TseGetClientNodeName() Function • 57
TseQueryRunningOnClient () Function • 57
TseQueryRunningOnConsole() Function • 57
Types category • 19
Types category, script function • 19
U
Using DDE to Access an Excel Spreadsheet •
122
Using Micros oft Exchange to Send an E-mail
Message • 122
Using Screen-Scraping to Get the Temperature
for a City • 123
Using SMTP to Send an E-mail Message • 123
V
Vista security restrictions • 65
Visual Indication of Script Errors • 17
W
WHILE Loop • 112
Working with QuickScript Editor Features • 10
WriteStatus() • 84
Writing a Text File to Disk • 123
WWControl() • 85
WWDDE Functions • 102
WWExecute() • 102
WWPoke() • 103
WWRequest() • 103
WWStringFromTime() • 100
130