Application Server Scripting Guide: Invensys Systems, Inc
Application Server Scripting Guide: Invensys Systems, Inc
Guide
Revision A
Last Revision: 7/24/07
Copyright
© 2007 Invensys Systems, Inc. All Rights Reserved.
All rights reserved. No part of this documentation shall be reproduced, stored in a
retrieval system, or transmitted by any means, electronic, mechanical,
photocopying, recording, or otherwise, without the prior written permission of
Invensys Systems, Inc. No copyright or patent liability is assumed with respect to
the use of the information contained herein. Although every precaution has been
taken in the preparation of this documentation, the publisher and the author
assume no responsibility for errors or omissions. Neither is any liability assumed
for damages resulting from the use of the information contained herein.
The information in this documentation is subject to change without notice and does
not represent a commitment on the part of Invensys Systems, Inc. The software
described in this documentation is furnished under a license or nondisclosure
agreement. This software may be used or copied only in accordance with the terms
of these agreements.
Trademarks
All terms mentioned in this documentation that are known to be trademarks or
service marks have been appropriately capitalized. Invensys Systems, Inc. cannot
attest to the accuracy of this information. Use of a term in this documentation
should not be regarded as affecting the validity of any trademark or service mark.
Alarm Logger, ActiveFactory, ArchestrA, Avantis, DBDump, DBLoad, DT Analyst,
FactoryFocus, FactoryOffice, FactorySuite, FactorySuite A2, InBatch, InControl,
IndustrialRAD, IndustrialSQL Server, InTouch, MaintenanceSuite, MuniSuite, QI
Analyst, SCADAlarm, SCADASuite, SuiteLink, SuiteVoyager, WindowMaker,
WindowViewer, Wonderware, and Wonderware Logger are trademarks of Invensys
plc, its subsidiaries and affiliates. All other brands may be trademarks of their
respective owners.
3
Contents
Welcome............................................ 7
Documentation Conventions...............................................7
Technical Support ...............................................................8
ArcCos()...........................................................................19
ArcSin() ...........................................................................20
ArcTan() ..........................................................................20
Cos() ................................................................................21
CreateObject().................................................................21
DateTimeGMT() .............................................................22
DText() ............................................................................22
Exp()................................................................................23
Int() .................................................................................23
IsBad().............................................................................24
IsGood()...........................................................................24
IsInitializing().................................................................25
IsUncertain() ..................................................................25
IsUsable()........................................................................26
Log() ................................................................................27
LogN() .............................................................................27
Log10() ............................................................................28
LogMessage() ..................................................................28
Now() ...............................................................................29
Pi() ...................................................................................29
Round()............................................................................30
SendKeys() ......................................................................30
SetBad() ..........................................................................32
SetGood().........................................................................33
SetInitializing() ..............................................................33
SetUncertain() ................................................................34
Sgn() ................................................................................34
Sin().................................................................................35
Sqrt() ...............................................................................35
StringASCII()..................................................................36
StringChar()....................................................................36
StringCompare() .............................................................37
StringCompareNoCase() ................................................38
StringFromGMTTimeToLocal().....................................39
StringFromIntg() ............................................................40
StringFromReal() ...........................................................41
StringFromTime() ..........................................................42
StringFromTimeLocal() .................................................43
StringInString()..............................................................44
StringLeft() .....................................................................45
StringLen()......................................................................46
StringLower()..................................................................47
StringMid() .....................................................................48
StringReplace() ...............................................................49
StringRight()...................................................................50
StringSpace() ..................................................................51
StringTest().....................................................................52
StringToIntg().................................................................53
StringToReal() ................................................................54
StringTrim()....................................................................55
StringUpper()..................................................................56
Tan() ................................................................................56
Text() ...............................................................................57
Trunc().............................................................................58
WriteStatus() ..................................................................58
WWControl() ...................................................................59
WWExecute() ..................................................................60
WWPoke() .......................................................................61
WWRequest() ..................................................................62
WWStringFromTime() ...................................................64
QuickScript .NET Variables .............................................65
Numbers and Strings .....................................................68
QuickScript .NET Control Structures ..............................69
IF … THEN … ELSEIF … ELSE … ENDIF ................69
FOR … TO … STEP … NEXT Loop ..............................72
FOR EACH … IN … NEXT ...........................................73
WHILE Loop ...................................................................74
QuickScript .NET Operators ............................................75
Parentheses ( ) ................................................................76
Negation ( - ) ...................................................................77
Complement ( ~ ) ............................................................77
Power ( ** )......................................................................77
Multiplication ( * ), Division ( / ), Addition ( + ),
Subtraction ( - ) ..........................................................77
Modulo (MOD) ................................................................78
Shift Left (SHL), Shift Right (SHR) ..............................78
Bitwise AND ( & )...........................................................78
Exclusive OR (^) and Inclusive OR ( | )........................78
Assignment ( = )..............................................................79
Comparisons ( <, >, <=, >=, ==, <> ) ..............................79
AND, OR, and NOT........................................................79
Welcome
Documentation Conventions
This documentation uses the following conventions:
Technical Support
Wonderware Technical Support offers a variety of support
options to answer any questions on Wonderware products
and their implementation.
Before you contact Technical Support, refer to the relevant
section(s) in this documentation for a possible solution to the
problem. If you need to contact technical support for help,
have the following information ready:
• The type and version of the operating system you are
using.
Chapter 1
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}
Startup Scripts
Startup scripts are called when the object is loaded into
memory, such as during deployment, platform or engine
start.
Startup instantiates COM objects and .NET 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 method.
OnScan Scripts
OnScan scripts are called the first time an AppEngine calls
this object to execute after the object scan state is changed to
OnScan. The OnScan method initiates local object attribute
values or provides more flexibility in the creation of .NET or
COM objects.
Attributes that are off-engine are not available to the
OnScan method.
Execute Scripts
Execute scripts are called every time the AppEngine
performs a scan and the object is OnScan.
The Execute script method is the workhorse of the scripting
execution 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: Executes whenever the elapsed time evaluates
as true.
• Data Change: Executes when a data value changes
between scans.
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 force. 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
removed from memory, usually as a result of the AppEngine
stopping. Primarily used to destroy COM objects and .NET
objects and clean up 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 Galay’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 timeout 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 down or cause a deployment or failover to
fail. In addition to the load that is placed on the system at
deployment time, the type or scripting done in the Startup
and OnScan methods is also important because 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 tagname within their hosting Area.
• Off-object referencing
• Dynamic referencing
Element Color
Chapter 2
• Examples
Script Functions
Script functions are described in this section.
Abs()
Returns the absolute value (unsigned equivalent) of a
specified number.
Category
Math
Syntax
Result = Abs( Number );
Parameter
Number
Any number or numeric attribute.
Examples
Abs(14); ' returns 14
Abs(-7.5); ' returns 7.5
ActivateApp()
Activates another currently running Windows application.
Category
Miscellaneous
Syntax
ActivateApp( TaskName );
Parameter
TaskName
The task this function activates.
Remarks
TaskName is the exact text string, including spaces, that
appears on the Task Bar or in the Task Manager. You can see
this name by opening the Task Manager.
Example
ActivateApp("Calculator");
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 attribute with a value between -1
and 1 (inclusive).
Examples
ArcCos(1); ' returns 0
ArcCos(-1); ' returns 180
See Also
Cos(), Sin(), Tan(), ArcSin(), ArcTan()
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 attribute with a value between -1
and 1 (inclusive).
Examples
ArcSin(1); ' returns 90
ArcSin(-1); ' returns -90
See Also
Cos(), Sin(), Tan(), ArcCos(), ArcTan()
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 attribute.
Examples
ArcTan(1); ' returns 45
ArcTan(0); ' returns 0
See Also
Cos(), Sin(), Tan(), ArcCos(), ArcSin()
Cos()
Returns the cosine of an angle in degrees.
Category
Math
Syntax
Result = Cos( Number );
Parameter
Number
Any number or numeric attribute.
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(), Tan(), ArcCos(), ArcSin(), ArcTan()
CreateObject()
Creates an ActiveX (COM) object.
Category
System
Syntax
ObjectResult = CreateObject( ProgID );
Parameter
ProgID
The program ID (as a string) of the object to be created.
Example
CreateObject("ADODB.Connection");
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);
DText()
Returns one of two possible strings, depending on the value
of the Discrete parameter.
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");
Exp()
Returns the result of the exponent e raised to a power.
Category
Math
Syntax
Result = Exp( Number );
Parameter
Number
Any number or numeric attribute.
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 attribute.
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
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, and so on
Name of the attribute(s) for which you want to determine
Bad quality. You can include a variable-length 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(), IsInitializing(), IsUncertain(), IsUsable()
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 attribute(s) for which you want to determine
Good quality. You can include a variable-length 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(), IsInitializing(), IsUncertain(), IsUsable()
IsInitializing()
Returns a Boolean value indicating if the quality of the
specified attribute is Initializing.
Category
Miscellaneous
Syntax
BooleanResult = IsInitializing( Attribute1, Attribute2,
… );
Parameter(s)
Attribute1, Attribute2, and so on
Name of the attribute(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(), IsGood(), IsUncertain(), IsUsable()
IsUncertain()
Returns a Boolean value indicating if the quality of the
specified attribute is Uncertain.
Category
Miscellaneous
Syntax
BooleanResult = IsUncertain( Attribute1, Attribute2, …
);
Parameter(s)
Attribute1, Attribute2, and so on
Name of the attribute(s) to determine Uncertain quality.
You can include a variable-length list of attributes.
Return Value
If all of the specified attributes have Uncertain quality, then
true is returned. Otherwise, false is returned.
Examples
IsUncertain(TIC101.PV);
IsUncertain(TIC101.PV, PIC102.PV);
See Also
IsBad(), IsGood(), IsInitializing(), IsUsable()
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, and so on
Name of the attribute(s) for which you want to determine
unusable quality. You can include a variable-length list of
attributes.
Return Value
If all of the specified attributes have either Good or
Uncertain quality, then true is returned. Otherwise, false is
returned.
Remarks
To qualify as usable, the attribute must have Good or
Uncertain quality. In addition, each float or double attribute
cannot be a NaN (not a number).
Examples
IsUsable(TIC101.PV);
IsUsable(TIC101.PV, PIC102.PV);
See Also
IsBad(), IsGood(), IsInitializing(), IsUncertain()
Log()
Returns the natural log (base e) of a number.
Category
Math
Syntax
RealResult = Log( Number );
Parameter
Number
Any number or numeric attribute.
Remarks
Natural log of 0 is undefined.
Examples
Log(100); ' returns 4.605...
Log(1); ' returns 0
See Also
LogN(), Log10()
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 attribute.
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(), Log10()
Log10()
Returns the base 10 log of a number.
Category
Math
Syntax
Result = Log10( Number );
Parameter
Number
Any number or numeric attribute.
Example
Log10(100); ' returns 2
See Also
Log(), LogN()
LogMessage()
Writes a user-defined message to the Log Viewer.
Category
Miscellaneous
Syntax
LogMessage( msg );
Parameter
msg
The message to write 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,
"#"));
Now()
Returns the current time.
Category
System
Syntax
TimeValue = Now();
Remarks
The return value can be formatted using .NET functions.
Pi()
Returns the value of Pi.
Category
Math
Syntax
RealResult = Pi();
Example
Pi(); ' returns 3.1415926
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 attribute.
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()
SendKeys()
Sends keys to an application. To the receiving application,
the keys appear to be entered from the keyboard. This lets
you enter data or send commands to the 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 {ENTER} for the Enter key.
Category
Miscellaneous
Syntax
SendKeys( KeySequence );
Parameter
KeySequence
Any key sequence or a string attribute.
Remarks
To specify more than one key, concatenate the codes for each
character. For example, to specify the dollar sign ($) key
followed by a (b), enter $b.
The following lists the valid send keys for unique keyboard
keys:
Key Code
Special keys (SHIFT, CTRL and ALT) have their own key
codes:
Key Code
SHIFT + (plus)
CTRL ^ (caret)
ALT % (percent)
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(), SetInitializing(), SetUncertain()
SetGood()
Sets the quality of an attribute to Good.
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(), SetInitializing(), SetUncertain()
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(), SetGood(), SetUncertain()
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.
Remarks
The specified attribute must be within the object to which the
script is attached.
Example
SetUncertain(me.PV);
See Also
SetBad(), SetGood(), SetInitializing()
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 attribute.
Return Value
If the input number is positive, the result is 1. Negative
numbers return 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
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
expression:
wave = 100 * Sin (6 * Now().Second);
See Also
Cos(), Tan(), ArcCos(), ArcSin(), ArcTan()
Sqrt()
Returns the square root of a number.
Category
Math
Syntax
RealResult = Sqrt( Number );
Parameter
Number
Any number or numeric attribute.
Example
This example takes the value of me.PV and returns the
square root as the value of x:
x=Sqrt(me.PV);
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 attribute.
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;
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 attribute.
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 StringAttribute 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 printers or
modems.
ControlString =
StringAttribute+StringChar(13)+StringChar(10);
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(), StringChar(), StringFromReal(),
StringFromTime(), StringFromTimeLocal(),
StringInString(), StringLeft(), StringLen(), StringLower(),
StringMid(), StringReplace(), StringRight(), StringSpace(),
StringTest(), StringToIntg(), StringToReal(), StringTrim(),
StringUpper(), Text()
StringCompareNoCase()
Compares a string value with another string and ignores the
case.
Category
String
Syntax
StringCompareNoCompare( 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)
Result = StringCompareNoCase (MText1,MText2);
Where Result is an Integer or Real tag and MText1 and
MText2 are Memory Message tags.
See Also
StringASCII(), StringChar(), StringFromReal(),
StringFromTime(), StringFromTimeLocal(),
StringInString(), StringLeft(), StringLen(), StringLower(),
StringMid(), StringReplace(), StringRight(), StringSpace(),
StringTest(), StringToIntg(), StringToReal(), StringTrim(),
StringUpper(), Text()
StringFromGMTTimeToLocal()
Converts a time value (in seconds since Jan-01-1970) into 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 StringType 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 adjustments for DST
to the input value.
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) will return "1/1/70"
StringFromGMTTimeToLocal(86400, 2) will return
"04:00:00 PM"
StringFromGMTTimeToLocal(86400, 3) will return "Thu Jan
01 16:00:00 1970"
StringFromGMTTimeToLocal(86400, 4) will return "Thu"
StringFromGMTTimeToLocal(86400, 5) will return
"Thursday"
See Also
StringASCII(), StringChar(), StringFromIntg(),
StringFromReal(), StringFromTime(),
StringFromTimeLocal(), StringInString(), StringLeft(),
StringLen(), StringLower(), StringMid(), StringReplace(),
StringRight(), StringSpace(), StringTest(), StringToIntg(),
StringToReal(), StringTrim(), StringUpper(), Text()
StringFromIntg()
Converts an integer value into its string representation in
another base and returns the result.
Category
String
Syntax
SringResult = StringFromIntg( Number, numberBase );
Parameters
Number
Number to convert. Any number or an integer attribute.
numberBase
Base to use in conversion. Any number or an integer
attribute.
Examples
StringFromIntg(26, 2); ' returns "11010"
StringFromIntg(26, 8); ' returns "32"
StringFromIntg(26, 16); ' returns "1A"
StringFromReal()
Converts a real value into its string representation, 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.
e = Display in exponential notation with a lowercase "e."
E = Display in exponential notation with an uppercase
"E."
Examples
StringFromReal(263.355, 2,"f"); ' returns
"263.36";
StringFromReal(263.355, 2,"e"); ' returns
"2.63e2";
StringFromReal(263.55, 3,"E"); ' returns
"2.636E2";
See Also
StringASCII(), StringChar(), StringFromIntg(),
StringFromTime(), StringInString(), StringLeft(),
StringLen(), StringLower(), StringMid(), StringReplace(),
StringRight(), StringSpace(), StringTest(), StringToIntg(),
StringToReal(), StringTrim(), StringUpper(), Text()
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 date 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 seconds since
January 1, 1970 GMT. The value returned reflects the local
time.
Examples
StringFromTime(86400, 1) ' returns "1/2/70"’;
StringFromTime(86400, 2) ' returns "12:00:0 AM";
StringFromTime(86400, 3) ' returns "Fri Jan 02
00:00:00 1970";
StringFromTime(86400, 4) ' returns "Fri";
StringFromTime(86400, 5) ' returns "Friday";
See Also
StringASCII(), StringChar(), StringFromIntg(),
StringFromReal(), StringFromTime(), StringInString(),
StringLeft(), StringLen(), StringLower(), StringMid(),
StringReplace(), StringRight(), StringSpace(), StringTest(),
StringToIntg(), StringToReal(), StringTrim(), StringUpper(),
Text()
StringFromTimeLocal()
Converts a time value (in seconds since Jan-01-1970) into a
particular string represention. The value returned also
represents local time.
Category
String
Syntax
MessageResult=StringFromTimeLocal(SecsSince1-1-70,
StringType);
Parameters
SecsSince1-1-70
Is converted to the StringType 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 adjustments for DST
to the input value.
Example
StringFromTimeLocal(86400, 1) will return
"1/2/70"
StringFromTimeLocal (86400, 2) will return
"12:00:00 AM"
StringFromTimeLocal (86400, 3) will return "Fri
Jan 02 00:00:00 1970"
StringFromTimeLocal (86400, 4) will return "Fri"
StringFromTimeLocal (86400, 5) will return
"Friday"
See Also
StringASCII(), StringChar(), StringFromIntg(),
StringFromReal(), StringFromTime(), StringInString(),
StringLeft(), StringLen(), StringLower(), StringMid(),
StringReplace(), StringRight(), StringSpace(), StringTest(),
StringToIntg(), StringToReal(), StringTrim(), StringUpper(),
Text()
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 attribute.
CaseSens
Determines whether 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(), StringChar(), StringFromIntg(),
StringFromReal(), StringFromTime(), StringLeft(),
StringLen(), StringLower(), StringMid(), StringReplace(),
StringRight(), StringSpace(), StringTest(), StringToIntg(),
StringToReal(), StringTrim(), StringUpper(), Text()
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.
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(), StringChar(), StringFromIntg(),
StringFromReal(), StringFromTime(), StringInString(),
StringLen(), StringLower(), StringMid(), StringReplace(),
StringRight(), StringSpace(), StringTest(), StringToIntg(),
StringToReal(), StringTrim(), StringUpper(), Text()
StringLen()
Returns the length, in characters, of text.
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 return character is ASCII 13.
See Also
StringASCII(), StringChar(), StringFromIntg(),
StringFromReal(), StringFromTime(), StringInString(),
StringLeft(), StringLower(), StringMid(), StringReplace(),
StringRight(), StringSpace(), StringTest(), StringToIntg(),
StringToReal(), StringTrim(), StringUpper(), Text()
StringLower()
Converts all of the upper-case characters in text string to
lower case and returns the result.
Category
String
Syntax
StringResult = StringLower( Text );
Parameter
Text
String to be converted to lower case. Actual string or a
string attribute.
Remarks
Lower-case 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(), StringChar(), StringFromIntg(),
StringFromReal(), StringFromTime(), StringInString(),
StringLeft(), StringLen(), StringMid(), StringReplace(),
StringRight(), StringSpace(), StringTest(), StringToIntg(),
StringToReal(), StringTrim(), StringUpper(), Text()
StringMid()
Extracts a specific number of characters from a starting point
within a string and returns the result.
Category
String
Syntax
StringResult = StringMid( Text, StartChar, Chars );
Parameters
Text
Actual string or a string attribute
StartChar
The position of the first character within the string to
extract. Any number or an integer attribute.
Chars
The total number of characters within the string to return.
Any number or an integer attribute.
Remarks
This function is slightly different than the StringLeft()
function and StringRight() 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(), StringChar(), StringFromIntg(),
StringFromReal(), StringFromTime(), StringInString(),
StringLeft(), StringLen(), StringLower(), StringReplace(),
StringRight(), StringSpace(), StringTest(), StringToIntg(),
StringToReal(), StringTrim(), StringUpper(), Text()
StringReplace()
Replaces or changes specific parts of a provided string and
returns the result.
Category
String
Syntax
StringResult = StringReplace( Text, SearchFor,
ReplaceWith, CaseSens, NumToReplace, MatchWholeWords
);
Parameters
Text
The string to change. Actual string or a string attribute.
SearchFor
The string to search for and replace. Actual string or a
string attribute.
ReplaceWith
The replacement string. Actual string or a string attribute.
CaseSens
Determines whether 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 whether the function limits its replacement to
whole words. (0=no and 1=yes) Any number or an integer
attribute. If MatchWholeWords is turned on (set to 1) and
the SearchFor 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 take a string attribute and replace
characters, words, or phrases.
The StringReplace() function does not recognize special
characters, such as @ # $ % & * ( ). It reads them as
delimiters. For example, if the function StringReplace()
(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(), StringChar(), StringFromIntg(),
StringFromReal(), StringFromTime(), StringInString(),
StringLeft(), StringLen(), StringLower(), StringMid(),
StringRight(), StringSpace(), StringTest(), StringToIntg(),
StringToReal(), StringTrim(), StringUpper(), Text()
StringRight()
Returns the specified number of characters starting at the
rightmost character of text.
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(), StringChar(), StringFromIntg(),
StringFromReal(), StringFromTime(), StringInString(),
StringLeft(), StringLen(), StringLower(), StringMid(),
StringReplace(), StringSpace(), StringTest(), StringToIntg(),
StringToReal(), StringTrim(), StringUpper(), Text()
StringSpace()
Generates a string of spaces either within a string attribute
or within an expression and returns the result.
Category
String
Syntax
StringResult = StringSpace( NumSpaces );
Parameter
NumSpaces
Number of spaces 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(), StringChar(), StringFromIntg(),
StringFromReal(), StringFromTime(), StringInString(),
StringLeft(), StringLen(), StringLower(), StringMid(),
StringReplace(), StringRight(), StringTest(), StringToIntg(),
StringToReal(), StringTrim(), StringUpper(), Text()
StringTest()
Tests the first character of text to determine whether 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() 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() 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(), StringChar(), StringFromIntg(),
StringFromReal(), StringFromTime(), StringInString(),
StringLeft(), StringLen(), StringLower(), StringMid(),
StringReplace(), StringRight(), StringSpace(), StringToIntg(),
StringToReal(), StringTrim(), StringUpper(), Text()
StringToIntg()
Converts the numeric value of a string to an integer value
and returns the result.
Category
String
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(), StringChar(), StringFromIntg(),
StringFromReal(), StringFromTime(), StringInString(),
StringLeft(), StringLen(), StringLower(), StringMid(),
StringReplace(), StringRight(), StringSpace(), StringTest(),
StringToReal(), StringTrim(), StringUpper(), Text()
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 zero (0). If the 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(), StringChar(), StringFromIntg(),
StringFromReal(), StringFromTime(), StringInString(),
StringLeft(), StringLen(), StringLower(), StringMid(),
StringReplace(), StringRight(), StringSpace(), StringTest(),
StringToIntg(), StringTrim(), StringUpper(), Text()
StringTrim()
Removes unwanted spaces from text and returns the result.
Category
String
Syntax
StringResult = StringTrim( Text, TrimType );
Parameter
Text
String that is trimmed of spaces. Actual string or a string
attribute.
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-space character
3 = Remove all spaces except for single spaces between
words
Remarks
The text is searched for white-spaces (ASCII 0x09-0x0D or
0x20) that are to be removed. TrimType determines the
method 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() function can remove ALL spaces from a
specified a string attribute. Simply replace all the space
characters with a "null."
See Also
StringASCII(), StringChar(), StringFromIntg(),
StringFromReal(), StringFromTime(), StringInString(),
StringLeft(), StringLen(), StringLower(), StringMid(),
StringReplace(), StringRight(), StringSpace(), StringTest(),
StringToIntg(), StringToReal(), StringUpper(), Text()
StringUpper()
Converts all the lower-case characters in text to upper case
and returns the result.
Category
String
Syntax
StringResult = StringUpper( Text );
Parameter
Text
String to be converted to upper case. Actual string or a
string attribute.
Remarks
Upper-case characters, symbols, numbers, and other special
characters are not affected.
Examples
StringUpper("abcd"); ' returns "ABCD";
StringUpper("22.2 is the value"); ' returns "22.2
IS THE VALUE";
See Also
StringASCII(), StringChar(), StringFromIntg(),
StringFromReal(), StringFromTime(), StringInString(),
StringLeft(), StringLen(), StringLower(), StringMid(),
StringReplace(), StringRight(), StringSpace(), StringTest(),
StringToIntg(), StringToReal(), StringTrim(), Text()
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;
Text()
Converts a number to text based on a specified format.
Category
String
Syntax
StringResult = Text( Number, Format );
Parameters
Number
Any number or numeric attribute.
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;
Trunc()
Truncates a real (floating point) number by simply
eliminating the portion to the right of the decimal point,
including the decimal point, and returns the result.
Category
Math
Syntax
NumericResult = Trunc( Number );
Parameter
Number
Any number or numeric attribute.
Remarks
This function accomplishes the same result as placing the
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()
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 return write status.
Return Value
The return statuses are:
• MxStatusOk
• MxStatusPending
• MxStatusWarning
• MxStatusCommunicationError
• MxStatusConfigurationError
• MxStatusOperationalError
• MxStatusSecurityError
• MxStatusSoftwareError
• MxStatusOtherError
Remarks
If the attribute 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);
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.
ControlType
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()
WWExecute()
Using the DDE protocol, 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 execute
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
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 TestMacro
runs):
[Run("Macro1!TestMacro")];
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(),
StringFromIntg(), or StringFromReal() functions. Actual
string or a string attribute.
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
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);
WWRequest()
Using the DDE protocol, makes a one-time request for a
value from a particular application, topic, and item and
returns the status.
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
attribute.
Attribute
A string attribute, enclosed 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
Example
The following statement requests a value from an Excel
spreadsheet cell and converts the resulting string into a
value:
WWRequest("excel","[Book1.xls]sheet1","r1c1",Result);
Value=StringToReal(Result);
See Also
StringToIntg(), StringToReal()
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.
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 DST
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
PST 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"
DIM LocVar1;
is equivalent to:
where:
sign :: = + | -
non-zero_digit ::= 1-9
digit ::= 0-9
where:
sign ::= + or -
hexdigit ::= 0-9, A-F, a-f (only eight hexdigits [32-bits] are
allowed)
Allowed format for floats is as follows:
FloatConst ::= [<sign>] <digit>* .<digit>+
[<exponent>;]
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)
• WHILE Loop
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;
{Default. Should never occur in this
example};
ENDIF;
Where:
• analog_var is a variable of type Integer, Float, Real, or
Double.
See Sample Scripts on page 81 for ideas about using this type
of control structure.
Where:
• object_variable is a dimmed variable.
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_expression is an expression that can be
evaluated as a Boolean as defined in the description of
IF…THEN statements.
It is possible to exit the loop from the body of the loop
through the EXIT WHILE statement.
The WHILE loop is executed as follows:
1 The script evaluates whether the Boolean_expression is
true or not. If not, program execution 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 EXIT WHILE statement.
3 Steps 1 through 2 are repeated.
See Sample Scripts on page 81 for ideas about using this type
of control structure.
~ Complement
- Negation
NOT Logical NOT
Precedence Operator
1 (highest) ( )
2 - (negation), NOT, ~
3 **
4 *, /, MOD
5 +, - (subtraction)
6 SHL, SHR
7 <, >, <=, >=
8 ==, <>
9 &
10 ^
11 |
12 =
13 AND
14 (lowest) OR
Parentheses ( )
Parentheses specify the correct order of evaluation for the
operator(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 parentheses. If the precedence is in question or
needs to be overridden, use parentheses.
In the example below, parentheses add B and C together
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 returns 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.
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 the left side of
the assignment 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.
Chapter 3
Sample Scripts
The sample scripts include:
• Accessing an Excel Spreadsheet Using an Imported Type
Library
• Accessing an Excel Spreadsheet Using CreateObject
• Accessing an Office XP Excel Spreadsheet Using an
Imported Type Library
wb = app.Workbooks.Add();
ws = wb.ActiveSheet;
ws.get_Range("A1").Value = 1000;
ws.get_Range("A2").Value = 1000;
ws.get_Range("A3").Value = "=A1+A2";
LogMessage(ws.get_Range("A3").Value);
wb.Close(false);
app = CreateObject("Excel.Application");
wb = app.Workbooks.Add();
ws = wb.ActiveSheet;
ws.Range("A1") = 20;
ws.Range("A2") = 30;
ws.Range("A3") = "=A1*A2";
LogMessage(ws.Range("A3").Value);
wb.Close(false);
a1 = ws.Range("A1");
a2 = ws.Range("A2");
a3 = ws.Range("A3");
a1.Value = 1000;
a2.Value = 2000;
a3.Value = "=A1*A2";
LogMessage(a3.Value);
wb.Close(true, "c:\temp.xls", false);
dim wr as WeatherRetriever;
wr = new WeatherRetriever;
me.temperature = wr.GetTemperature(me.zipcode);
dim m as SendMail.Message;
m = new SendMail.Message;
m.SendSimpleMail
(
{to: } "<type valid email address here>",
{from: } "<type valid email address here>",
{subject: } "Reminder to self",
{body: } "Pick up eggs and milk on your way home."
);
connection = new
System.Data.SqlClient.SqlConnection("server=(local);
uid=sa;database=northwind");
connection.Open();
regionId.Value = 5;
regionDesc.Value = "Europe";
command.ExecuteNonQuery();
regionId.Value = 6;
regionDesc.Value = "South America";
command.ExecuteNonQuery();
connection.Close();
numbers[1] = "one";
numbers[2] = "two";
numbers[3] = "three";
LogMessage(numbers[3]);
x[1, 1] = 1;
x[1, 2] = 2;
x[1, 3] = 3;
x[2, 1] = 4;
x[2, 2] = 5;
x[2, 3] = 6;
LogMessage(x[2, 3]);
i = 1234;
LogMessage("Total cost: " +
i.ToString("$#,###,###.00"));
t = Now();
LogMessage("The current time is: " +
t.ToString("hh:mm:ss") + ".");
connection = new
System.Data.SqlClient.SqlConnection("server=(local);
uid=sa;database=northwind");
connection.Open();
while reader.Read()
LogMessage(reader("CompanyName"));
endwhile;
reader.Close();
connection.Close();
' Startup
counter = new System.Diagnostics.PerformanceCounter;
counter.CategoryName = "Processor";
counter.CounterName = "% Processor Time";
counter.InstanceName = "0";
' Execute
me.PercentProcessorTime = counter.NextValue();
sr = System.IO.File.OpenText("c:\MyFile.txt");
while sr.Peek() > -1
LogMessage(sr.ReadLine());
endwhile;
sr.Close();
’ Startup
connection = new
System.Data.SqlClient.SqlConnection("server=(local);
uid=sa;database=northwind");
connection.Open();
System.AppDomain.CurrentDomain.SetData
("NorthwindConnection", connection);
’ Shutdown
Remove("NorthwindConnection");
connection.Close();
session = CreateObject("MAPI.Session");
session.Logon("Employee");
msg = session.Outbox.Messages.Add();
msg.Recipients.Add("<type valid email address here>");
msg.Subject = "Reminder to self";
msg.Text = "Pick up eggs and milk on your way home.";
msg.Send();
session.Logoff();
request = System.Net.WebRequest.Create
(
"http://www.srh.noaa.gov/data/forecasts/zipcity.php?in
putstring=" +
System.Web.HttpUtility.UrlEncode(me.CityState)
);
reader = new
System.IO.StreamReader(request.GetResponse().GetResp
onseStream());
regex = new
System.Text.RegularExpressions.Regex("<br><br>(.*)&d
eg;F<br>");
match = regex.Match(reader.ReadToEnd());
me.temperature = match.Groups(1);
sw = System.IO.File.CreateText("C:\MyFile.txt");
sw.WriteLine("one");
sw.WriteLine("two");
sw.WriteLine("three");
sw.Close();
s = "obj1.Attr1";
x.BindTo(s); ' where s is any expression that
returns a string.
' The string should be an ArchestrA reference.
Glossary
ApplicationEngine A real-time engine that hosts and executes the runtime logic
(AppEngine) contained within AutomationObjects.
Application Server The name of the product inside FactorySuite that forms a
central application backbone. It includes the Galaxy
Repository, one IDE, a WinPlatform, an AppEngine, and a
basic library of ApplicationObjects.
block read group A DAGroup triggered by the user or another object. It reads a
block of data from the external data source and indicates the
completion status.
block write group A DAGroup triggered by the user or another object after all
the required data items are set. The block of data is then sent
to the external data device. When the block write is complete,
it indicates the completion status.
Change Log The history log tracking the life cycle activities of ArchestrA,
such as object creation, check-in/check-out, deployment, save,
rename, undeploy, undo checkout, override checkout and
assignment.
checkpoint The act of saving on disk the configuration, state, and all
associated data necessary to support automatic restart of a
running AutomationObject. The restarted object has the
same configuration, state, and associated data as the last
checkpoint image on disk.
contained name The name of an object as it exists within the context of its
container. For example, a valve object with the TagName
“Valve101” can be contained within a reactor and given the
ContainedName “Inlet” within the context of its container.
The ContainedName must be unique within the context of
the containing object.
Data Access Server The server executable that interfaces with DINetwork
(DAServer) Objects and DIDevice Objects in the ArchestrA environment
or with any third-party client, using various client protocols
including OPC, DDE and SuiteLink.
Data Access Server A developer tool to build Data Access Servers (DAServers).
Toolkit (DAS Toolkit)
event record The data that is transferred about the system and logged
when a defined event changes state. For example, an analog
crosses its high level limit or an acknowledgement is made.
hierarchical name The fully qualified name of a contained object, including the
container object's TagName. For example, a valve object with
a contained name of “Inlet” within a reactor named
“Reactor1” would have the HierarchicalName
“Reactor1.Inlet”.
The valve object also has a unique TagName distinct from its
HierarchicalName, such as Valve101.
historical storage The time series data storage system, that compresses and
system stores high volumes of time series data for latter retrieval.
Application Server leverages InSQL as its historical storage
system.
Package Definition The standard description file that contains the configuration
File (.aaPDF) data and implementation code for a base template. File
extension is typically .aaPDF.
Package File The result of the export function of the IDE. The description
(.aaPKG) file that contains the configuration data and implementation
code for a template and/or instance. File extension is
typically .aaPKG.
scan group A DAGroup that requires only the update interval defined,
and the data is retrieved at the requested rate.
Index
Numerics B
32-bit integers, complements 77 base template, definition 100
Bitwise AND ( & ) 78
A block read group, definition 100
Abs(), script function 18 block write group, definition 100
access
Excel spreadsheets using an imported C
type library, example script 82 call web services, get the temperature for
Excel spreadsheets using a specified zip code 85
CreateObject 83 call web services, send email 86
Office XP Excel spreadsheets using change log, definition 100
imported type library 84 check-in, definition 100
ActivateApp(), script function 19 check-out, definition 100
addition ( + ) 77 checkpoint, definition 100
AND 79 comparisons ( , =, ==, ) 79
ApplicationEngine, definition 99 complement ( ~ ) 77
ApplicationObject Toolkit, definition 99 concatenating
ApplicationObject, definition 99 entries 10
ArcCos(), script function 19 memory types 77
ArcSin(), script function 20 message types 77
ArcTan(), script function 20 containment, definition 101
Area, definition 99 converting 77
assignment ( = ) 79 positive integers 77
assignment, definition 100 real numbers 77
attribute reference string, definition 100 Cos(), script function 21
attribute, definition 100
AutomationObject, definition 100