0% found this document useful (0 votes)
2 views390 pages

Programma Di Script (Inglese)

The document provides an overview of Script programs used in the EcoStruxure Building Operation software, detailing their creation, workflow, and components. It explains how to write instructions for controlling building systems and the importance of binding variables to points or values. Additionally, it outlines the Script Editor's role in developing these programs and the execution flow of tasks within the system.

Uploaded by

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

Programma Di Script (Inglese)

The document provides an overview of Script programs used in the EcoStruxure Building Operation software, detailing their creation, workflow, and components. It explains how to write instructions for controlling building systems and the importance of binding variables to points or values. Additionally, it outlines the Script Editor's role in developing these programs and the execution flow of tasks within the system.

Uploaded by

magistrigiuseppe
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

59 Script Introduction

Topics
Script Overview
Script Workflow
Script Programs
Creating a Script Program
Opening a Script Program or Function
Script Keywords
Script Program Flow
FallThru Program Flow
Looping Program Flow
Script Program Instructions
Lines and Line Numbers
Reserved Words
Script Reserved Words
Bindings and Script Programs
Binding Values in Script Editor Using a Binding Template
Local Variable Declarations
Tasks
Adding a Task to a Program
Program Cycles in EcoStruxure Building Operation Software
Configuring the Execution Precedence for a Program
59 Finding Cycles in a Task
59 Script Introduction
59.1 Script Overview

59.1 Script Overview


Script programs are text-based instructions that tell the EcoStruxure BMS server to
take some kind of action to control a building.
For example, you can tell the EcoStruxure BMS server to take the following actions:
• OPEN THE DAMPER
• CLOSE THE VALVE
Each instruction is a complete text-command description. Program instructions are
listed in the order in which the controller must perform them.

59.1.1 Script Workflow


The Script workflow allows you to create (and edit) Script programs in the
EcoStruxure Building Operation database.
For more information, see section 59.2 “Script Workflow” on page 1601.

59.1.2 Script Programs


You can store your Script programs like a common document and include them
later in other projects for use in your control system. You can also write programs
that perform very complex control system decisions, such as controlling lighting,
boilers, and air handling units at multiple sites.
For more information, see section 59.3 “Script Programs” on page 1605.

59.1.3 Script Functions


A function is a routine designed to carry out an often repeated task or series of
tasks. Your Script function then becomes a subroutine that can be called whenever
that particular action needs to be performed.
For more information, see section 60.97 “Script Functions” on page 1795.

59.1.4 Script Program Components


Script programs are composed of the following components that allow you to
develop your programs quickly and easily:
• Program constants
• Program operators
• Program statements
• Expressions
• Variables
For example, you can create program statements with everyday language, so you
do not need to be a programmer to learn how to program with Script.

04-20006-02-en, March 2019 Technical


1599
59 Script Introduction
59.1 Script Overview

For more information, see section 60.1 “Script Program Components” on page
1651.

59.1.5 Script Editor Overview


The Script Editor is a text programming tool you use to create Script programs that
control and monitor building automation systems. Script Editor opens when you
create or edit a Script program in WorkStation.
When you open a new program in the Script Editor, you begin by declaring local
variables for the program input and output followed by names for those variables.
The program starts with zero or more of these declarations followed by one or more
lines specifying the operation(s) to perform.
For more information, see section 61.1 “Script Editor Overview” on page 1885.

59.1.6 Script Web Services


Web Services are programmable applications accessible from standard Internet
protocols, like HTTP and XML. Web Services help solve application integration
challenges by allowing applications to communicate with one another independent
of the target, host operating system, object model, or programming language.
For more information, see section 62.1 “Script Web Services” on page 1937.

Technical 04-20006-02-en, March 2019


1600
59 Script Introduction
59.2 Script Workflow

59.2 Script Workflow


The Script workflow allows you to create (and edit) Script programs in the
EcoStruxure Building Operation database.
The following flowchart describes the basic steps required to create (or edit) a
Script program. Related information can be found in the sections after the
flowchart. If you want to edit an existing Script program, select the program in the
SmartX server and then continue from the second step.

04-20006-02-en, March 2019 Technical


1601
59 Script Introduction
59.2 Script Workflow

Figure: Script Workflow

Create a Script program


In WorkStation, create a Script program under a SmartX server.

Technical 04-20006-02-en, March 2019


1602
59 Script Introduction
59.2 Script Workflow

For more information, see section 59.4 “Creating a Script Program” on page 1607.

Open your program in Script Editor


In WorkStation, select and open your program in Script Editor.
For more information, see section 59.5 “Opening a Script Program or Function” on
page 1608.

Declare local variables


In Script Editor, declare local variables for the program inputs and outputs followed
by names for the variables.
For more information, see section 59.16 “Local Variable Declarations” on page
1630.

Create program lines


In your Script program, create program lines to specify the type of actions you want
the program to perform.
For more information, see section 61.9 “Adding a Line” on page 1903.

Create points or values


In WorkStation, create points or values.
For more information, see section 92.13 “Creating a BACnet Point in an
EcoStruxure BMS Server” on page 3132.
For more information, see section 92.27 “Creating a BACnet Value” on page 3181.

Bind variables to the points or values


In WorkStation, bind the variables to the points or values you created to view the
output.

Note
In Script, you can bind using either the Bindings view in WorkStation, or the
Bindings view in Script Editor. For more information, see section 46.10 “Binding
Values Using a Binding Template” on page 1246.

Check and save your program


In Script Editor, check your program for errors and then save the program.
For more information, see section 61.15 “Checking and Saving a Script Program”
on page 1910.

Select the task


In WorkStation, select the task in which you wish to include your Script program.
For more information, see section 59.18 “Adding a Task to a Program” on page
1635.

Execute your Script program


In WorkStation, execute your Script program.
For more information, see section 61.16 “Executing a Script Program” on page
1911.

04-20006-02-en, March 2019 Technical


1603
59 Script Introduction
59.2 Script Workflow

Store and reuse your programs


In WorkStation, store your programs like a common document and import them
later for reuse in other projects.
For more information, see section 61.17 “Importing Script Program Code” on page
1912.

Technical 04-20006-02-en, March 2019


1604
59 Script Introduction
59.3 Script Programs

59.3 Script Programs


A Script program consists of a set of instructions or statements that direct the
EcoStruxure BMS server to perform one or more operations. Program statements
are written with Script words, known as keywords.

59.3.1 Script Keywords


Script keywords are arranged in a predefined structure with their own syntax.
According to the rules of that syntax, certain parameters and values are allowed or
not allowed to follow a keyword.
For more information, see section 59.6 “Script Keywords” on page 1609.

59.3.2 Script Program Instructions


The Script programming language consists of a set of instructions that tells the
EcoStruxure BMS server what to do. Each instruction is a complete text-command
description that tells the EcoStruxure BMS server to take some type of specific
action to control a building. Program instructions are listed in the order in which the
controller must perform them.
For more information, see section 59.10 “Script Program Instructions” on page
1620.

59.3.3 Script Program Flow


Script programs tell an EcoStruxure BMS server to perform numerous actions, such
as increasing the heat, locking doors, and printing reports. The program
instructions that command these actions are arranged and executed in a certain
order, known as a program flow.
For more information, see section 59.7 “Script Program Flow” on page 1616.

59.3.4 Tasks
Function block and Script programs must be connected to tasks in order to run.
You access Tasks from the Properties dialog box.
The task is a property of the object that defines the program cycles.
When you create a new function block or Script program, Task 3 is the default. This
means that one program cycle executes in 1000 ms.
For more information, see section 59.17 “Tasks” on page 1634.

04-20006-02-en, March 2019 Technical


1605
59 Script Introduction
59.3 Script Programs

59.3.5 Program Cycles in EcoStruxure Building


Operation Software
All programs are executed in the order they are bound in the EcoStruxure Building
Operation software. For example, in programs that are executed in a straight order
or in any similar configuration, Program 4 runs after Program 3 that runs after
Program 2 that runs after Program 1. The first program to be executed is Program
1.
For more information, see section 59.19 “Program Cycles in EcoStruxure Building
Operation Software” on page 1636.

59.3.6 Bindings and Script Programs


A binding is an association between a local variable (numeric, string, datetime,
function) within a Script program and a property of an object in the system. The use
of bindings increases the flexibility of the building automation system.
For more information, see section 59.14 “Bindings and Script Programs” on page
1628.

Technical 04-20006-02-en, March 2019


1606
59 Script Introduction
59.4 Creating a Script Program

59.4 Creating a Script Program


You create a Script program to import existing program code or to program new
logic for an EcoStruxure BMS server using Script Editor.
For more information, see section 59.3 “Script Programs” on page 1605.

To create a Script program


1. In WorkStation, in the System Tree pane, select the EcoStruxure BMS
server or folder where you want to create the script program.
2. On the File menu, point to New and then click Program.
3. In the Create Object wizard, in the object type list, select Script Program.
4. In the Name box, type a name for the script program.
5. In the Description box, type a description for the script program.
6. Click Create.

04-20006-02-en, March 2019 Technical


1607
59 Script Introduction
59.5 Opening a Script Program or Function

59.5 Opening a Script Program or Function


You open a Script program or function in Script Editor to enter program
instructions.
For more information, see section 59.3 “Script Programs” on page 1605.

To open a Script program or function


1. In WorkStation, in the System Tree pane, select the Script program or
function.
2. On the Actions menu, click Edit.
The Script program or function is now open and ready for input.

Technical 04-20006-02-en, March 2019


1608
59 Script Introduction
59.6 Script Keywords

59.6 Script Keywords


Script keywords are arranged in a predefined structure with their own syntax.
According to the rules of that syntax, certain parameters and values are allowed or
not allowed to follow a keyword.

59.6.1 A-D
This table contains keywords that begin with the lettters A - D.
A B C D

ABS BASEDON...GOTO CEILING DATE


For more information, For more information, For more information, For more information,
see section 60.118 see section 60.48 see section 60.132 see section 60.81
“ABS” on page 1824. “BASEDON...GOTO” “CEILING” on page “DATE” on page
on page 1730. 1840. 1777.

ACOS BITAND CHR DATETIME


For more information, For more information, For more information, For more information,
see section 60.158 see section 60.16 see section 60.145 see section 60.41
“ACOS” on page “BITAND” on page “CHR” on page “DATETIME” on page
1875. 1678. 1860. 1716.

AND BITNOT CONTINUE DAYOFMONTH


For more information, For more information, For more information, For more information,
see section 60.21 see section 60.17 see section 60.50 see section 60.82
“AND” on page “BITNOT” on page “CONTINUE” on “DAYOFMONTH” on
1683. 1679. page 1733. page 1778.

ARG BITOR COS DAYOFYEAR


For more information, For more information, For more information, For more information,
see section 60.40 see section 60.18 see section 60.162 see section 60.83
“ARG” on page “BITOR” on page “COS” on page “DAYOFYEAR” on
1715. 1680. 1879. page 1779.

ASC BITXOR DIFFTIME


For more information, For more information, For more information,
see section 60.144 see section 60.19 see section 60.155
“ASC” on page 1859. “BITXOR” on page “DIFFTIME” on page
1681. 1871.

ASIN BREAK DIVIDED BY


For more information, For more information, For more information,
see section 60.159 see section 60.49 see section 60.27
“ASIN” on page “BREAK” on page “DIVIDED BY” on
1876. 1732. page 1694.

ATAN Buffered
For more information, For more information,
see section 60.160 see section 60.63
“ATAN” on page “Buffered” on page
1877. 1755.

04-20006-02-en, March 2019 Technical


1609
59 Script Introduction
59.6 Script Keywords

Continued
A B C D

ATAN2
For more information,
see section 60.161
“ATAN2” on page
1878.

AVERAGE
For more information,
see section 60.137
“AVERAGE” on page
1845.

59.6.2 E-H
This table contains keywords that begin with the letters E - H.
E F G H

EQUALS FACTORIAL GetBufferSize HOD


For more information, For more information, For more information, For more information,
see section 60.22 see section 60.120 see section 60.111 see section 60.84
“EQUALS” on page “FACTORIAL” on “GetBufferSize” on “HOD” on page
1686. page 1826. page 1814. 1780.

ERRORS FAILURE GetBufferedValue HOUR


For more information, For more information, For more information, For more information,
see section 60.94 see section 60.8 see section 60.112 see section 60.85
“ERRORS” on page “Failure” on page “GetBufferedValue” “HOUR” on page
1792. 1662. on page 1816. 1781.

EXPONENTIAL FLOOR GOTO


For more information, For more information, For more information,
see section 60.119 see section 60.133 see section 60.52
“EXPONENTIAL” on “FLOOR” on page “GOTO” on page
page 1825. 1841. 1737.

FOR...NEXT
For more information,
see section 60.51
“FOR...NEXT” on
page 1734.

FREEMEM
For more information,
see section 60.95
“FREEMEM” on page
1793.

Technical 04-20006-02-en, March 2019


1610
59 Script Introduction
59.6 Script Keywords

59.6.3 I-N
This table contains keywords that begin with the letters I -N.
I L M N

IF...THEN...ELSE LEFT MAXIMUM NOT


For more information, For more information, For more information, For more information,
see section 60.53 see section 60.146 see section 60.138 see section 60.24
“IF...THEN...ELSE” “LEFT” on page “MAXIMUM” on page “NOT” on page 1690.
on page 1740. 1861. 1847.

INPUT LENGTH MAXITEM NUMERIC


For more information, For more information, For more information, For more information,
see section 60.62 see section 60.147 see section 60.139 see section 60.43
“INPUT” on page “LENGTH” on page “MAXITEM” on page “NUMERIC” on page
1754. 1862. 1849. 1722.

IS... LINE MID NUMTOSTR


For more information, For more information, For more information,
see section 60.23 see section 60.148 see section 60.114
“IS...” on page 1687. “MID” on page 1863. “NUMTOSTR” on
page 1818.

LN MINIMUM
For more information, For more information,
see section 60.121 see section 60.140
“LN” on page 1827. “MINIMUM” on page
1851.

LOG MINITEM
For more information, For more information,
see section 60.122 see section 60.141
“LOG” on page “MINITEM” on page
1828. 1853.

MINUS
For more information,
see section 60.28
“MINUS” on page
1695.

MINUTE
For more information,
see section 60.86
“MINUTE” on page
1782.

MOD
For more information,
see section 60.29
“MOD” on page
1696.

04-20006-02-en, March 2019 Technical


1611
59 Script Introduction
59.6 Script Keywords

Continued
I L M N

MONTH
For more information,
see section 60.87
“MONTH” on page
1783.

MOVE
For more information,
see section 60.54
“MOVE” on page
1744.

59.6.4 O-S
This table contains keywords that begin with the letters O - S.
O P R S

OFF P RANDOM SCAN


For more information, For more information, For more information, For more information,
see section 60.9 see section 60.35 “P” see section 60.123 see section 60.96
“OFF” on page 1663. on page 1703. “RANDOM” on page “SCAN” on page
1829. 1794.

ON PASSED ReadProperty SELECT CASE


For more information, For more information, For more information, For more information,
see section 60.10 see section 60.130 see section 60.127 see section 60.57
“ON” on page 1664. “PASSED Function” “ReadProperty” on “SELECT CASE” on
on page 1838. page 1834. page 1748.

-ON PLUS Relinquish SECOND


For more information, For more information, For more information, For more information,
see section 60.11 “- see section 60.30 see section 60.128 see section 60.88
ON” on page 1665. “PLUS” on page “Relinquish” on page “SECOND” on page
1697. 1835. 1785.

OR PRINT Repeat...Until SEARCH


For more information, For more information, For more information, For more information,
see section 60.25 see section 60.36 see section 60.55 see section 60.150
“OR” on page 1691. “PRINT” on page “Repeat...Until” on “SEARCH” on page
1704. page 1745. 1865.

OUTPUT PUBLIC RETURN SET


For more information, For more information, For more information, For more information,
see section 60.64 see section 60.65 see section 60.56 see section 60.37
“OUTPUT” on page “PUBLIC” on page “RETURN” on page “SET” on page 1710.
1756. 1757. 1746.

Technical 04-20006-02-en, March 2019


1612
59 Script Introduction
59.6 Script Keywords

Continued
O P R S

RIGHT SIN
For more information, For more information,
see section 60.149 see section 60.163
“RIGHT” on page “SIN” on page 1880.
1864.

ROUND StandardDeviatio
n
For more information,
see section 60.134 For more information,
“ROUND” on page see section 60.142
1842. “StandardDeviation”
on page 1855.

STOP
For more information,
see section 60.58
“STOP” on page
1750.

STRING
For more information,
see section 60.44
“STRING” on page
1724.

STRINGFILL
For more information,
see section 60.152
“STRINGFILL” on
page 1867.

STRTODATE
For more information,
see section 60.115
“STRTODATE” on
page 1819.

STRTONUM
For more information,
see section 60.116
“STRTONUM” on
page 1821.

SQRT
For more information,
see section 60.124
“SQRT” on page
1830.

SUM
For more information,
see section 60.125
“SUM” on page
1831.

04-20006-02-en, March 2019 Technical


1613
59 Script Introduction
59.6 Script Keywords

59.6.5 T-Y
This table contains keywords that begin with the letters T - Y.
T W Y

TAB WAIT YEAR


For more information, see For more information, see For more information, see
section 60.153 “TAB” on section 60.59 “WAIT” on section 60.92 “YEAR” on
page 1869. page 1751. page 1790.

TAN WebService
For more information, see For more information, see
section 60.164 “TAN” on section 60.46 “ Webservice”
page 1881. on page 1727.

TIMEPIECE WEEKDAY
For more information, see For more information, see
section 60.156 “TIMEPIECE” section 60.91 “WEEKDAY”
on page 1873. on page 1788.

TOD WHILE
For more information, see For more information, see
section 60.89 “TOD” on section 60.60 “WHILE” on
page 1786. page 1752.

TD WriteProperty
For more information, see For more information, see
section 60.78 “TD” on page section 60.129
1772. “WriteProperty” on page
1836.

TH
For more information, see
section 60.77 “TH” on page
1771.

THE
For more information, see
section 60.45 “THE” on page
1726.

TIMES
For more information, see
section 60.31 “TIMES” on
page 1698.

TM
For more information, see
section 60.76 “TM” on page
1770.

TS
For more information, see
section 60.75 “TS” on page
1769.

Technical 04-20006-02-en, March 2019


1614
59 Script Introduction
59.6 Script Keywords

Continued
T W Y

TURN
For more information, see
section 60.38 “TURN” on
page 1712.

TRUNCATE
For more information, see
section 60.135 “TRUNCATE”
on page 1843.

04-20006-02-en, March 2019 Technical


1615
59 Script Introduction
59.7 Script Program Flow

59.7 Script Program Flow


Script programs tell an EcoStruxure BMS server to perform numerous actions, such
as increasing the heat, locking doors, and printing reports. The program
instructions that command these actions are arranged and executed in a certain
order, known as a program flow.
Script has two types of program flows: FallThru and Looping.

59.7.1 FallThru Program Flow


A FallThru program executes the program lines in the sequential order in which you
list them: from the first line to the last line. Therefore, the program flows, or “falls
thru” the entire sequence of instructions.
For more information, see section 59.8 “FallThru Program Flow” on page 1617..

59.7.2 Looping Program Flow


A Looping program remains on one line until the program is instructed to go to
another line.
For more information, see section 59.9 “Looping Program Flow” on page 1619.

Technical 04-20006-02-en, March 2019


1616
59 Script Introduction
59.8 FallThru Program Flow

59.8 FallThru Program Flow


A FallThru program executes the program lines in the sequential order in which you
list them: from the first line to the last line. Therefore, the program flows, or “falls
thru” the entire sequence of instructions.
In the following FallThru program example, when the controller determines that the
temperature is not less than 70 and not greater than 75, the program flows to the
next consecutive line (labeled “Pumping”).

Figure: Script FallThru Program Example


FallThru programs start when prompted by a specific point or system variable. Any
point or system variable can automatically start a progam when its value changes.
The program is triggered by the action of the point or system variable. Once you
create a point or choose a system variable, the program you want to run is attached
through the trigger.
For example, suppose you write a program to control a circulating fan. You want
the fan to turn on when the room is occupied and turn off when the room is not
occupied. In your program, you could choose to use a point called OCCUPIED that
triggers the following program.

Figure: FallThru Program Trigger

04-20006-02-en, March 2019 Technical


1617
59 Script Introduction
59.8 FallThru Program Flow

You configure the trigger for the OCCUPIED point on the b3 field controller. Note
that you can only configure triggers on the b3 device. For more information, see
section 100.10 “Configuring Script FallThru Program Triggers in a b3 BACnet
Device” on page 3746..

Technical 04-20006-02-en, March 2019


1618
59 Script Introduction
59.9 Looping Program Flow

59.9 Looping Program Flow


A Looping program remains on one line until the program is instructed to go to
another line.
In the following Looping program example, the program continuously scans the
CheckOccupied line to determine if the office is occupied. If so, the program turns
on the office lights and fan. If not, the program turns them off.

Figure: Looping Program Example

04-20006-02-en, March 2019 Technical


1619
59 Script Introduction
59.10 Script Program Instructions

59.10 Script Program Instructions


The Script programming language consists of a set of instructions that tells the
EcoStruxure BMS server what to do. Each instruction is a complete text-command
description that tells the EcoStruxure BMS server to take some type of specific
action to control a building. Program instructions are listed in the order in which the
controller must perform them.
Script has two types of program instructions: conditional and unconditional. A
conditional instruction establishes criteria that have to be met before the instruction
can be executed and the task performed by anEcoStruxure BMS server:
IF Temp is 78 THEN Turn on Fan
An unconditional instruction directs a specific action without establishing any criteria
before the action can occur:
Turn on Fan
You can use “the” in a Script program instruction to make the statement easier to
read. The following examples show how “the” improves the readability of a
statement:
IF FAN IS ON THEN TURN ON PUMP
IF THE FAN IS ON THEN TURN ON THE PUMP

59.10.1 Lines and Line Numbers


A line acts as the basic execution unit of a Script program. Lines consist of one or
more statements that belong together under one label. The first or only line of a
program does not need to have a label. You can also add a comment here
preceded by a single quote ('), to help explain the operation of the program.
Comments are not acted upon by the program's logic.
For example, you can create a simple program that contains a single declaration
followed by a single program line:
Numeric i ‘Declaration of a local variable of type Numeric
i = 1 ‘Single program line
You can add a label to the line:
Numeric i
Line Setting
i=1
In this example, the line is labeled with the Line keyword or a colon after the line
name (but not both). All of the statements following the “Setting” label are then part
of that line until another Line label is encountered.
For more information, see section 59.11 “Lines and Line Numbers” on page 1622.

59.10.2 Verb and Verb Elements


To construct a Script program instruction, you must follow these guidelines:
• Use only one verb

Technical 04-20006-02-en, March 2019


1620
59 Script Introduction
59.10 Script Program Instructions

• Use one verb element or a list of verb elements after the verb
For example, these Script program instructions are valid:
OPEN THE DAMPER
CLOSE THE VALVE
Open the damper, vent1, vent2, vent3, and vent4
Close the firstvalve, secondvalve, thirdvalve
You cannot use two verbs, such as open and close, in the same instruction.
Therefore, this instruction is invalid:
OPEN THE DAMPER AND CLOSE THE VALVE

59.10.3 Case Sensitivity


Script instructions are not case sensitive. For example, the uppercase letter R and
the lowercase letter r are not treated differently. In Script, the following names are
treated the same:
RoomTemp1
ROOMTEMP1
RoomtemP1

59.10.4 Reserved Words


Reserved words are those words used as system constants, keywords, system
functions, and system variables that are reserved as part of the Script programming
language. Being familiar with these words helps avoid naming errors. You cannot
use reserved words as line label or program variables.
Before importing older programs to your controllers, check the program for
reserved words and remove or replace them. For more information, see section
59.12 “Reserved Words” on page 1623.

04-20006-02-en, March 2019 Technical


1621
59 Script Introduction
59.11 Lines and Line Numbers

59.11 Lines and Line Numbers


A line acts as the basic execution unit of a Script program. Lines consist of one or
more statements that belong together under one label. The first or only line of a
program does not need to have a label. You can also add a comment here
preceded by a single quote ('), to help explain the operation of the program.
Comments are not acted upon by the program's logic.
You label a line with the LINE keyword or a colon after the line name:

Figure: Line Labeling


In the previous example, all of the statements following the “BEGIN” label are part of
that line, until another LINE label is encountered. Line labels are limited to 16
characters, including underscores, periods, and numbers.
Statements in a line are indented to emphasize their relationship to the line label.
Ideally, you should always form lines this way.
You can number the lines in your program window in Script for easy reference while
programming. When you enable this feature, line numbers display in the left hand
side of the Script Editor.

Figure: Line Numbering

Technical 04-20006-02-en, March 2019


1622
59 Script Introduction
59.12 Reserved Words

59.12 Reserved Words


Reserved words are those words used as system constants, keywords, system
functions, and system variables that are reserved as part of the Script programming
language. Being familiar with these words helps avoid naming errors. You cannot
use reserved words as line label or program variables.
Before importing older programs to your controllers, check the program for
reserved words and remove or replace them.

59.12.1 Script Constants


Script constants, including class names, are listed in alphabetical order in the
following tables. You cannot use Script constants as a line label or program
variable.
For more information, see section 60.6 “Script Constants” on page 1659.

59.12.2 Script Reserved Words


Script reserved words are listed in alphabetical order in the following tables. You
cannot use reserved words as a line label or program variable.
For more information, see section 59.13 “Script Reserved Words” on page 1624.

04-20006-02-en, March 2019 Technical


1623
59 Script Introduction
59.13 Script Reserved Words

59.13 Script Reserved Words


Script reserved words are listed in alphabetical order in the following tables. You
cannot use reserved words as a line label or program variable.

Table: Reserved Words A-H


A B C D E F G H

Above Basedon C Date E Fact GetObjec Hod


t

Abs Below Case DateTime Either Factorial Go Hour

AccessLo Between CD DayOfMo Else First GoTo HourOfD


g nth ay
DayOfYe
ar

AccessS Bitand Ceiling Del En Floor Greater Hr


erver

AckAlarm Bitnot Change DiffTime Enable For

Acos Bitor Chr Dis Encrypt From

Adjust Bitxor Cos Disable Encrypte


d

All Break Cosine Div End

Am Breakpoi Curvefit Divided EndIf


nt

And By Does EndSelec


t

Append Dom EndWhen

Arcsine Doy EndWhile

Arctange Dt Equal
nt

Arctange Equals
nt2

Arg Erase

Asc Errors
Execute

Asin Exists

Ask Exp

Atan Exponenti
al

Atan2

Technical 04-20006-02-en, March 2019


1624
59 Script Introduction
59.13 Script Reserved Words

Continued
A B C D E F G H

Average

Averaged

Avg

Table: Reserved Words I-S


I L M N O P R S

If Last Max Neither Object P Random Sc

In Left Maximum Next Open Param Return Scan

Is Len Maxitem Not Or Passed Right Sd

Length Message Number Output Pid Rnd Search


Window

Less Mid Numeric Plus Run Sec


Second

Let Min NumToSt Pm Select


r

Ln Minimum Pr Print Set

Log Minitem Shut

Lookup Minus Sin

Minute Sine

Mod Site

Modify Sqrt

Month Standard
-
Deviation

Move Start

Mth Status

Mult StatusLin
e

Multiplied Step

Stop
String

Stringfill

04-20006-02-en, March 2019 Technical


1625
59 Script Introduction
59.13 Script Reserved Words

Continued
I L M N O P R S

StrToDat
e

StrToNu
m

StrToTim
e

Sum

Table: Reserved Words T-Z


T U V W

Tab Unadvise Val Weekday

Tan UniquePIN Version When

Tangent Until Where

Td Update While

Th UpdateAlarms With

Than UpdateEvents WriteProperty

The UpdateExitLog

Then

Through

Thru

Time

TimeOfDay

Timepiece

Times

TmTo

Tod

Touchedcell

Trace

Trunc

Truncate

Technical 04-20006-02-en, March 2019


1626
59 Script Introduction
59.13 Script Reserved Words

Continued
T U V W

Ts

Turn

04-20006-02-en, March 2019 Technical


1627
59 Script Introduction
59.14 Bindings and Script Programs

59.14 Bindings and Script Programs


A binding is an association between a local variable (numeric, string, datetime,
function) within a Script program and a property of an object in the system. The use
of bindings increases the flexibility of the building automation system. You can write
a program for one application, and use that program for a similar application by just
changing the bindings instead of changing all of the local variable names in the
program to suit the new program.

59.14.1 Local Variable Declarations


In Script, you declare local variables using either the Input, Output, or Public binding
keyword. Then, you bind those variables to the object properties. For example, you
can bind to the value of a point, or have a program's output bound to an input of
another program.

Note
With bindings, you are not limited solely to the properties of points and programs.
You can also use other object types.

For more information, see section 59.16 “Local Variable Declarations” on page
1630.

59.14.2 Binding Attributes


Important
The four binding attributes in a Script program: Forced, Invalid, Offline, and
Overridden are not supported in the EcoStruxure Building Operation software.

Technical 04-20006-02-en, March 2019


1628
59 Script Introduction
59.15 Binding Values in Script Editor Using a Binding Template

59.15 Binding Values in Script Editor Using a


Binding Template
You use binding templates to reduce engineering time when creating bindings for
variables and functions within a Script program. Binding templates are defined and
created for binding patterns that are frequently reused. You can access the
Bindings view without leaving Script Editor.
For more information, see section 16.1 “Binding Templates” on page 405.

To bind values in Script Editor using a binding template


1. In Script Editor, click Bindings to display the Bindings view for the Script
program.
2. In the Bindings View, in the binding point browser, drag the object or folder
to the binding template that you want to apply.

3. In the Confirm Bindings dialog box, select the bindings that you want to
create.
4. Click OK.
5. In the Bindings View, verify that all bindings are correctly bound.
6. On the toolbar, click Save.

04-20006-02-en, March 2019 Technical


1629
59 Script Introduction
59.16 Local Variable Declarations

59.16 Local Variable Declarations


In Script, you declare local variables using either the Input, Output, or Public binding
keyword. Then, you bind those variables to the object properties. For example, you
can bind to the value of a point, or have a program's output bound to an input of
another program.

Note
With bindings, you are not limited solely to the properties of points and programs.
You can also use other object types.

During execution, when the program gets the value of an Input variable, the
program gets the value of the object property (the value of a point). When the
program sets the value of an Output variable, the program sets the value of the
object property (the value of a point).
You can use a binding with the following:
• Input variables
• Output variables
• Public variables
• User-Defined Functions
Any hardware or software input, output device like a fan, motion sensor, or a Script
function is represented as an object in the EcoStruxure Building Operation
database. When you create a local variable in Script, that variable is generic and
can potentially be associated with the object property and the local variable that
property is bound to. The object property and the local variable must have similar
types. For example, you bind a numeric local variable to an integer, float, digital, and
enumeration instead of a string or datetime.

An example of a binding with a Script Program


To access the values of points in the system through bindings, a Script program
must include Input, Output, Public, or Function local variables. The following figure
shows the Bindings view for a Script program.

Technical 04-20006-02-en, March 2019


1630
59 Script Introduction
59.16 Local Variable Declarations

Figure: Bindings View for a Script Program

Tip
Corresponding properties tabs are displayed, one for each binding type. These
tabs list each of the local variables that can be bound to other objects in the
system.

In Script, you can bind using either the Bindings view in WorkStation, or the
Bindings view in the Script Editor. For more information, see section 46.10 “Binding
Values Using a Binding Template” on page 1246.
Using the Bindings view in Script Editor, you can slide the view, overlay your Script
program, bind the necessary objects, retract the view, and then resume
programming without leaving the Script Editor.

04-20006-02-en, March 2019 Technical


1631
59 Script Introduction
59.16 Local Variable Declarations

Figure: Bindings View - Slider View


You can also undock the Bindings view in Script Editor and include it as a tab
wherever you want in the Editor window. For example, you can position it at the
bottom of the window as shown in the following graphic.

Technical 04-20006-02-en, March 2019


1632
59 Script Introduction
59.16 Local Variable Declarations

Figure: Bindings View - Tabbed View

Public Binding Qualifier


Public is a binding qualifier that identifies a variable as a public variable. You can
modify a public variable from outside a Script program, such as from a graphic.
Public behaves like an output variable, so you may bind the public variable to the
value of a point, or to the input variable of a Script program as you would with any
output variable. Unlike an output variable, you do not have to use the force
capability to modify Public from the Script property grid, or from a graphic.
You should use the Public binding qualifier when you need to directly modify that
variable from the Script property grid (that is, modify the value the Public binding
variable is bound to). Unlike an output variable, you can manually change the value
of the public variable from a graphic.

04-20006-02-en, March 2019 Technical


1633
59 Script Introduction
59.17 Tasks

59.17 Tasks
Function block and Script programs must be connected to tasks in order to run.
You access Tasks from the Properties dialog box.
The task is a property of the object that defines the program cycles.
When you create a new function block or Script program, Task 3 is the default. This
means that one program cycle executes in 1000 ms.

Figure: Tasks
The way you schedule programs to execute in Script differs from how you schedule
them to execute in Continuum. For more information, see the Script and Plain
English Program Differences topic on WebHelp.

Table: Task Intervals


Task Interval

Task 1 0.1 seconds

Task 2 0.5 seconds

Task 3 1 seconds

Task 4 5 seconds

Task 5 10 seconds

Technical 04-20006-02-en, March 2019


1634
59 Script Introduction
59.18 Adding a Task to a Program

59.18 Adding a Task to a Program


To make a Script or Function Block program run, the program must be connected
to a task.
For more information, see section 59.17 “Tasks” on page 1634.

To add a task to a program


1. In WorkStation, in the System Tree pane, select the program you want to
add a task to.
2. On the File menu, click Properties.
3. In the Task box, enter the task you want to add.
4. Click OK.

04-20006-02-en, March 2019 Technical


1635
59 Script Introduction
59.19 Program Cycles in EcoStruxure Building Operation Software

59.19 Program Cycles in EcoStruxure Building


Operation Software
All programs are executed in the order they are bound in the EcoStruxure Building
Operation software. For example, in programs that are executed in a straight order
or in any similar configuration, Program 4 runs after Program 3 that runs after
Program 2 that runs after Program 1. The first program to be executed is Program
1.
The illustration that follows shows the execution sequence for a straight order
configuration.

Figure: Execution order of programs


When programs are connected in an algebraic loop, the execution order cannot be
determined and the program that runs first needs to be established. In EcoStruxure
Building Operation software, algebraic loops are called Cycles. In this case, there is
no way to determine the execution order of the programs. Program 4 runs after
Program 3 that runs after Program 2 that runs after Program 1 that runs after
Program 4.

Figure: In an algebraic loop the execution order of programs cannot easily be determined.
To resolve a cycle and determine which program runs first in the cycle, you use the
execution precedence function. Programs can have execution precedence values
ranging from 0 to 255 where 0 results in the highest priority and 255 results in the
lowest priority. The program with highest execution precedence is always executed
first in the cycle.
Execution Precedence

Values: Integers ranging from 0 to 255

Highest priority value: 0

Lowest priority value: 255

The execution precedence is configured in the properties for the program. The
default value when you create a new program is 100.

Technical 04-20006-02-en, March 2019


1636
59 Script Introduction
59.19 Program Cycles in EcoStruxure Building Operation Software

Figure: Execution precedence


The execution precedence can never override the execution order of programs
based on how they are bound. The execution precedence decides the order in
which the programs are run when they are set up in some form of cycle and the
binding does not give a straight order for which program runs first.
The execution precedence can be used in two different situations:
• To determine the execution order when programs are bound in a cycle.
• As troubleshooting, for example when a there are delays without any known
reason. A long delay might be the result of programs that run in the wrong
order.

59.19.1 Example A
In this example we have four programs that are connected in a cycle. The execution
order cannot be determined from how programs are bound. Program 1 should run
before Program 2, Program 2 before Program 3, and Program 4 before Program 1.

04-20006-02-en, March 2019 Technical


1637
59 Script Introduction
59.19 Program Cycles in EcoStruxure Building Operation Software

Figure: Example
However, Program 2 reads from a physical input, Input A, and the information from
this reading is transferred to Program 4, which writes to a physical output, Output
B.

Figure: Example
So, we want to Program 2 to run before Program 4. To do this we use execution
precedence. By configuring the Execution precedence as 99 for Program 2,
Program 2 will be the first program to be executed in the cycle.

Figure: Example
The resulting execution order will be P2, P3, P4 and P1.

Technical 04-20006-02-en, March 2019


1638
59 Script Introduction
59.19 Program Cycles in EcoStruxure Building Operation Software

59.19.2 Example B
All programs use the default execution precedence that is 100. In this example, it is
not possible to determine the execution order of Program 1 and Program 2 and the
execution order of Program 3 and Program 4. The only thing we can be sure of is
that the cycle with Program 1 and Program 2 is executed before the cycle with
Program 3 and Program 4 due to the fact that Program 3 awaits input from
Program 2.

Figure: Example
To resolve the order we configure Program 2 and Program 3 to have the execution
precedence of 99. Then Program 2 runs before Program 1 in the first cycle and
Program 3 before Program 4 in the second cycle.

Figure: Example
Now the execution order is Program 2, Program 3, Program 4 and Program 1.

59.19.3 Application Scheduler


The Application Scheduler displays the programs execution order and if you have
any cycles in your system. In the System Tree pane, the Application Scheduler is
displayed in the Modules folder. The programs are represented with an entry under
the task they are assigned to.

04-20006-02-en, March 2019 Technical


1639
59 Script Introduction
59.19 Program Cycles in EcoStruxure Building Operation Software

Figure: Application scheduler


The object called cycle identifies a cycle. In the properties dialog for the task the
property "Conflict" is set to "True" if there is any cycle in the Task. Conflicts do not
mean that the programs will not run at all. The programs will run but the might run in
an execution order that may cause unnecessary delays from input to output.

Technical 04-20006-02-en, March 2019


1640
59 Script Introduction
59.19 Program Cycles in EcoStruxure Building Operation Software

Figure: Conflict setting in task 3


Use the List View to see the execution order of the programs.

Figure: Entries in the List View


Entry is the order of execution of the programs for a specific task. In this case
Program 2 executes first followed by Program 4. Program 3 runs last.

04-20006-02-en, March 2019 Technical


1641
59 Script Introduction
59.20 Configuring the Execution Precedence for a Program

59.20 Configuring the Execution Precedence


for a Program
You configure the highest execution precedence number on the program you want
to be executed first in a cycle.
For more information, see section 59.19 “Program Cycles in EcoStruxure Building
Operation Software” on page 1636.

To configure the execution precedence for a program


1. In WorkStation, in the System tree pane, select the program.
2. On the File menu, click Properties.
3. In the Execution precedence box, enter a number that is higher than all the
other programs in the cycle.

4. Click OK.

Technical 04-20006-02-en, March 2019


1642
59 Script Introduction
59.21 Finding Cycles in a Task

59.21 Finding Cycles in a Task


If you encounter unexpected delays in input to output response, the execution
order of the programs in a Task might not optimized.
For more information, see section 59.19 “Program Cycles in EcoStruxure Building
Operation Software” on page 1636.

To find cycles in a task


1. In WorkStation, in the System Tree pane, in the System folder, open the
Modules, and then ApplicationScheduler foldes.
2. Open a Task.
3. If the Task contains an object called Cycle, a cycle is present.

04-20006-02-en, March 2019 Technical


1643
60 Script Programming

Topics
Script Program Components
Program Constants
Numeric Constants
String Constants
ASCII Codes
Script Constants
Constant Keywords
Failure
OFF
ON
-ON
Success
Program Operators
Operator Keywords
Bitwise Operators
BITAND
BITNOT
BITOR
BITXOR
Logical Operators
60 AND
EQUALS
IS...
NOT
OR
Mathematical Operators
DIVIDED BY
MINUS
MOD
PLUS
TIMES
Program Statements
Statement Keywords
Action Statements
P
PRINT
SET
TURN
Declaration Statements
ARG
DATETIME
LINE
NUMERIC
STRING
THE
Webservice
Program Control Statements
BASEDON...GOTO
BREAK
60 CONTINUE
FOR...NEXT
GOTO
IF...THEN...ELSE
MOVE
Repeat...Until
RETURN
SELECT CASE
STOP
WAIT
WHILE
Qualifier Statements
INPUT
Buffered
OUTPUT
PUBLIC
Expressions
Variables
Declaring a Variable
Program Variables
Local Program Variables
Variables Pane Types
Program Arrays
System Variables
Script Runtime Variables
TS
TM
TH
TD
60 System Variable Keywords
Date and Time System Variables
DATE
DAYOFMONTH
DAYOFYEAR
HOD
HOUR
MINUTE
MONTH
SECOND
TOD
UTCOffset
WEEKDAY
YEAR
Runtime System Variables
ERRORS
FREEMEM
SCAN
Script Functions
Script Function Workflow
Script Functions without Arguments
Script Functions with Arguments
Script Functions that Return a Value
Script Functions and Programs
Function Declarations and Statements
Declaring and Calling a Script Function
Creating a Script Function
Declaring a Script Function Argument
Checking and Saving a Script Function
60 System Functions
System Function Keywords
Buffered Variable Functions
GetBufferSize
GetBufferedValue
Conversion Functions
NUMTOSTR
STRTODATE
STRTONUM
Mathematical Functions
ABS
EXPONENTIAL
FACTORIAL
LN
LOG
RANDOM
SQRT
SUM
Object Functions
ReadProperty
Relinquish
WriteProperty
PASSED Function
Rounding Functions
CEILING
FLOOR
ROUND
TRUNCATE
Statistical Functions
60 AVERAGE
MAXIMUM
MAXITEM
MINIMUM
MINITEM
StandardDeviation
String Functions
ASC
CHR
LEFT
LENGTH
MID
RIGHT
SEARCH
FIND
STRINGFILL
TAB
Time Functions
DIFFTIME
TIMEPIECE
Trigonometric Functions
ACOS
ASIN
ATAN
ATAN2
COS
SIN
TAN
60 Script Programming
60.1 Script Program Components

60.1 Script Program Components


Script programs are composed of the following components that allow you to
develop your programs quickly and easily:
• Program constants
• Program operators
• Program statements
• Expressions
• Variables
For example, you can create program statements with everyday language, so you
do not need to be a programmer to learn how to program with Script.

60.1.1 Program Constants


Constants are numbers, words, or dates that do not change.
For more information, see section 60.2 “Program Constants” on page 1653.

60.1.2 Program Operators


An operator is the part of an expression that causes a mathematical operation to
occur, such as addition, or tests a condition, such as equality.
For more information, see section 60.13 “Program Operators” on page 1667.

60.1.3 Program Statements


Program statements are written with Script words, known as keywords, that are
arranged in a predefined structure. Each keyword has its own keyword syntax.
According to the rules of that syntax, certain parameters and values are allowed or
not allowed to follow a keyword.
For more information, see section 60.32 “Program Statements” on page 1699.

60.1.4 Expressions
Instructions that consist of mathematical operations are called expressions.
Expressions can also be item names or constants that return a numeric or string
result.
For more information, see section 60.66 “Expressions” on page 1758.

60.1.5 Variables
A variable is a run-time (dynamically changing) property of an object.

04-20006-02-en, March 2019 Technical


1651
60 Script Programming
60.1 Script Program Components

For more information, see section 60.67 “Variables” on page 1759.

Technical 04-20006-02-en, March 2019


1652
60 Script Programming
60.2 Program Constants

60.2 Program Constants


Constants are numbers, words, or dates that do not change.

60.2.1 Numeric Constants


A numeric constant is a number. In Script, only floating point numbers are used. A
floating point number is a number with a decimal.
For more information, see section 60.3 “Numeric Constants” on page 1654.

60.2.2 String Constants


A string constant is a series of ASCII characters, including blanks, surrounded by
quotation marks ("string").
For more information, see section 60.4 “String Constants” on page 1655.

60.2.3 Script Constants


Script constants, including class names, are listed in alphabetical order in the
following tables. You cannot use Script constants as a line label or program
variable.
For more information, see section 60.6 “Script Constants” on page 1659.

60.2.4 Constant Keywords


Script constant keywords represent numbers or values that are used in
expressions.
For more information, see section 60.7 “Constant Keywords” on page 1661.

04-20006-02-en, March 2019 Technical


1653
60 Script Programming
60.3 Numeric Constants

60.3 Numeric Constants


A numeric constant is a number. In Script, only floating point numbers are used. A
floating point number is a number with a decimal.
You can enter a floating point number in one of the following ways:
• Number with up to seven decimal places
• Number in scientific notation
• Positive numbers between 1.40129E-45 and 3.402823E+38
• Negative numbers between -3.402823E+38 and -1.40129E-45
Floating point numbers can display without decimal points, but are still handled by
the system as floating point numbers. The accepted numbers are based on the
Institute of Electrical and Electronics Engineers, IEEE 754 single precision format.
The following numbers are examples of numeric constants:
• 12
• 74.5
• -.543
• 4E+32
Do not use a comma in the number. For example, 1,000 is an invalid numeric
constant.
Script interprets only the following numbers:
• Greater than 3.402823E+38 as infinity.
• Less than -.402823E+38 as negative infinity.
Script accepts all numbers, but interprets only the following numbers:
• Numbers greater than 3.402823E+38 are interpreted as infinity.
• Less than -.402823E+38 as negative infinity.
• Between 1.40129E-45 and -.40129E-45 as zero.

Technical 04-20006-02-en, March 2019


1654
60 Script Programming
60.4 String Constants

60.4 String Constants


A string constant is a series of ASCII characters, including blanks, surrounded by
quotation marks ("string").
The following are examples of some acceptable strings:
• "Hello world"
• "Access to the building is restricted"
• "123"

60.4.1 Rules for String Constants


Even though a string contains a number, the number cannot be directly used in
mathematical calculations.
In Script, the vertical bar, |, is the control character in a string. Anything you put after
the vertical bar is interpreted as a code or a format for a variable value. For example,
to print a quote enclosed by quotation marks you would use (“) following the vertical
bar. In the statement that follows:
PRINT "The string |" abc|" is included"
The printer outputs: The string "abc" is included.
More information about the vertical bar in strings is included under the PRINT
keyword.

60.4.2 ASCII Codes


Most keyboards have a limited set of characters. There are no characters to control
such actions as feeding the paper, turning on a beep, scrolling the screen, and so
on. For these actions, you use a set of codes called the American Standard Code
for Information Interchange (ASCII).
For more information, see section 60.5 “ASCII Codes” on page 1656.

04-20006-02-en, March 2019 Technical


1655
60 Script Programming
60.5 ASCII Codes

60.5 ASCII Codes


Most keyboards have a limited set of characters. There are no characters to control
such actions as feeding the paper, turning on a beep, scrolling the screen, and so
on. For these actions, you use a set of codes called the American Standard Code
for Information Interchange (ASCII).
You use these codes in a PRINT statement to control your printer or screen. For
more information, see section 60.36 “PRINT” on page 1704.
The following table lists ASCII codes. Examples follow the table.

Table: ASCII Code


Code (in Decimal) Character or Action

0 NUL

1 SOH

2 STX

3 ETX

4 EOT

5 ENQ

6 ACK

7 Beep

8 Backspace

9 TAB forward

10 Line feed

11 Vertical TAB

12 Form feed

13 Carriage return

14 SO

15 SI

16 DLE

17 DC1

18 DC2

19 DC3

20 DC4

21 NAK

Technical 04-20006-02-en, March 2019


1656
60 Script Programming
60.5 ASCII Codes

Continued
Code (in Decimal) Character or Action

22 SYN

23 ETB

24 CAN

25 EM

26 SUB

27 ESC

28 FS

29 GS

30 RS

31 US

127 DEL

Note
• Script supports characters at or below ASCII 127. Additional characters are
not supported and are replaced by a question mark (?).

Examples
For example, you might use the ASCII code for a character in the STRINGFILL
function. You must give STRINGFILL the code for the character with which you
want to fill the string. For more information, see section 60.152 “STRINGFILL” on
page 1867.
For example, to make the printer beep, you send the beep code a PRINT
statement, like this:
Print "|7" to Printer1
You can also make a terminal beep as follows:
Print "|7" to Screen1
To feed the paper forward one form feed:
Print "|12" to Printer1
To send an ESCAPE to the printer:
Print "|27" to Printer1
More printer control statements can be available for your printer. See the
manufacturer's documentation.
To create a bar in a chart, you might fill a string with asterisks using STRINGFILL
and the ASCII code for asterisk, 42, as follows:
Stringfill (Kilowatts, 42)
You could make a similar bar in a chart using pound signs:

04-20006-02-en, March 2019 Technical


1657
60 Script Programming
60.5 ASCII Codes

Stringfill (Pressure, 35)

Technical 04-20006-02-en, March 2019


1658
60 Script Programming
60.6 Script Constants

60.6 Script Constants


Script constants, including class names, are listed in alphabetical order in the
following tables. You cannot use Script constants as a line label or program
variable.

Table: Script Constants A-M


A B C D E F J M

Apr Binary Char Days Enabled Failed Jan Mar

April Bit Character Dec EnableDis Failure January March


SetNotSu able
pported

Aug Bitstring CharType Decembe EndResto False Jul Minutes


r re

August Closed Delete Equal Fault July MissingR


equiredP
arameter

Average Constant Digital Feb Jun Mon

Averaged CurrentV Disabled February June Monday


alue

Active Fri Months

Friday MonthTo
Date

Function MonthTo
Now

Table: Script Constants N-Z


N O P R S T

Nov Object Print Run Sat Thu

November ObjectClass Running Saturday Thursday

NoVTSession ObjectDeletio Sep Today


s-Available nNotPermitte
d

ObjectID September True

ObjectIdentifi Singular Tue


er-
AlreadyExists

ObjectRefere Site_Config Tuesday


nce

Oct Site_ConfigB

04-20006-02-en, March 2019 Technical


1659
60 Script Programming
60.6 Script Constants

Continued
N O P R S T

October Success

Odd Sun

Off Sunday

Offline

On

-On

OneWeekTo
Date

OneWeekTo
Now

OneYearToD
ate

OneYearToN
ow

Online

Opened

Or

Other

OverRange

Overridden

Technical 04-20006-02-en, March 2019


1660
60 Script Programming
60.7 Constant Keywords

60.7 Constant Keywords


Script constant keywords represent numbers or values that are used in
expressions.
There are five different Script constant keywords.

60.7.1 Failure
Failure is used in expressions to indicate a function has failed to complete. Failure is
always numeric and equal to one. Failure can be used to replace numbers in a
comparison expression.
For more information, see section 60.8 “Failure” on page 1662.

60.7.2 OFF
OFF is used in expressions to indicate an item is OFF or set to bottom of scale.
OFF is always numeric and thus, can be compared to numeric values of points or
variables in a comparison expression.
For more information, see section 60.9 “OFF” on page 1663.

60.7.3 ON
ON is used in expressions to indicate an item is ON or set top of scale.
ON is always numeric and can be compared to input, output, and numeric points or
variables in a comparison expression.
For more information, see section 60.10 “ON” on page 1664..

60.7.4 -ON
-ON is used in expressions to indicate a tri-state point is set to -ON.
-ON is always numeric and thus, can be compared to numeric values of points or
variables in a comparison expression.
For more information, see section 60.11 “-ON” on page 1665..

60.7.5 Success
Success is used in expressions to indicate a process or function has completed
successfully.
Sucess is always numeric and equal to zero.
For more information, see section 60.12 “Success” on page 1666..

04-20006-02-en, March 2019 Technical


1661
60 Script Programming
60.8 Failure

60.8 Failure
Failure is used in expressions to indicate a function has failed to complete. Failure is
always numeric and equal to one. Failure can be used to replace numbers in a
comparison expression.

Syntax
Failure

Technical 04-20006-02-en, March 2019


1662
60 Script Programming
60.9 OFF

60.9 OFF
OFF is used in expressions to indicate an item is OFF or set to bottom of scale.
OFF is always numeric and thus, can be compared to numeric values of points or
variables in a comparison expression.

Note
Be aware that you need to use the ON/OFF keywords in Infinet device Script
programs to control digital outputs. While the Inactive/Active and True/False
options will not generate any compile or runtime errors, they will also not produce
the expected ON/OFF behavior.

Syntax
Off

Examples
Example 1
Program File
Turn the Lobby_Light Off
Example 2
Program File
If the Lobby_Light is Off then Turn Off the Heat

04-20006-02-en, March 2019 Technical


1663
60 Script Programming
60.10 ON

60.10 ON
ON is used in expressions to indicate an item is ON or set top of scale.
ON is always numeric and can be compared to input, output, and numeric points or
variables in a comparison expression.

Note
Be aware that you need to use the ON/OFF keywords in Infinet device Script
programs to control digital outputs. While the Inactive/Active and True/False
options will not generate any compile or runtime errors, they will also not produce
the expected ON/OFF behavior.

Syntax
On

Example
Script Program File - Using ON and OFF
If timeofday is between 9 and 17 then
Set the Fan to ON
Else
Set the Fan to OFF
Endif

Technical 04-20006-02-en, March 2019


1664
60 Script Programming
60.11 -ON

60.11 -ON
-ON is used in expressions to indicate a tri-state point is set to -ON.
-ON is always numeric and thus, can be compared to numeric values of points or
variables in a comparison expression.

Syntax
-On

Example
Program File
If the Flow is greater than SetPoint then set the Damper to -On

04-20006-02-en, March 2019 Technical


1665
60 Script Programming
60.12 Success

60.12 Success
Success is used in expressions to indicate a process or function has completed
successfully.
Sucess is always numeric and equal to zero.

Syntax
Success

Examples
Call a user-defined Script function, which returns either Success or Failure.
If MyUpdateFunction (“Zone1”, “Temperature”, TempValue) =
Success then Print "Update Successful"
Else
user1Goto RecordFailure
Endif

Technical 04-20006-02-en, March 2019


1666
60 Script Programming
60.13 Program Operators

60.13 Program Operators


An operator is the part of an expression that causes a mathematical operation to
occur, such as addition, or tests a condition, such as equality.

60.13.1 Operator Precedence


In Script, operators are acted upon in a certain sequence when more than one
operator occurs in an expression. This is known as operator precedence. The
following table lists the order (top to bottom) that is used when working out an
expression.

Table: Operator Precedence


Operator Description Association

() Parentheses Left to Right


[] Array Element Left to Right

Blank or \ Path Name Connector Right to Left

+ Plus Sign on Number Right to Left


- Minus Sign on Number
NOT Logical Negation
BITNOT Bitwise Negation
% Percentage

^ Exponentiation Left to Right

* Multiplication Left to Right


/ Division
MOD Modulo

+ Addition Left to Right


- Subtraction

< Less Than Left to Right


<= Less Than or Equal
> Greater Than
>= Greater Than or Equal

= Equal Left to Right


<> Not Equal
IS IN Set Inclusion
IS NOT IN Set Exclusion
IS BETWEEN Range
IS THRU Range

04-20006-02-en, March 2019 Technical


1667
60 Script Programming
60.13 Program Operators

Continued
Operator Description Association

BITAND Bitwise Logical And Left to Right


BITOR Bitwise Logical Or
BITXOR Bitwise Exclusive Or

& Logical And Left to Right


! Logical Or

; Joining Operator Left to Right

60.13.2 Plus Sign, Minus Sign, Negation, BITNOT, and


Percentage Operators
The following table identifies and defines the plus sign, minus sign, negation,
BITNOT, and percentage operators.

Table: Plus Sign, Minus Sign, Negation, BITNOT, and Percentage


Operator Definition

+ number Shows that a number is positive, but does


not affect the value.

- number Makes a positive number negative and a


negative number positive. This operator
works only on numeric expressions.

NOT number Negates the number or expression. If the


value of the expression is nonzero, NOT
changes that expression to 0. If the
expression is TRUE, NOT makes that
expression FALSE.

BITNOT integer Changes the 1s to 0s and 0s to 1s in the


binary equivalent of the integer, and then
gives you the decimal integer equivalent of
that binary number.

number % Divides the number by 100 to determine the


percentage.

60.13.3 Fundamental Operators


The following table identifies and defines the fundamental operators.

Technical 04-20006-02-en, March 2019


1668
60 Script Programming
60.13 Program Operators

Table: Fundamental Operators


Operator Example Definition

Addition number + number Adds the numbers. Works on


numbers or datetimes and
the resulting expression is
numeric or datetime.
Alias: PLUS

Subtraction number - number Works on numbers or


datetimes and the resulting
expression is numeric or
datetime.
Alias: MINUS

Multiplication number * number Multiples the numbers.


Works on numbers and the
resulting expression is
numeric.
Aliases: TIMES, MULT, and
MULTIPLIED BY

Division number / number Divides the first number by


the second. Works on
numbers and the resulting
expression is numeric.
Alias: DIVIDED BY

Modulus number MOD number Finds the amount left over


when dividing the first
number by the second. For
example, 9 MOD 7 gives 2.
Alias: REMAINDER

Exponentiation number ^ number Raises the first number to the


power of the second
number. For example, 2 ^ 3
=8
Alias: EXP

60.13.4 Comparative Operators


A comparative operator compares the number to the left of the keyword with the
number to its right. The results are TRUE (numeric 1) or FALSE (numeric 0) and are
considered numeric.

04-20006-02-en, March 2019 Technical


1669
60 Script Programming
60.13 Program Operators

Table: Comparative Operators


Operator Example Definition

Less Than number < number Determines whether the


value of the left number is
less than the value of the
right number.
Aliases: IS LESS THAN
(THAN is optional) and IS
BELOW

Less Than or Equal number <= number Determines whether the


value of the left number is
less than or equal to the
value of the right number.
Alias: IS LESS THAN OR
EQUAL TO where THAN and
TO are optional

Greater Than number > number Determines whether the


value of the left number is
greater than the value of the
right number.
Alias: IS GREATER THAN
(THAN is optional) and IS
ABOVE

Greater Than or Equal number >= number Determines whether the


value of the left number is
greater than or equal to the
value of the right number.
Alias: IS GREATER THAN
OR EQUAL TO, where THAN
and TO are optional

Equal number = number Determines whether the


value of the left number is
equal to the value of the right
number.
Aliases: EQUALS, IS EQUAL
TO, and IS EQUAL

Not Equal number <> number Determines whether the


value of the left number is not
equal to the value of the right
number.
Aliases: DOES NOT EQUAL,
IS NOT EQUAL TO, and IS
NOT EQUAL

Technical 04-20006-02-en, March 2019


1670
60 Script Programming
60.13 Program Operators

Comparing String Values


You can also use Greater Than, Less Than, or Equal To operators to compare two
string values. The strings are evaluated by ASCII code, using their numerical ASCII
values. For example, "Z" which has an ASCII value of 90 is greater than "A" which
has an ASCII value of 65. Likewise, "9" is greater than "0", and "A" is greater than
"9". Also, "ABC", which is the equivalent to the sum of the ASCII values of each
individual character, is greater than "A". For more information, see section 60.5
“ASCII Codes” on page 1656..

60.13.5 List and Range Operators


The following table identifies and defines list and range operators.

Table: List and Range Operators


Operator Example Definition

IS IN number IS IN list Determines if the number or


expression on the left is in
Or the listed set. If the number
number IS list on the left-hand side of the
expression is in the list
expression on the right-hand
side, the expression yields
TRUE (numeric 1). If the
expression is not in the list on
the right-hand side, the
expression yields FALSE
(numeric 0).
Alias: IS EITHER

IS NOT IN number is NOT IN list Determines if the number or


expression on the left is NOT
in the listed set. If the number
on the left-hand side of the
expression is NOT in the list
expression on the right-hand
side, the expression yields
TRUE (numeric 1). If the
expression is in the list on the
right-hand side, the
expression yields FALSE
(numeric 0).
Alias: IS NEITHER

04-20006-02-en, March 2019 Technical


1671
60 Script Programming
60.13 Program Operators

Continued
Operator Example Definition

IS THRU number IS number THRU Designates a range starting


number with the number or
expression on the left-hand
side of THRU and ending
with the number or
expression on the right-hand
side. If the number at
beginning of the expression
is within the inclusive range,
the expression yields TRUE
(numeric 1). If the expression
is not in the inclusive range,
the expression yields FALSE
(numeric 0).
This statement is
operationally equivalent to IS
BETWEEN.

IS BETWEEN number IS BETWEEN Designates a range starting


number AND number with the number or
expression on the left-hand
side of AND and ending with
the number or expression on
the right-hand side. If the
number at the beginning of
the expression is within the
inclusive range, the
expression yields TRUE
(numeric 1). If the expression
is not in the inclusive range,
the expression yields FALSE
(numeric 0).
This statement is
operationally equivalent to IS
THRU.

60.13.6 Bit Operators


The following table identifies and defines the bit operators.

Technical 04-20006-02-en, March 2019


1672
60 Script Programming
60.13 Program Operators

Table: Bit Operators


Operator Example Definition

BITAND integer BITAND integer Compares the binary


equivalents of the two
integers, digit by digit, as if
the 1s were TRUE and the 0s
were FALSE.
If both binary numbers
contain a 1 in the same
place, that is TRUE AND
TRUE, which is TRUE If both
numbers contain a 0 in the
same place, that is FALSE
and FALSE, which is FALSE.
If one number contains a 1
and the other a 0 in the same
place, that is TRUE AND
FALSE, which is also FALSE.
Refer to the Truth Tables that
follow for further explanation.

BITOR integer BITOR integer Compares the binary


equivalents of the two
integers, digit by digit, as if
the 1s were TRUE and the 0s
FALSE.
If both binary numbers
contain a 1 in the same
place, that is TRUE OR
TRUE, which is TRUE. If both
numbers contain a 0 in the
same place, that is FALSE
OR FALSE, which is FALSE.
If one number contains a 1
and the other a 0 in the same
place, that is TRUE OR
FALSE, which is TRUE.
Refer to the Truth Tables that
follow for further explanation.

04-20006-02-en, March 2019 Technical


1673
60 Script Programming
60.13 Program Operators

Continued
Operator Example Definition

BITXOR integer BITXOR integer Compares the binary


equivalents of the two
integers, digit by digit, as if
the 1s were TRUE and the 0s
FALSE. BITXOR finds cases
where one digit or the other
is TRUE, but not cases
where both digits are TRUE.
If both binary numbers
contain a 1 in the same
place, that is TRUE XOR
TRUE, which is FALSE
because only one or the
other can be TRUE, not both.
If both numbers contain a 0
in the same place, that is
FALSE XOR FALSE, which is
FALSE. If one number
contains a 1 and the other a
0 in the same position, that is
TRUE XOR FALSE, which is
TRUE.
Refer to the Truth Tables that
follow for further explanation.

Truth Tables
The following table is the truth table for the bit operators:

Table: Truth Table


Operator Integer1 Integer2 Result

BITAND TRUE TRUE TRUE


BITAND TRUE FALSE FALSE
BITAND FALSE FALSE FALSE
BITAND FALSE TRUE FALSE

BITOR TRUE TRUE TRUE


BITOR TRUE FALSE TRUE
BITOR FALSE FALSE FALSE
BITOR FALSE TRUE TRUE

BITXOR TRUE TRUE FALSE


BITXOR TRUE FALSE TRUE
BITXOR FALSE FALSE FALSE
BITXOR FALSE TRUE TRUE

Technical 04-20006-02-en, March 2019


1674
60 Script Programming
60.13 Program Operators

60.13.7 AND/OR and String Joining Operators


The following table identifies and defines the AND, OR, and String Joining
Operators.
Operator Example Definition

AND number & number Compares two expressions,


which must be numeric or
converted to numeric, in a
comparison. The statement
returns TRUE (numeric 1) if
both expressions are
nonzero.
Alias: AND

OR number ! number Determines whether a


comparison is true by
making the comparison to
each expression (which must
be numeric or converted to
numeric) separately,
excluding the others. The
statement returns FALSE
(numeric 0) if both
expressions are false, TRUE
(numeric 1) if at least one is
true.
Alias: OR

String Joining string ; string Joins two strings by adding


the second one onto the end
of the first to form a new
string. Both expressions
must be string or convert to
type string (that includes
numeric and datetime types).
Also known as the
concatenation operator.

60.13.8 Operator Keywords


Operators carry out a mathematical process, such as addition, subtraction, or a
logical TRUE/FALSE comparison.
For more information, see section 60.14 “Operator Keywords” on page 1676.

04-20006-02-en, March 2019 Technical


1675
60 Script Programming
60.14 Operator Keywords

60.14 Operator Keywords


Operators carry out a mathematical process, such as addition, subtraction, or a
logical TRUE/FALSE comparison.
Script uses three different types of operator keywords: bitwise, logical, and
mathematical operators.

60.14.1 Bitwise Operators


Bitwise operators perform logical operations on the binary equivalents of integers.
Bitwise operators include the following keywords:
• BITAND
• BITNOT
• BITOR
• BITXOR
For more information, see section 60.15 “Bitwise Operators ” on page 1677...

60.14.2 Logical Operators


Logical operators carry out TRUE/FALSE comparisons.
Logical operators include the following keywords:
• AND
• EQUALS
• IS...
• NOT
• OR
For more information, see section 60.20 “Logical Operators ” on page 1682...

60.14.3 Mathematical Operators


Mathematical operators perform mathematical operations, such as addition or
subtraction.
Mathematical operators include the following keywords:
• DIVIDED BY
• MINUS
• MOD
• PLUS
• TIMES
For more information, see section 60.26 “Mathematical Operators” on page 1693...

Technical 04-20006-02-en, March 2019


1676
60 Script Programming
60.15 Bitwise Operators

60.15 Bitwise Operators


Bitwise operators perform logical operations on the binary equivalents of integers.

Note
The Bitwise operators are not valid for Infinet device Script programs.

60.15.1 BITAND
BITAND logically compares the binary equivalents of the two integers, digit by digit.
This operator creates a new binary number that contains a 1 for each digit position,
where the first number's bit and the second number's bit are both 1, and sets all
other digits to zero. The new binary number is then converted to its decimal
equivalent.
For more information, see section 60.16 “BITAND” on page 1678..

60.15.2 BITNOT
BITNOT switches 1s to 0s and 0s to 1s in the binary equivalent of the integer, digit
by digit. (This is called the one’s complement of the binary number.) This operator
creates a new binary number and then converts that number back to its decimal
equivalent.
For more information, see section 60.17 “BITNOT” on page 1679..

60.15.3 BITOR
BITOR logically compares the binary equivalents of the two integers, digit by digit.
This operator creates a new binary number that contains a 1 for each digit position
where the first number's bit or the second number's bit is 1 and where both the first
and second number's bits are 1. The operator also sets all other digits to zero.
BITOR converts the new binary number to its decimal equivalent.
For more information, see section 60.18 “BITOR” on page 1680..

60.15.4 BITXOR
BITXOR logically compares the binary equivalents of the two integers, digit by digit.
This operator creates a new binary number that contains a 1 for each digit position,
where either the first number's bit or the second number's bit is 1, but gives zeros
where both are 1 or both are 0. BITXOR converts the new binary number to its
decimal equivalent.
For more information, see section 60.19 “BITXOR” on page 1681..

04-20006-02-en, March 2019 Technical


1677
60 Script Programming
60.16 BITAND

60.16 BITAND
BITAND logically compares the binary equivalents of the two integers, digit by digit.
This operator creates a new binary number that contains a 1 for each digit position,
where the first number's bit and the second number's bit are both 1, and sets all
other digits to zero. The new binary number is then converted to its decimal
equivalent.
BITAND carries out comparisons of checksums and similar operations.

Syntax
integer bitand integer

Table: BITAND Parameter


Parameter Description

integer Any number from 0 to 65535.


If you provide a number with a decimal point,
BITAND uses only the integer and drops
everything to the right of the decimal point.

Example
Suppose you want to compare Total1 and Total2:
Total1 = 13 (binary equivalent is 0000000000001101)
Total2 = 11 (binary equivalent is 0000000000001011)
You would compare them with BITAND as follows:
Program File
Set result = Total1 bitand Total2
The comparison would give 0000000000001001. RESULT would be set to 9.

Technical 04-20006-02-en, March 2019


1678
60 Script Programming
60.17 BITNOT

60.17 BITNOT
BITNOT switches 1s to 0s and 0s to 1s in the binary equivalent of the integer, digit
by digit. (This is called the one’s complement of the binary number.) This operator
creates a new binary number and then converts that number back to its decimal
equivalent.
BITNOT carries out bitmasking and similar operations.

Syntax
bitnot integer

Table: BITNOT Parameter


Parameter Description

integer Any number from 0 to 65535.


If you provide a number with a decimal point,
BITNOT uses only the integer and drops
everything to the right of the decimal point.

Example
Suppose you want to find the one’s complement of AMOUNT:
Amount = 13 (binary equivalent is 0000000000001101)
You could reverse the number with BITNOT as follows:
Program File
Set result = bitnot AMOUNT
The BITNOT of the amount would be 1111111111110010. The statement would
set RESULT to 65522.

04-20006-02-en, March 2019 Technical


1679
60 Script Programming
60.18 BITOR

60.18 BITOR
BITOR logically compares the binary equivalents of the two integers, digit by digit.
This operator creates a new binary number that contains a 1 for each digit position
where the first number's bit or the second number's bit is 1 and where both the first
and second number's bits are 1. The operator also sets all other digits to zero.
BITOR converts the new binary number to its decimal equivalent.
BITOR carries out comparisons of checksums and similar operations.

Syntax
integer bitor integer

Table: BITOR Parameter


Parameter Description

integer Any number from 0 to 65535.


If you provide a number with a decimal point,
BITOR uses only the integer and drops
everything to the right of the decimal point.

Example
Suppose you want to compare Total1 and Total2:
Total1 = 13 (binary equivalent is 0000000000001101)
Total2 = 11 (binary equivalent is 0000000000001011)
You would compare them with BITOR as follows:
Program File
Set result = Total1 bitor Total2
The comparison would give 0000000000001111. RESULT would be set to 15.

Technical 04-20006-02-en, March 2019


1680
60 Script Programming
60.19 BITXOR

60.19 BITXOR
BITXOR logically compares the binary equivalents of the two integers, digit by digit.
This operator creates a new binary number that contains a 1 for each digit position,
where either the first number's bit or the second number's bit is 1, but gives zeros
where both are 1 or both are 0. BITXOR converts the new binary number to its
decimal equivalent.
BITXOR carries out comparisons of checksums and similar operations.

Syntax
integer bitxor integer

Table: BITXOR Parameter


Parameter Description

integer Any number from 0 to 65535.


If you provide a number with a decimal point,
BITXOR uses only the integer and drops
everything to the right of the decimal point.

Example
Suppose you want to compare Total1 and Total2:
Total1 = 13 (binary equivalent is 0000000000001101)
Total2 = 11 (binary equivalent is 0000000000001011)
Program File
Set result = Total1 bitxor Total2
The comparison would give 0000000000000110. RESULT would be set to 6.

04-20006-02-en, March 2019 Technical


1681
60 Script Programming
60.20 Logical Operators

60.20 Logical Operators


Logical operators carry out TRUE/FALSE comparisons.

60.20.1 AND
The AND keyword can be used in two ways.
For more information, see section 60.21 “AND” on page 1683..

60.20.2 EQUALS
EQUALS is similar to the IS... operator.
For more information, see section 60.22 “EQUALS” on page 1686.

60.20.3 IS...
IS... carries out the logical test you specify.
For more information, see section 60.23 “IS...” on page 1687.

60.20.4 NOT
NOT logically negates or inverts a number or expression, changing 0 (FALSE to
OFF) to 1 (TRUE or ON) or vice versa.
For more information, see section 60.24 “NOT” on page 1690..

60.20.5 OR
The OR keyword can be used to provide the logical OR between two expressions,
or positioned in a list of names beween the last two items.
For more information, see section 60.25 “OR” on page 1691..

Technical 04-20006-02-en, March 2019


1682
60 Script Programming
60.21 AND

60.21 AND
Alias: Ampersand (&) is the alias for the logical AND only.
The AND keyword can be used in two ways.
See Syntax for more details.
The controller carries out all other operations (such as adding and subtracting)
before acting on AND or OR. Because AND and OR are acted on last, you can form
logical statements without using too many parentheses. (See Example 3 for using
AND and OR together.)

Syntax
Syntax 1: number and number
Provides the logical AND between two expressions.
Syntax 2: namelist and final_name
When used in a list of names between the last two items, indicates the end of the
series.

Table: AND Parameters


Parameter Description

number Any number or expression.

namelist One or more names with commas between


them.

final_name A single name at the end of a series of


names.
AND before the last name is optional.

Examples
Example 1
Instead of forming IF..THEN statements to turn the heat on when multiple
conditions exist, you can make one statement using AND:
Program File
If Temp < 70 and TOD > 7:00am then turn On the Heat
or
If Temp < 70 & TOD > 7:00am then turn On the Heat
Example 2
To run a series of programs, instead of using RUN several times, you can list the
program names on the same line, using AND (final comma optional) to indicate the
last item in the list:
Program File
Run the Cooling, Heating and Fan
or using the final comma:
Run the Cooling, Heating, and Fan

04-20006-02-en, March 2019 Technical


1683
60 Script Programming
60.21 AND

You cannot use the ampersand (&) for AND in a series. You can, however, leave out
AND as follows:
Run the Cooling, Heating, Fan
Example 3
If OR occurs before AND, the controller interprets OR first because the controller
works from left to right on AND and OR. For example, take this statement:
Program File
If Wkd = Sat or Wkd = Sun and TOD > 9:00 then...
The above statement is interpreted so that the items in parentheses below are
calculated first:
If (Wkd = Sat or Wkd = Sun) and TOD > 9:00 then...
If AND occurs before OR, the controller interprets AND first:
Program File
If TOD > 9:00 and Wkd = Sat or Wkd = Sun then...
is interpreted as:
If (TOD > 9:00 and Wkd = Sat) or Wkd = Sun then...
Example 4
AND is also used with the operator BETWEEN, as in the following example:
Program File
If TOD is between 8:00am and 6:00pm then...
You cannot use the ampersand (&) for AND when AND is used with BETWEEN.

Note
• Use parentheses to enforce the order of interpretations and resolve potential
ambiguities.

Example 5
To set one or more variables to an expression, such as ON, you can use any of the
following:
Program File
D1, D2 = On
D1 and D2 = On
Set D1,D2 to On
Set D1 and D2 to On
D1, D2, D3, D4 = On
D1, D2, D3 and D4 = On
Set D1, D2, D3, D4 to On
Set D1, D2, D3, and D4 to On
In this example, the following line is used to set the variable D1 to On and D2 to On
(In other words, it includes two set statements on the same line).
D1 = On AND D2 = On

Technical 04-20006-02-en, March 2019


1684
60 Script Programming
60.21 AND

However, the line does not get interpreted as such. Instead, it is interpreted as
follows:
D1 = ((On) and (D2 = On))
This results in one statement that sets D1 to the logical expression on the right hand
side of the first equal operator, and does not set D2 all together.
Be aware of the following here:
• A logical operator, such as AND, works only in expressions and not
statements.
• The language rules of precedence always apply when interpreting expressions.
In this case, the Equal operator (=) has a higher precedence than the AND
operator.

Note
• Be sure to always remember to use parentheses to enforce the order of
interpretations and resolve potential ambiguities. For more information, see
section 60.13 “Program Operators” on page 1667.

04-20006-02-en, March 2019 Technical


1685
60 Script Programming
60.22 EQUALS

60.22 EQUALS
EQUALS is similar to the IS... operator.
For more information, see section 60.23 “IS...” on page 1687..

Technical 04-20006-02-en, March 2019


1686
60 Script Programming
60.23 IS...

60.23 IS...
IS... carries out the logical test you specify.

Syntax
Greater-than-expression:
number > number
number is greater than number
number is above number
Greater-than-or-equal-to-expression:
number >= number
number is greater than or equal to number
Less-than-expression:
number < number
number is less than number
number is below number
Less-than-or-equal-to-expression:
number <= number
number is less than or equal to number
Equal-expression:
number = number
number is number
number is equal to number
number equals number
Not-equal-expression:
number <> number
number is not number
number is not equal to number
number does not equal number
List-inclusion-expression:
number is in list
number is range (see range-expression below)
number is EITHER list
List-exclusion-expression:
number is not in list
number is not range (see range-element below)
number is neither list
Range-expression:
number is between lower_number AND higher_number

04-20006-02-en, March 2019 Technical


1687
60 Script Programming
60.23 IS...

number is not between lower_number AND higher_number


number is lower_number THRU higher_number
number is not lower_number THRU higher_number

Table: IS...Parameters
Parameter Description

number Any number or expression, including a date


and time or name that stands for one.

list Two or more numbers (as defined above)


with commas between them.

range Two numbers (as defined above), each


marking one end of a range with THRU
between them, or two numbers preceded by
BETWEEN with AND between them.

Examples
Example 1
To compare two values, you usually place an IS... statement between IF and THEN
in an IF..THEN statement.

Note
• Because THAN is optional, in the following pairs of statements, each
statement gives the same instructions to the controller.

Program File
If Zone_Temp is greater than 70 then…
If Zone_Temp is greater 70 then…
If Zone_Temp is above 70 then…
If Zone_Temp is less than 70 then…
If Zone_Temp is less 70 then…
If Zone_Temp is below 70 then…
Example 2
The following statements are grouped together and give the same instructions to
the controller, because TO is optional and EQUALS can be used without IS:
Program File
If Zone_Temp is equal to 70 then…
If Zone_Temp is equal 70 then…
If Zone_Temp equals 70 then…
If Zone_Temp is not equal to 70 then…
IF Zone_Temp does not equal 70 then…
Example 3

Technical 04-20006-02-en, March 2019


1688
60 Script Programming
60.23 IS...

With IS IN, IS EITHER, IS NOT IN, or IS NEITHER, the comma in the list means OR.
You can also use the word OR before the last item in the list, for example:
Program File
If Zone_Temp is in Occupied, Warmup then…
If Zone_Temp is either Occupied, Warmup, OR Reset then…
If Zone_Temp is not in Occupied, Warmup then...
If Zone_Temp is neither Occupied, Warmup then...
If Zone_Temp is not 8 through 81 then...
Example 4
With IS BETWEEN and IS NOT BETWEEN, you always use AND. IS BETWEEN with
AND is equivalent to IS with THRU. The following statements are equivalent:
Program File
If Zone_Temp is between 70 and 80 then…
If Zone_Temp is 70 thru 80 then…
With THRU or BETWEEN, do not put parentheses around the two elements being
compared. The following parenthesis are not allowed:
If Zone_Temp is (70 thru 80) then…
If Zone_Temp is between (70 thru 80) then…
Program File
If Zone_Temp is not between 70 and 80 then…
If Zone_Temp is not 70 thru 80 then…
If Zone_Temp is not (ROOMTMP-5) thru (ROOMTMP+5)
If Zone_Temp is not ROOMTMP-5 thru ROOMTMP+5
With THRU or BETWEEN, always put the lower number first. The following
examples are not allowed:
If Zone_Temp is 80 thru 70 then…
If Zone_Temp is between 80 and 70 then…

Note
• Both THRU and BETWEEN are always inclusive, so the following are both
TRUE if the ZONE_TEMP is equal to 70 or 80.

If Zone_Temp is 70 thru 80 then…


If Zone_Temp is between 70 AND 80 then…

04-20006-02-en, March 2019 Technical


1689
60 Script Programming
60.24 NOT

60.24 NOT
NOT logically negates or inverts a number or expression, changing 0 (FALSE to
OFF) to 1 (TRUE or ON) or vice versa.

Syntax
not number

Table: NOT Parameter


Parameter Description

number Any number or expression.

Example
Program File
If not OCCUPIED then..
In this example, assume OCCUPIED can be ON or OFF. When OCCUPIED is ON,
placing NOT in front tests for the opposite condition, OFF.

Technical 04-20006-02-en, March 2019


1690
60 Script Programming
60.25 OR

60.25 OR
The OR keyword can be used to provide the logical OR between two expressions,
or positioned in a list of names beween the last two items.
In this second example, OR indicates the end of the series. OR with the last name is
optional. The system carries out all other operations (such as adding and
subtracting) before acting on OR (or AND).
Operators by Precedence compares the order of operations on which the system
software acts. Because OR (and AND) are acted on last, you can form logical
statements without using too many parentheses. See Example 4 for how to use
AND and OR together.

Syntax
number or number
namelist or final_name

Table: OR Parameters
Parameter Description

number Any number, name that stands for a number,


formula or function that gives a number.

namelist One or more names with commas between


them.

final_name A single name at the end of a series of


names.

Examples
Example 1
To take an action only if at least one of several conditions exists, you use OR
between the numbers, so if one of them is true, the resulting action occurs:
Program File
If the Heat is On or the Cool is On then...
Note that in the above statement, you can substitute exclamation mark (!) for OR.
Example 2
To put a list in an IF statement, you can use an OR between the last two names in
the list:
Program File
You cannot use the exclamation mark (!) for OR in a series. You can, however, leave
out OR as follows:
If the Zone is Warming, Occupied, Lowtemp then...
Example 3
You can also combine the logical OR with a name list containing an OR (with or
without the comma before OR) as follows:
Program File
If the Zone is either Warm, Occupied, or Low or Heat is Off then...

04-20006-02-en, March 2019 Technical


1691
60 Script Programming
60.25 OR

The controller always interprets the first OR as the list OR and the second as the
logical OR. If you want to reverse the order of the statement, use parentheses, as
follows:
Program File
If (Heat is Off) or Zone is either Warming, Occupied or Low
then...
Example 4
If OR occurs before AND, the system software interprets OR first because the
software works from left to right on AND and OR. For example, take this statement:
Program File
If WKD = Sat or Wkd = Sun and TOD > 900 then...
The above statement is interpreted so that the items in parentheses below are
calculated first:
If (Wkd = Sat or Wkd = Sun) and TOD > 900 then...
If AND occurs before OR, the controller interprets AND first:
Program File
If TOD > 900 and Wkd = Sat or Wkd = Sun then...
is interpreted as:
If (TOD > 900 and Wkd = Sat) or Wkd = Sun then...

Technical 04-20006-02-en, March 2019


1692
60 Script Programming
60.26 Mathematical Operators

60.26 Mathematical Operators


Mathematical operators perform mathematical operations, such as addition or
subtraction.
Mathematical operators include the following keywords.

60.26.1 DIVIDED BY
DIVIDED BY divides one number by another. The division operator (/) can be
substituted for DIVIDED BY.
For more information, see section 60.27 “DIVIDED BY” on page 1694..

60.26.2 MINUS
MINUS subtracts number from number.
For more information, see section 60.28 “MINUS” on page 1695..

60.26.3 MOD
MOD returns the remainder of one number divided by another.
For more information, see section 60.29 “MOD” on page 1696..

60.26.4 PLUS
PLUS adds two expressions.
For more information, see section 60.30 “PLUS” on page 1697..

60.26.5 TIMES
TIMES multiplies two numbers.
For more information, see section 60.31 “TIMES” on page 1698..

04-20006-02-en, March 2019 Technical


1693
60 Script Programming
60.27 DIVIDED BY

60.27 DIVIDED BY
Aliases: /, DIV
DIVIDED BY divides one number by another. The division operator (/) can be
substituted for DIVIDED BY.

Syntax
number divided by number

Table: DIVIDED BY Parameters


Parameter Description

number Any number or expression.

Examples
Example 1
Program File
Usage = kwh divided by 24
Example 2
Program File
Usage = kwh/24

Technical 04-20006-02-en, March 2019


1694
60 Script Programming
60.28 MINUS

60.28 MINUS
Alias: -
MINUS subtracts number from number.

Syntax
number minus number

Table: MINUS Parameters


Parameter Description

number Any number or expression.

list Two or more numbers (as defined above)


with commas between them.

range Two numbers (as defined above), each


marking one end of a range with THRU
between them, or two numbers preceded by
BETWEEN with AND between them.

Examples
Example 1
Program File
Kwh_day = Kwh_PM minus Kwh_AM
Example 2
Program File
Kwh_day = Kwh_PM - Kwh_AM

04-20006-02-en, March 2019 Technical


1695
60 Script Programming
60.29 MOD

60.29 MOD
Alias: REMAINDER
MOD returns the remainder of one number divided by another.

Syntax
number mod number

Table: MOD Parameter


Parameter Description

number Any number or expression.

Example
Program File
Extra = 5 mod 2
The equation divides 5 by 2 and gives a remainder of 1, so EXTRA is set to 1.

Technical 04-20006-02-en, March 2019


1696
60 Script Programming
60.30 PLUS

60.30 PLUS
Alias : +
PLUS adds two expressions.

Syntax
number plus number

Table: PLUS Parameter


Parameter Description

number Any number or expression.

Example
Example 1
Program File
TotalKwh = KwhMonth plus KwhDay
Example 2
Program File
TotalKwh = KwhMonth + KwhDay

04-20006-02-en, March 2019 Technical


1697
60 Script Programming
60.31 TIMES

60.31 TIMES
Aliases: MULTIPLIED BY, MULT, *
TIMES multiplies two numbers.

Syntax
number times number

Table: TIMES Parameter


Parameter Description

number Any number or expression.

Example
Example 1
Program File
Energycost = Building1_KW times 1.78
Example 2
Program File
Energycost = Building1_KW * 1.78

Technical 04-20006-02-en, March 2019


1698
60 Script Programming
60.32 Program Statements

60.32 Program Statements


Program statements are written with Script words, known as keywords, that are
arranged in a predefined structure. Each keyword has its own keyword syntax.
According to the rules of that syntax, certain parameters and values are allowed or
not allowed to follow a keyword.

60.32.1 Statement Keywords


Statements define the actions that controllers perform (such as START), or assist in
the structure of a statement (such as THE).
For more information, see section 60.33 “Statement Keywords” on page 1700.

04-20006-02-en, March 2019 Technical


1699
60 Script Programming
60.33 Statement Keywords

60.33 Statement Keywords


Statements define the actions that controllers perform (such as START), or assist in
the structure of a statement (such as THE).
Script uses three different types of statement keywords: action, declaration, and
program control statements.

60.33.1 Action Statements


Action statements define the actions that controllers perform (such as SET).
Action statements include the following keywords:
• P
• PRINT
• SET
• TURN
For more information, see section 60.34 “Action Statements ” on page 1702.

60.33.2 Declaration Statements


Declaration statements assist in defining program variables.
Declaration statements include the following keywords:
• ARG
• DATETIME
• LINE
• NUMERIC
• STRING
• THE
For more information, see section 60.39 “Declaration Statements ” on page 1713.

60.33.3 Program Control Statements


Program Control statements assist in directing program flow.
Program Control statements include the following keywords:
• BASED ON...GOTO
• BREAK
• CONTINUE
• FOR..NEXT
• GOTO
• IF...THEN...ELSE

Technical 04-20006-02-en, March 2019


1700
60 Script Programming
60.33 Statement Keywords

• MOVE
• REPEAT...UNTIL
• RETURN
• SELECT CASE
• STOP
• STOP
• WAIT
• WHILE
For more information, see section 60.47 “Program Control Statements ” on page
1728.

60.33.4 Qualifier Statements


Qualifier statements assist in defining input, output, and public variables.
Qualifier statements include the following keywords:
• INPUT
• OUTPUT
• PUBLIC
For more information, see section 60.61 “Qualifier Statements” on page 1753.

04-20006-02-en, March 2019 Technical


1701
60 Script Programming
60.34 Action Statements

60.34 Action Statements


Action statements define the actions that controllers perform (such as SET).

60.34.1 P
P prints the values of one or more variables, points, constants, or other expressions
representing a value, including strings of characters and datetimes, each on a
separate line.
For more information, see section 60.35 “P” on page 1703..

60.34.2 PRINT
PRINT prints a series of characters (text strings, often simply called strings) to a
string object or attribute, a local variable, a printer, or a communications port.
For more information, see section 60.36 “PRINT” on page 1704..

60.34.3 SET
SET assigns a value to a point or variable.
For more information, see section 60.37 “SET” on page 1710..

60.34.4 TURN
TURN sets the name or names to the top of the defined range for the point if ON
and to the bottom of the range if OFF.
For more information, see section 60.38 “TURN” on page 1712..

Technical 04-20006-02-en, March 2019


1702
60 Script Programming
60.35 P

60.35 P
Alias: PR
P prints the values of one or more variables, points, constants, or other expressions
representing a value, including strings of characters and datetimes, each on a
separate line.
The list can contain different types of items. Prints units with point values.
For points, system variables, and attributes, prints the name of the point (or variable
or attribute), followed by an equal sign, the value of the point, and the units.
Otherwise, only the value prints.
Also, can print to comm ports and string objects (including program string
variables).

Syntax
P list

Table: P Parameter
Parameter Description

list One or more expressions with commas


between them. The list can also include
functions or attributes.

Examples
Example 1
Command Line
P SupplyAir, ReturnAir, BurnerStat, CoilStatus
SupplyAir = 46 degrees F
ReturnAir = 68 degrees F
BurnerStat = on
CoilStatus = off
Notice that the name of the point and the units print for each point.
Example 2
Command Line
P OutsideAir, Avg (Temp), AvgSetpt, OutsideAir_Type, TOD
OutsideAir_Type = 46 degrees F
86
AvgSetpt = 64
OutsideAir Type = Input
TIMEOFDAY = 8:32 pm

04-20006-02-en, March 2019 Technical


1703
60 Script Programming
60.36 PRINT

60.36 PRINT
PRINT prints a series of characters (text strings, often simply called strings) to a
string object or attribute, a local variable, a printer, or a communications port.
You can also print to a string point or local variable to fill that point or variable with a
string of text or numbers. In addition, on WorkStation, you can print to an ASCII file.

Syntax
Format 1: any_of_formats_above to string_point_or_variable
Prints any value or string, including messages, points, or variables, into a string
point or variable to set the value of that string.
Format 2: Print string
Prints a string value of text to the default comm port of the program or report.
Format 3: Print list
Prints the values of one or more variables, points, constants, or other expressions
representing a value. The list can contain different types of items.
Format 4: Print string_format, list
Prints the variables, points, or other expressions in the list in the format you specify.

Table: PRINT Parameters


Parameter Description

string A series of characters in quotation marks.

string_format A known character or string of characters


combined with changeable characters to
form one print line.

list A known character or string of characters


combined with changeable characters to
form one print line.

; (Optional) If you end a PRINT statement


without the semicolon, the next line you print
starts on a new line. If you want to print two
strings one after the other on the same line,
you must end the first with a semicolon.

string_point_or_variable Any defined string point or string variable.

Formatting Characters
You can indicate the layout of the print line using the following special symbols:

Technical 04-20006-02-en, March 2019


1704
60 Script Programming
60.36 PRINT

Table: Special PRINT Line Symbols


Character Description

| Indicates the beginning of a series of


characters that are strictly for formatting and
not to be treated as text. When followed by a
numeric constant, indicates an ASCII code
follows.

|" (A vertical bar immediately before a


quotation mark.) Indicates to print the
quotation mark, rather than interpreting that
mark as the beginning or end of the string.

| numeric_constant Produces the ASCII code that corresponds


to the numeric constant. For example, |7
would produce a bell or beep if printed on a
terminal. |13 is the carriage return character.
See the ASCII Codes for more codes.

# Represents one character that is numeric.


The series of characters prints right-justified,
filling with blanks any blank characters to the
left.

$### Displays either ON, -ON, or OFF (as with


tristate Output point).

% Multiplies the point value by 100 and places


a percent sign after that point value (most
useful with scale of 0 to 1, where 1 is 100%).

* Prints the next argument result.

- Prints a leading or trailing minus sign, if


expression is a negative number; prints a
leading or trailing plus sign if expression is a
positive number.

} Removes trailing zeroes (extra decimal


spaces)

, Prints commas every third digit left of the


decimal point.

> Right justifies the number or text within the


format.

< Left justifies the number or text within the


format.

^ Displays a numeric expression in scientific


notation.

@ Represents one character of any kind,


alphabetic or numeric. A series of characters
prints left justified, filling with blanks any
blank characters to the right.

04-20006-02-en, March 2019 Technical


1705
60 Script Programming
60.36 PRINT

The format must be enclosed in quotation marks. The comma is required after the
format (outside the quotation marks) if an item to insert in the format follows (see
Example 3).

Examples

Table: PRINT Program File and Output Columns


No. Program File Output Explanation

1 Print - Prints the value


"HEAT_SETPT" into the string
to PointName and changes its
setting. You can
set a string point
or variable this
way.

2 Print "WARNING - WARNING-Trouble The string of


Trouble on the on the 4th Floor! characters prints; the
4th Floor!" quotation marks do
not.

3 Print TEMP1, 67 72 77 75 The value of each


TEMP2, TEMP3, variable in the list
TEMP4 prints, with a space
after the value.

4 Print "The The Temperature is The string prints with


temperature is 75.0 at 4:32:05 a value of the first
|###.# at point (or variable) in
|##:##:##", the first format and
~Temp4, Hour, the value of the next
Minute, Second point or variable in
the next format. If
there are more than
two formats, the
subsequent point or
variable values are
printed in the
corresponding
formats in order.

5 Print 1340 Leaves 3 leading


"|#######", spaces before the
Total_Watts value of Total Watts.
The value prints on
the terminal called
TERMINAL.

6 Print WeekDay; Tuesday January 2 Prints all text and


spaces on the same
Print " "; line because each
Print Month; PRINT statement
ends with a
Print " "; semicolon (;).
Print DayOfMonth

Technical 04-20006-02-en, March 2019


1706
60 Script Programming
60.36 PRINT

Continued
No. Program File Output Explanation

7 Print 1,340.00 Leaves one leading


"|##,###.##", space. Adds the
Total_Watts comma after the 1
and has two zeros
after the decimal.

8 Print 1,340 Drops extra decimal


"#,###.##}", places (trailing zeros).
Total_Watts

9 Print "The Fan The Fan Status is ON Prints ON, -ON, or


Status is OFF for a digital or
|$###", tristate point, left-
FanStatus justifying ON in the
format.

10 Print "The The Damper Setting Prints the pulsing


Damper Setting is 20.00 value of the damper
is |##.##", in the format. Here
Damper the damper is ON for
20 seconds. for -ON,
the value is negative.

11 Print "| *", Murphy Johnson Outputs any number


Murphy FullName of characters of any
type that are in the
FullName attribute.
The * is particularly
useful when you do
not want to limit the
number of character
in a variable.

12 Print Heater Failed! The message inside


"|@@@@@@@@@@@@@ STRMSG prints left
@", justified in the 14
characters allowed
~ STRMSG to by the @ signs.
Building1
Console

13 Print 21.7 Right justifies and


"|>#######.##}" drops the trailing 0.
, 21.70

14 Print "|-##>##", +88.8 Prints leading minus


88.8 sign if the number is
negative and the
leading plus sign if
the number is
positive. Prints all
trailing zeros.

04-20006-02-en, March 2019 Technical


1707
60 Script Programming
60.36 PRINT

Continued
No. Program File Output Explanation

15 Print "|##.##-", 88.80- Prints trailing minus


-88.80 sign if the number is
negative and the
trailing plus sign if the
number is positive.
Prints all trailing
zeros.

16 Print "|###^## 8,97e03+05 is the Prints the number is


is the "Total." scientific notation.
|"TOTAL.|"", Also prints the
97000 quotation marks
around VALUE,
because a vertical
bar is before each
quotation mark that
should print.

17 Print 8,97e-01 Prints in scientific


"|###^##"", notation with
.8970 negative exponent.

18 Print "|- +1.340e+06 Prints in scientific


##.##^##"", notation with a
1340000 leading plus sign for
a positive number.

19 Print "The The blower's current Prints the text string


blower's current state is ENABLED. left justified in the
state is format and leaves a
|@@@@@@@@.",~ blank for the
Blower State unfulfilled character
at the end.

20 Print "The valve The Valve is set to Prints the value in


is set to |%### 45% open. engineering units as
open.",~Water_V a percentage of the
alue scale for the point.
This format works
best with a scale of 0
to 1, where 0 is fully
closed and 1 is fully
open. So, if the value
is 1, the statement
prints 100%. If the
value is .45, the
statement prints
45%.

Technical 04-20006-02-en, March 2019


1708
60 Script Programming
60.36 PRINT

Continued
No. Program File Output Explanation

21 Print "Date:", Date: December 4, Prints the date.


Month, 2008 Commas must
",~DayOfMonth, separate each group
Test Report of literal text. Notice
",",Year
that the only place a
Print " " space displays is
Print "Test immediately after the
Report" word Date. You must
specify the blank
space in quotation
marks.
Also prints a blank
line between the date
and the report title. If
you use the word
PRINT, followed by
one blank in
quotation marks,
then the entire line
prints as a blank line
(as long as you do
not put a semicolon
at the end).

04-20006-02-en, March 2019 Technical


1709
60 Script Programming
60.37 SET

60.37 SET
Alias: ADJUST and CHANGE (Format 1 only), LET (Format 2 only), MODIFY
SET assigns a value to a point or variable.

Syntax
Syntax 1: Set namelist to number
Syntax 2: Set namelist = number

Table: SET Parameters


Parameter Description

namelist Any defined name or list of names. The


name or names can be any of the following
types:
• Point (any type).
• Local variable, either numeric, string, or
datetime.
The type of name must match the type of
number.

number Any number or expression, including a string


or date and time, or a name that stands for
either of those.
A numeric name can accept only the results
of a numeric expression. A string name can
accept only text. A datetime name can
accept only a date and time.

Examples
Example 1
At any time in a program, you can set the value of a variable or array of variables
using SET and the word TO:
Program File
Set area to height times width
You can also use ADJUST, CHANGE, or MODIFY with TO. With ADJUST and
CHANGE, the TO is required:
Program File
Adjust Valve to Open
Program File
Change Space_SP to 72
Program File
Modify Space_SP to 72
You cannot use the equal sign with ADJUST or CHANGE, but you can use the
equal sign with MODIFY.
Example 2

Technical 04-20006-02-en, March 2019


1710
60 Script Programming
60.37 SET

You can set a variable using SET and an equals sign as in the example below:
Program File
Set KwAbg = Average (KW)
Instead of SET, you can use LET with the equals sign, as follows:
Program File
Let KwAvg = Average (KW)
You cannot use the word TO with LET.
Neither the word SET nor the word LET is required with the equals sign, so you can
set the same variable like this:
Program File
KwAvg = Average (KW)
Example 3
You can set a string variable or point to a particular value:
Program File
Set Stat_Message to "Heat active"
Example 4
You can set several points and variables to a particular value:
Program File
Set KwAvg, OATAvg, HWAvg, CHWAvg = 0

04-20006-02-en, March 2019 Technical


1711
60 Script Programming
60.38 TURN

60.38 TURN
TURN sets the name or names to the top of the defined range for the point if ON
and to the bottom of the range if OFF.

Syntax
Format 1: Turn On point_list
TURN OFF point_list
Format 2: Turn point_list On
TURN point_list OFF

Table: TURN Parameter


Parameter Description

point_list One or more defined output or numeric


points; the statement is not designed for
other types of points.

Examples
Example 1
Suppose you want to turn on the fan and the pump. You can turn both on in one
program statement:
Program File
Turn on the Fan and the Pump
Example 2
You can place the word ON or OFF after the name of the point:
Program File
Turn the Pump off
Example 3
You can also place ON or OFF before the name of the point:
Program File
Turn off the Pump

Technical 04-20006-02-en, March 2019


1712
60 Script Programming
60.39 Declaration Statements

60.39 Declaration Statements


Declaration statements assist in defining program variables.

60.39.1 ARG
ARG is a keyword that defines an argument and can be given a name. After you
assign an easy-to-remember name to an argument variable, you can then refer to
that variable by its name so your function is easier to understand.
For more information, see section 60.40 “ARG” on page 1715..

60.39.2 DATETIME
DATETIME creates and defines one or more names as local DATETIME variables.
You define the variables inside a program for use only in that particular program.
For more information, see section 60.41 “DATETIME” on page 1716..

60.39.3 LINE
LINE labels a particular line in the program so that program control can later branch
or move to that line with the GOTO (or more advanced BASED ON..GOTO)
statement.
For more information, see section 60.42 “LINE” on page 1718..

60.39.4 NUMERIC
NUMERIC creates and defines one or more names as local numeric variables. You
define the variables inside a program for use only in that particular program.
For more information, see section 60.43 “NUMERIC” on page 1722..

60.39.5 STRING
STRING creates and defines one or more names as local string variables. You
define the variables inside a program for use only in that particular program. You
can specify the length of the string of characters with the string_length.
For more information, see section 60.44 “STRING” on page 1724..

60.39.6 THE
THE performs no function, but enhances readability.
For more information, see section 60.45 “THE” on page 1726..

04-20006-02-en, March 2019 Technical


1713
60 Script Programming
60.39 Declaration Statements

60.39.7 Webservice
Webservice delares a Web Service in a Script program.
For more information, see section 60.46 “ Webservice” on page 1727.

Technical 04-20006-02-en, March 2019


1714
60 Script Programming
60.40 ARG

60.40 ARG
Alias: PARAM
ARG is a keyword that defines an argument and can be given a name. After you
assign an easy-to-remember name to an argument variable, you can then refer to
that variable by its name so your function is easier to understand.
ARG can only be used to declare that variable in a function (Syntax 1). ARG calls the
argument variable by the variable’s number (Syntax 2).

Syntax
Syntax 1: ARG integer_constant name
Syntax 2: ARG [ integer_expression ]

Table: ARG Parameters


Parameter Description

integer_constant Any integer between 1 and 15.

name Any name you choose for the argument


including underscore and period, but must
begin with a letter. Not a keyword.

integer_expression Any integer or expression that gives an


integer.

Examples
Example 1
In this example, ARG[5] represents the status of a report. To make that easier to
understand, ARG[5] is named RPTSTATUS. The program refers to RPTSTATUS for
the variable value from then on.
Function File
ARG 5 RptStatus
Example 2
To test to see if the report status equals SUCCESS, you can call on the argument
variable using the easy-to-remember name (from Example 1):
Function File
If RptStatus is Success then…
Example 3
To test to see if the report status equals SUCCESS, you can also call on the
argument variable using ARG[5]:
Function File
If ARG[5] is Success then…

04-20006-02-en, March 2019 Technical


1715
60 Script Programming
60.41 DATETIME

60.41 DATETIME
DATETIME creates and defines one or more names as local DATETIME variables.
You define the variables inside a program for use only in that particular program.
You define the variables as follows:
• Specify an array by including the array_size_number during the array definition
since each variable can be a single variable or an array.
• Add seconds as if the datetime were a number because the datetime is stored
in seconds.
• Define all local datetime variables at the top of your program.
• Set the datetime variable to the time at a given moment using the DATE system
variable.
• Print the datetime variable. When you do, you receive the date and time printed
in this format:
MONTH DD YYYY hh:mm:ss
The month is spelled out; the day is two digits, the year is four digits. The hour,
minute, and second are in 24-hour time.
Binding Qualifiers
Variables can also be bound to the object property of a point outside of the
program. To do this, you must use a keyword, either Input or Output.

Syntax
Datetime Binding_qualifier namelist [ array_size_number ]

Table: DATETIME Parameters


Parameter Description

namelist The name of a datetime variable you are


defining or a series of datetime variables
separated by commas.

array_size_number A number up to 32,767 that tells the


controller how many positions are in the
array.

Binding_qualifier The keyword Input or Output, which you can


bind to a point.

Examples
Example 1
In this program, the first statement defines the TEMPTIME as a datetime variable.
The next statement sets the variable to the time at a given moment with the DATE
system variable:
Program File
Datetime TempTime
TempTime = date
Example 2
You can define a series of datetime variables in a single statement:

Technical 04-20006-02-en, March 2019


1716
60 Script Programming
60.41 DATETIME

Program File
Datetime TempTime, FirstTime, LastTime
Example 3
You can define more than one array of datetime variables in a single statement:
Program File
Datetime TempTime[40], Timer[30], Watch[15]
Example 4
You can define several arrays of datetime variables and several single variables in a
single statement:
Program File
Datetime TempTime[40], FirstTime, Timer[30], LastTime

04-20006-02-en, March 2019 Technical


1717
60 Script Programming
60.42 LINE

60.42 LINE
LINE labels a particular line in the program so that program control can later branch
or move to that line with the GOTO (or more advanced BASED ON..GOTO)
statement.

Caution
• Line names 0, C, and E are reserved for use by WorkStation. LINE 0 is
predefined for stopping the program, so you cannot label a line LINE 0.
However, you can use GOTO line 0 to stop a program. You can label a line
LINE E and the program automatically goes to that line when an error occurs.
LINE C is reserved for future use.

You can label lines to redirect program flow to any part of the program. For
example, you could return program flow to an earlier line, such as the first line. Or
you could send program flow to a later line to branch into a specific set of actions.

Syntax
Line linename
linename:
Line integer
Integer:

Table: LINE Parameters


Parameter Description

linename Any single character or word that is not a


keyword, except:
• C (reserved)
• E (used for error detection)
You must begin the name with an alphabetic
character. In the GOTO statement, the label
must be spelled exactly as is in the LINE
statement; however, you can interchange
upper- and lowercase.

integer Any single whole number, except 0.


LINE 0 is predefined for stopping the
program, so you cannot label a line LINE 0.
However, you can use the GOTO line 0 to
stop a program.

Format 2 The linename followed by a colon (:) on its


own line.

Format 4 The integer followed by a colon (:) on its own


line. In this case, the line has a line number
for a name.

Examples
Example 1

Technical 04-20006-02-en, March 2019


1718
60 Script Programming
60.42 LINE

In the following example the first linename is STARTUP, labeled LINE STARTUP.
Follow the program flow to see how the line name directs the control of the
program.
Program File
Line Startup
If Temp > 72 then goto Cooling
If Temp < 70 then goto Heating
Line Heating
Turn on the Heat
...
Goto Startup
Line Cooling
Turn on the Blower
...
Goto Startup
Example 2
This example is the same as the last, only each linename is labeled with the name
followed by a colon:
Program File
Startup:
If Temp > 72 then goto Cooling
If Temp < 70 then goto Heating
Heating:
Turn on the Heat
...
Goto Startup
Turn on the Blower
Cooling:
...
Goto Startup
Example 3
This example shows how to use an integer as a line label:
Program File
LINE 1
Start Fan1
Goto 2
LINE 2
If Fan1_Status is on then goto Shutdown
LINE Shutdown
If Zone1 temperature is less than 60 then

04-20006-02-en, March 2019 Technical


1719
60 Script Programming
60.42 LINE

Stop Fan1
Goto 1
Endif
Example 4
This example shows an integer with a colon as a line label:
Program File
1:
Start Fan1
Goto 2
2:
If Fan1_Status is on then goto 3
3:
If Zone1 temperature is less than 60 then
Stop Fan1
Goto 1
Endif
Example 5
This example shows a program that has a line labeled E. The program automatically
goes to line E when an error occurs. If you do not have a line E, the software
automatically disables the program. When an error occurs, you might want the
program to go to a special line. For example, you might want the program to go to a
special line that closes an open comm port (see OPEN).
The following program goes to line E and closes the comm port when an error
occurs:
Program File
Numeric Result
Line OpenPort3
Result = Open (Comm3)
Line TestingOpen
If result = success then goto PrintMenus
Line PrintMenus
Run MenuDisplay
...
If Comm3_PrintDone = true then goto ClosePort3
Line ClosePort3
Result = Close (Comm3)
Line TestingClose
If result = Success then Stop
Line E
Result = Close (Comm3)

Technical 04-20006-02-en, March 2019


1720
60 Script Programming
60.42 LINE

Print "EMERGENCY EXIT - MENUPROGRAM FAILED."


If you have a line E, when an error occurs, line E displays in the file status
information.

04-20006-02-en, March 2019 Technical


1721
60 Script Programming
60.43 NUMERIC

60.43 NUMERIC
Alias: NUMBER
NUMERIC creates and defines one or more names as local numeric variables. You
define the variables inside a program for use only in that particular program.

Tip
A numeric variable is a name that represents a number. Numeric variables are
subject to the same range limitations as numeric constants. Numeric constants,
variables, points, expressions (formulas), or functions can be compared to other
numeric type items or used in mathematical calculations.

Each variable can be a single variable or an array. You specify an array by including
the array_size_number during the array definition.

Binding Qualifiers
Varibles can also be bound to the object property of a point outside of the program.
To do this, you must use a keyword, either Input or Output.

Syntax
Numeric Binding_qualifier namelist [array_size_number]

Table: NUMERIC Parameters


Parameter Description

namelist The name of the numeric variable you are


defining, or a series of numeric variables
separated by commas.

array_size_number A number up to 32,767 that tells the


controller how many positions are in the
array.

Binding_qualifier The keyword Input or Output which you can


bind to a point.

Examples
Example 1
Suppose that you are averaging the values of the ten temperatures. The points that
take the outside air temperature have been defined using menus and windows, but
you define the variable that contains the average using NUMERIC:
Program File
Numeric Avg_Temp
Avg_Temp = Average (Temp)
Print Avg_Temp
Example 2
You can define a series of numeric variables in a single statement:
Program File

Technical 04-20006-02-en, March 2019


1722
60 Script Programming
60.43 NUMERIC

Numeric Ave_OAT, AVE_Temp, Fan_SP


Example 3
You can define an array of numeric variables in a single statement:
Program File
Numeric Fan_SP[20]
Example 4
You can define several arrays of numeric variables and several single variables in a
single statement:
Program File
Numeric Fan_SP[20], Pump_SP, AHU_SP[10], Heat_SP

04-20006-02-en, March 2019 Technical


1723
60 Script Programming
60.44 STRING

60.44 STRING
STRING creates and defines one or more names as local string variables. You
define the variables inside a program for use only in that particular program. You
can specify the length of the string of characters with the string_length.

Tip
A string variable is a name that represents a series of alphanumeric characters.
String constants, variables, points, expressions, or functions can be compared to
other string type items. Strings cannot be used in mathematical calculations
unless they are converted to a numeric type.

Each variable can be a single variable or an array. You specify an array by including
the array_size_number during the array definition.
You must define all local string variables at the top of your program.
STRING is used to store textual information in the current program.
If you do not give a string_length, the string is given the default length, which is 16
characters.

Tip
For EcoStruxure BMS servers, the maximum string_length is 255 characters. For
b3 BACnet devices, the maximum length is 32 characters. The Script compiler
catches any number that is out of range.

Binding Qualifiers
Varibles can also be bound to the object property of a point outside of the program.
To do this, you must use a keyword, either Input or Output.

Syntax
String Binding_qualifier string_length namelist [array_size_number]

Table: STRING Parameters


Parameter Description

namelist The name of the string (text) variable you are


defining, or a series of string variables
separated by commas.

array_size_number (Optional) Any number up to 32,767 that tells


the controller how many positions are in the
array.

Binding_qualifier The keyword Input or Output which you can


bind to a point.

Examples
Example 1
To set a string variable, you must first define that variable using STRING. To define a
single string variable of the default length, you enter this program line:

Technical 04-20006-02-en, March 2019


1724
60 Script Programming
60.44 STRING

Program File
String VarName
Example 2
To have a program read information from a file containing text, you would create a
series of string variables like those below to contain each piece of text information.
You can create them all in the same program line:
Program File
String 20 LNAME, LOGON, PWORD, ROOM, TERMINAL
The length of each string is 20. To give them different lengths, you must define
(declare) each one separately.
Example 3
To create a string array of variables, you must first define the array. The string called
PUMP below is an eight-character string with 20 variables in the array (PUMP[1],
PUMP[2], PUMP[3], and so on).
Program File
String 8 Pump[20]
Pump[6] = "HeatPump"
Example 4
You can create several arrays of string variables and single string variables all in one
program line:
Program File
String Pump[6], Blower[8], HeaterNM, FanName

04-20006-02-en, March 2019 Technical


1725
60 Script Programming
60.45 THE

60.45 THE
THE performs no function, but enhances readability.

Syntax
the name

Table: THE Parameter


Parameter Description

name Any point, piece of equipment, terminal,


computer, or printer.
THE can precede a name only. THE cannot
precede a keyword that designates an
action (verb).

Examples
Program File
Turn on the Fan

Technical 04-20006-02-en, March 2019


1726
60 Script Programming
60.46 Webservice

60.46 Webservice
Webservice delares a Web Service in a Script program.
For more information, see section 62.1 “Script Web Services” on page 1937.

Note
Webservice is not supported in the MP Series controller.

Syntax
Webservice (service name)

Table: Webservice Parameter


Parameter Description

service name Any Web Service name of your choosing.

Tip
The Web Service declaration name does not need to match the Script Web
Service object you intend to bind.

Example
You declare a Web Service here in order to invoke an online calculator service.
Program File
Webservice wsCalculator

04-20006-02-en, March 2019 Technical


1727
60 Script Programming
60.47 Program Control Statements

60.47 Program Control Statements


Program Control statements assist in directing program flow.

60.47.1 BASEDON...GOTO
BASEDON...GOTO branches to a different line for each value the number can have.
You put the line names in the linelist.
For more information, see section 60.48 “BASEDON...GOTO” on page 1730..

60.47.2 BREAK
BREAK halts the smallest enclosing FOR...NEXT, REPEAT...UNTIL, WHILE, or
SELECT CASE statement.
For more information, see section 60.49 “BREAK” on page 1732..

60.47.3 CONTINUE
CONTINUE stops the current iteration of the smallest enclosing FOR...NEXT,
REPEAT...UNTIL, or WHILE statement and starts the next iteration from the top of
the loop. CONTINUE also exits the SELECT CASE statement.
For more information, see section 60.50 “CONTINUE” on page 1733..

60.47.4 FOR...NEXT
FOR...NEXT carries out all statements in a loop a fixed number of times.
For more information, see section 60.51 “FOR...NEXT” on page 1734..

60.47.5 GOTO
GOTO branches to the line labeled linename.
For more information, see section 60.52 “GOTO” on page 1737..

60.47.6 IF...THEN...ELSE
IF...THEN...ELSE carries out a given statement or series of statements if the
expression is TRUE.
IF...THEN...ELSE can also carry out a given statement or series of statements if the
given expression is FALSE.
For more information, see section 60.53 “IF...THEN...ELSE” on page 1740..

Technical 04-20006-02-en, March 2019


1728
60 Script Programming
60.47 Program Control Statements

60.47.7 MOVE
MOVE converts engineering units to electrical units to control the output point,
using the top and bottom of scale for that point.
For more information, see section 60.54 “MOVE” on page 1744..

60.47.8 Repeat...Until
Repeat...Until carries out the statements in the loop until the number is true.
For more information, see section 60.55 “Repeat...Until” on page 1745..

60.47.9 RETURN
In a function, the RETURN keyword controls the calling program, returns and sends
the number to the calling program, and returns the contents of the variable.
For more information, see section 60.56 “RETURN” on page 1746..

60.47.10 SELECT CASE


SELECT CASE executes one or more statements, depending on the value of a
test_expression.
For more information, see section 60.57 “SELECT CASE” on page 1748..

60.47.11 STOP
With an output point, STOP actually stops the piece of equipment. With an input
point, STOP sets the point to the bottom of the defined scale. With a numeric point,
STOP sets the point to the lowest number in the controller system. You might STOP
an input after using the RUN keyword in order to test whether the input is active.
For more information, see section 60.58 “STOP” on page 1750..

60.47.12 WAIT
WAIT makes a program's execution wait for a specified number of seconds and
then resume right after the WAIT command statement.
For more information, see section 60.59 “WAIT” on page 1751..

60.47.13 WHILE
WHILE carries out the instructions in the statements within the loop over and over
again as long as the given number is TRUE.
For more information, see section 60.60 “WHILE” on page 1752..

04-20006-02-en, March 2019 Technical


1729
60 Script Programming
60.48 BASEDON...GOTO

60.48 BASEDON...GOTO
BASEDON...GOTO branches to a different line for each value the number can have.
You put the line names in the linelist.

Syntax
Syntax 1:
Basedon (number) Goto linelist
or
Basedon (number) Go to linelist
or
Basedon (number) Go to linelist
Syntax 2:
Basedon (number) Goto Line linelist
or
Basedon (number) Go to Line linelist

Table: BASEDON... GOTO Parameters


Parameter Description

number Any number or expression. If less than 1 or


greater than the number of lines in the
linelist, the controller ignores the
BASEDON...GOTO statement and executes
the statement immediately after
BASEDON...GOTO.

linelist One or more defined line labels (see LINE


statement) present in the current program.
The label must be spelled here just as the
label is defined, except you can interchange
upper- and lowercase. The line label can
also be an integer.

Examples
You can have a series of steps (a line) that you want to run every Friday to shut
down equipment not required over the weekend. Then, every Monday you can
restart that equipment.
To run different lines on particular days, you write a program that activates certain
lines based on the day of the week. The lines are labeled with LINE, telling the line
the routine starts on.
Remember that SUN is considered the first day of the week, so in the program
below, the first line listed after GOTO runs on Sunday, the next on Monday, the next
on Tuesday, and so on:
Program File
Basedon Wkd Goto Sun_1, Mon_1, Tue_1, Wed_1, Thu_1, Fri_1, Sat_1

Line Sun_1

Technical 04-20006-02-en, March 2019


1730
60 Script Programming
60.48 BASEDON...GOTO


Line Mon_1

Line Tue_1

Line Wed_1

Line Thu_1

Line Fri_1

Line Sat_1

Note
• The following variations to the BASEDON statement (above) are acceptable.

You can also include the word LINE in front of the line list:
Basedon Wkd Goto Line Sun_1, Mon_1, Tue_1, Wed_1, Thu_1, Fri_1,
Sat_1
You can replace GOTO with the word GO:
Basedon Wkd Go Sun_1, Mon_1, Tue_1, Wed_1, Thu_1, Fri_1, Sat_1
You can separate the word GO from the word TO:
Basedon Wkd Go to Sun_1, Mon_1, Tue_1, Wed_1, Thu_1, Fri_1, Sat_1
You can include the word LINE after GO and TO:
Basedon Wkd Go to Line Sun_1, Mon_1, Tue_1, Wed_1, Thu_1, Fri_1,
Sat_1

04-20006-02-en, March 2019 Technical


1731
60 Script Programming
60.49 BREAK

60.49 BREAK
BREAK halts the smallest enclosing FOR...NEXT, REPEAT...UNTIL, WHILE, or
SELECT CASE statement.
After BREAK executes, the next statement the controller carries out is the one
immediately following the end of the loop or block.

Syntax
Break

Examples
To check several stored temperatures to see if any is reading over 75 degrees, you
use a FOR...NEXT loop. Normally, the loop below would end after checking the 20
temperatures. To exit the loop as soon as you find one over 75 degrees, you use
the BREAK statement.
Program File

Technical 04-20006-02-en, March 2019


1732
60 Script Programming
60.50 CONTINUE

60.50 CONTINUE
CONTINUE stops the current iteration of the smallest enclosing FOR...NEXT,
REPEAT...UNTIL, or WHILE statement and starts the next iteration from the top of
the loop. CONTINUE also exits the SELECT CASE statement.
Each time the loop repeats, the action is an iteration of that loop.

Syntax
Continue

Examples
To check several temperatures stored in an array and print names of those over 75
degrees, you use a FOR...NEXT loop. (See the FOR...NEXT statement.) Normally,
the loop below would print the names of all 20 stored temperatures. To get the loop
to select those over 75, use CONTINUE to break the loop whenever one is less than
or equal to 75, and skip to the next array item.
Program File

In the above program, if the temperature is less than or equal to 75 degrees,


CONTINUE tells the controller to go back to the top of the FOR...NEXT loop to
check the next temperature (and therefore skip any statement between CONTINUE
and the NEXT statement).

04-20006-02-en, March 2019 Technical


1733
60 Script Programming
60.51 FOR...NEXT

60.51 FOR...NEXT
FOR...NEXT carries out all statements in a loop a fixed number of times.

Syntax
Syntax 1:
For numeric_name = begin to end
Statement
Statement
...
Next numeric_name
Syntax 2:
For numeric_name = begin to end step number
Statement
Statement
...
Next numeric_name

Table: FOR...NEXT Parameters


Parameter Description

numeric_name A defined local variable or point that stands


for a number.
The numeric_name after NEXT must be the
same as the one after FOR.

statement Any complete instruction that tells the


program what to do next or what action to
take.

begin An integer expression.

end An integer expression.

number The amount to increase numeric_name by


each time the controller goes through the
loop.

Examples
Example 1
A FOR...NEXT loop looks like this:
Program File
For count = 2 to 10 step 2
Print count, " ", (10 + count)
Next count

Technical 04-20006-02-en, March 2019


1734
60 Script Programming
60.51 FOR...NEXT

The statement sets the value of the numeric_name to the begin value, then carries
out the statements after FOR until reaching NEXT. At NEXT, the program goes back
to FOR and gets the next value of numeric_name by adding number to begin.
Here, since begin is 2, end is 10, and number is 2, the numeric_name (often called
the counter) counts 2, 4, 6, 8, 10. The first time through the loop numeric_name is
2, the second time numeric_name is 4, and so on.
As long as numeric_name is less than or equal to end, the statements inside the
loop are carried out. When numeric_name is greater than end the program then
goes to the statement after NEXT.
Here is the output printed by the previous loop:
2 12
4 14
6 16
8 18
10 20
If you do not specify a STEP number, the name automatically increases by one
(increments) each time the loop executes.
The step can also be a negative step, taking the value of the name from a begin of,
for example, 10 to an end of 1 by a number of -1.
The step can also be a negative step, taking the value of the name from a begin of,
for example, 10 to an end of 1 by a number of -1.
Example 2
Before you run functions that use the ARG variables, you can set them all to zero
with one programming statement using FOR...NEXT:
Program File
For count = 1 to 15
Set ARG[count] = 0
Next count
The first time through the loop, ARG[1] is set to 0, the second time ARG[2] is set to
0, the third time ARG[3] is set to 0, and so on.
Example 3
To set every third value in an array to zero, you can go to the third item, then sixth,
then ninth, and so on, using STEP with FOR...NEXT:
Program File
Number count
For count = 3 to 15 step 3
Set Pump[count] = 0
Next count
Example 4
To find a filtered average, you could set up a function called FILT_TOTAL. The
function, shown below, uses FOR...NEXT to loop from ARG[3] through ARG[15],
and add only the numbers with a value between that of ARG[1] and ARG[2].
Function File

04-20006-02-en, March 2019 Technical


1735
60 Script Programming
60.51 FOR...NEXT

Technical 04-20006-02-en, March 2019


1736
60 Script Programming
60.52 GOTO

60.52 GOTO
GOTO branches to the line labeled linename.

Syntax
Syntax 1: Goto linename
Syntax 2: Goto Line linename
Syntax 3: Go linename
Syntax 4: Go To linename
Syntax 5: Go To Line linename

Table: GOTO Parameter


Parameter Description

linename Any line label created with the LINE


statement. Must be in the same program.

Examples
Example 1
In the following looping program, the GOTO statement with IF..THEN controls the
heating and cooling processes:
Program File
Line Beginning
If Temp is less than 68 then Goto Heating
If Temp is greater than 76 then Goto Cooling
Line Heating
Turn on Heater1
Goto Beginning
Line Cooling
Turn on Cool1
Goto Beginning
Both Heating and Cooling are line labels. When the temperature changes, GOTO
sends control to the appropriate line.
The controller then executes instructions in the labeled line.
Notice that the GOTOs have been strategically placed so the controller executes
some statements and skips others.
Example 2
You can include the word LINE in front of the line name, as follows:
Program File
Line 1
Start Fan1
Goto Line 2

04-20006-02-en, March 2019 Technical


1737
60 Script Programming
60.52 GOTO

Line 2
If Fan1_Status is on then Goto Line Shutdown
Line Shutdown
If Zone1 Temp is less than 60 then
Stop Fan1
Goto Line 1
Endif
Example 3
You can leave out TO and type only GO:
Program File
Line Beginning
If Temp is less than 68 then go Heating
If Temp is greater than 76 then go Cooling
Line Heating
Turn On Heater1
Go Beginning
Line Cooling
Turn On Cool1
Go Beginning
Example 4
You can separate GO and TO, as follows:
Program File
Line Beginning
If Temp is less than 68 then Go to Heating
IF Temp is greater than 76 then Go to Cooling
Line Heating
Turn Heater1
Go to Beginning
Line Cooling
Turn On Cool1
Go to Beginning
Example 5
You can separate GO and TO, and include LINE as well:
Program File
Line Beginning
If Temp is less than 68 then Go to Line Heating
If Temp is greater than 76 then Go to Line Cooling
Line Heating
Turn On Heating1

Technical 04-20006-02-en, March 2019


1738
60 Script Programming
60.52 GOTO

Go to Line Beginning
Line Cooling
Turn On Cool1
Go to Line Beginning

04-20006-02-en, March 2019 Technical


1739
60 Script Programming
60.53 IF...THEN...ELSE

60.53 IF...THEN...ELSE
IF...THEN...ELSE carries out a given statement or series of statements if the
expression is TRUE.
IF...THEN...ELSE can also carry out a given statement or series of statements if the
given expression is FALSE.
For all formats, the following actions take place:
• If the expression is TRUE, the controller carries out the statement or
statements following THEN.
• If the expression is FALSE, the controller skips those statements after THEN
and does either of these actions:
– Carries out the statements after ELSE (if ELSE is used).
– Moves on to the next statement after the IF..THEN block.
Whether the expression is TRUE or FALSE, when the IF..THEN statement is
complete, program flow goes to the statement following the IF..THEN statement
unless the flow is directed to another line using GOTO, BREAK, or CONTINUE.
If you have multiple statements after THEN, they must occur on consecutive
(physical) lines, and the end of the statement must be marked with ENDIF.
Here are some general rules you should follow for all formats:
• IF and THEN must always be on the same physical line.
• THEN can be followed by one statement on the same physical line or many
statements on the physical lines that follow.
• If a multi-line statement, ELSE must always be on a physical line by itself
(Syntax 4).
• ELSE can be followed by one statement on the same physical line or multiple
statements on the physical lines that follow (Syntax 4).
• ENDIF is required to close an IF..THEN block when multiple statements occur
after THEN or when one or more statements occur after ELSE.
• When you use an IF statement after THEN, that statement must be nested
under THEN and end with ENDIF. (See Example of an IF statement after THEN,
below.)

Syntax
Syntax 1:
If expression then statement
Syntax 2:
If expression then
statement
statement
statement
..
ENDIF
Syntax 3:
If expression then statement else statement

Technical 04-20006-02-en, March 2019


1740
60 Script Programming
60.53 IF...THEN...ELSE

Syntax 4:
If expression then
statement
statement
statement
...
Else
statement
statement
statement
...
Endif

Table: IF...THEN...ELSE Parameters


Parameter Description

expression Any number or expression. The expression


can be a TRUE or FALSE comparison.

statement Any complete instruction that tells the


program what to do next or what action to
take.

Examples
Example of Syntax 1
To take a single action if the expression is TRUE, you use Syntax 1, the single-line
IF..THEN statement:
Program File
If TOD >= 1200 then Goto Noon
If the time of day is greater than 12:00 noon, then program flow moves to the
NOON line. Otherwise, the program continues with the next statement.

Note
• If you put THEN on a separate physical line from IF, a syntax error occurs.

Example of Syntax 2
To take several actions if the expression is TRUE, and take no action if the
expression is FALSE, you use Syntax 2:
Program File
If Wkd = Mon and TOD > 800 and TOD < 1600 then
Run the HeaterProg
Run the FanCheckProg
Stop the PumpProg

04-20006-02-en, March 2019 Technical


1741
60 Script Programming
60.53 IF...THEN...ELSE

Endif
If the expression is FALSE, the controller ignores the statements following THEN
and moves to the statement after ENDIF.
Example of Syntax 3
To take a single action if an expression is TRUE and another single action if the
expression is FALSE, you use Syntax 3:
Program File
If TOD > 800 & TOD < 1700 then Run DayPrg else Run NiteProg
Notice that IF, THEN, and ELSE must all be on one line in this format.
Example of Syntax 4
To take several actions if the expression is TRUE or take several others if the
expression is FALSE, you use Syntax 4:
Program File
If Temp < 72 and [Link] is off then
Turn on the Fan
Close the Damper
Else
Turn off the Fan
Open the Damper
Endif
ELSE stands on a line by itself in this format, and the end of the IF.. THEN..ELSE
statement must be marked by ENDIF.
Example of nested IFs
IF statements can be included (nested) within other IF statements.
Program File
If the Wkd is Either Saturday OR Sunday then
Set Occupancy to Off
Stop the DailyProgram
If the Temp is Greater Than 70 then
Turn On the Fan
Open the Damper
Else
Turn OFF the Fan
Open the Damper
Endif
Else
Set Occupancy to On
Start the DailyProgram
Endif

Technical 04-20006-02-en, March 2019


1742
60 Script Programming
60.53 IF...THEN...ELSE

Notice that each IF ends with an ENDIF. The inner (indented) ENDIF goes with the
inner IF and ELSE, the outer ENDIF with the outer IF and ELSE.
The ELSE and ENDIF that belong to the indented IF are aligned under that IF.
Notice that the last IF ends first.
Example of an IF statement after THEN
Take a look at the following statement with an IF after THEN:
Program File
If the Wkd is Sat then if the Hour is 1 then Goto 1 else Goto 2
Which IF does the ELSE belong to? In this case the ELSE belongs to the second IF.
Why? Because ELSE belongs to the closest previous IF on the same physical line.
An IF..THEN statement that starts right after THEN is always a self-contained
statement that ends on that physical line.
To make the ELSE belong to the first IF, you must form a nested IF arrangement, as
follows:
Program File
If the Wkd is Sat then
If the Hour is 1 then
Goto 1
Endif
Else
Goto 2
Endif
In this nested IF statement, the ELSE belongs with the first IF.
Example of a nonzero value number
Program File
If 10 then start Burner
Here, since 10 is a nonzero value, 10 is interpreted as TRUE and causes the burner
to fire up.

Caution
• Be careful when programming with IF..THEN..ELSE statements if the number
is any nonzero value. When this occurs, the number is interpreted as TRUE
and the THEN block is executed.

04-20006-02-en, March 2019 Technical


1743
60 Script Programming
60.54 MOVE

60.54 MOVE
Alias: MODULATE
MOVE converts engineering units to electrical units to control the output point,
using the top and bottom of scale for that point.
Set the point or points in output_point_list to number.
The percent sign is optional.

Syntax
MOVE output_point_list TO number
MOVE output_point_list TO number %

Table: MOVE Parameters


Parameter Description

output_point_list One or more output point names or variables


with commas between them. Top and
bottom of scale must be set for each point.

number Any number or expression, including a date


and time or name that stands for one.

Products Supported
CX series, BACnet series, CMX series, SCX series, TCX series, LCX series, ACX
series, DCX 250, EcoStruxure BMS servers

Examples
Example 1
If Valve2 has engineering units of 0 to 90 degrees, and the corresponding electrical
units are 0 to 20 mA, when you move the setting of Valve2 to 45, the electrical unit
sets to 10 mA. To have the engineering units automatically converted to electrical
units, you use MOVE as follows:
Program File
MOVE VALVE2 TO 45
Example 2
For this valve, assume engineering units of 0 to 1 where 0 is closed and 1 is open
and corresponding electrical units of 0 to 20 mA. Moving the setting of Valve2 to
50% gives .5. At .5, the valve is set to the corresponding value of 10 mA.
Program File
MODULATE VALVE2 TO 50%

Technical 04-20006-02-en, March 2019


1744
60 Script Programming
60.55 Repeat...Until

60.55 Repeat...Until
Repeat...Until carries out the statements in the loop until the number is true.

Syntax
Repeat
statement
statement
...
Until number

Table: Repeat...Until Parameters


Parameter Description

statement Any complete instruction that tells the


program what to do next or what action to
take.

number Any number or expression, including a date


and time or name that stands for one.

The statements within the loop always execute at least once before the expression
is evaluated.

Examples
You want to print all the values in an array:
Program File
Numeric Count
Count = 1
Repeat
Print OutsideAir [Count]
Count = Count + 1
Until Count = OutsideAir_Size

04-20006-02-en, March 2019 Technical


1745
60 Script Programming
60.56 RETURN

60.56 RETURN
In a function, the RETURN keyword controls the calling program, returns and sends
the number to the calling program, and returns the contents of the variable.
If you expect to use the results of a calculation in more than one program, you set
up a function file and put the calculation instructions inside, thus creating a function.
When you need the function in a program, you call the function by using the
function variable as if that function were any other keyword verb.
Later, the RETURN statement tells the function the value to return to the calling
program.
Make sure to return a number or other value when you want to use the returned
value in the calling program.

Syntax
Return
Return number

Table: RETURN Parameter


Parameter Description

number (Optional) Any number or expression,


including a date and time or name that
stands for one.

Examples
Example 1
You use RETURN without an expression to return to the calling program without
passing parameters. You might do that with a function that contains a series of
actions to be carried out, as in the SHUTDOWN function shown below:
Function File
Turn off the Heat
Turn off the Fan
Run Pump, Cooling
Return
In this case, RETURN returns you to the program that called the SHUTDOWN
function, returning a numeric 0 because you supplied no arguments on the
RETURN statement.
The statement that calls SHUTDOWN in the calling program looks like this:
Program File
Shutdown ()
Example 2
To create a function called GetArea that calculates the cross-sectional area of a
circle, name the function file GetArea and enter the following in the function file:
Function File
ARG 1 radius

Technical 04-20006-02-en, March 2019


1746
60 Script Programming
60.56 RETURN

Return (3.14159 * (radius ^ 2))


You pass the radius into the function file from the calling statement in the main
program. Here is a sample calling statement:
Program File
VOL = GetArea(radius) * LEG
This statement calls the GetArea function, giving the radius value, which the
function requires to calculate the area.
Example 3
Create a function that uses a diameter as an argument to calculate and return the
value of the circumference.
Function File
ARG[1] diameter
Numeric Circumf
Circumf = 3.14159 * diameter
Return (Circumf)

04-20006-02-en, March 2019 Technical


1747
60 Script Programming
60.57 SELECT CASE

60.57 SELECT CASE


SELECT CASE executes one or more statements, depending on the value of a
test_expression.

Syntax
Select Case test_expression
Case expression_list
statement_list
Case expression_list
statement_list
...
Case Else
else_statement_list
EndSelect

Table: SELECT CASE Parameters


Parameter Description

test_expression Any numeric, string, or datetime expression.

expression_list A list of one or more expressions, separated


by commas.

statement_list One or more statements to execute if


test_expression matches any expression in
the corresponding expression_list.

else_statement_list One or more statements to execute if


test_expression matches any expression in
corresponding expression_list.

If test_expression matches any expression in CASE expression_list, then the


statements following that CASE clause are executed up to the next CASE clause, if
any, or up to EndSelect. At least one CASE expression_list clause is expected.
The CASE ELSE clause is used to execute the statements in else_statement_list if
test_expression does not match any expression in any of the CASE expression_list
clauses. The CASE ELSE clause is not required. However, you should include the
clause anyway to catch unexpected test_expression values.
Once the statements in the statement_list or else_statement_list have been
executed, the statement right after the EndSelect is the one to execute next.
Expressions can be numeric, string, or datetime.

Examples
Example 1
Program File
Select Case Weekday
Case Monday, Tuesday

Technical 04-20006-02-en, March 2019


1748
60 Script Programming
60.57 SELECT CASE

Print "Run Mon_Tue Report"


Case Wednesday thru Friday
Print "Run Wed_Thu_Fri Report"
Case Else
Print "Run Weekend Report"
EndSelect
Example 2
Program File
Numeric ReportId
Select Case ReportId
Case 1
Print "Run First Report"
Case 2, 3, 5 thru 10, 15
Print "Run Special Report"
Case 20
Print "Run Final Report"
Case Else
Print "Invalid Report Id"
EndSelect
Example 3
Program File
Select Case Numeric1 Description
Case Numeric2 Description
Print "Numeric1 and Numeric2 have the same description”
Case “West Building”
Print "Numeric1 is the West Building”
Case Else
Print "Numeric1 is not the West Building”
EndSelect

04-20006-02-en, March 2019 Technical


1749
60 Script Programming
60.58 STOP

60.58 STOP
Aliases: CLOSE, SHUT
With an output point, STOP actually stops the piece of equipment. With an input
point, STOP sets the point to the bottom of the defined scale. With a numeric point,
STOP sets the point to the lowest number in the controller system. You might STOP
an input after using the RUN keyword in order to test whether the input is active.

Syntax
Stop point_list
Sets the point (or points) to bottom of its defined scale, turns the equipment off, and
controls the equipment through the point. You can use this statement in a program
to turn off a piece of equipment.

Table: STOP Parameters


Parameter Description

point_list Usually any defined Output point or list of


points. The statement is not designed for
other types of points, but you can stop an
input or numeric point.

Examples
You can STOP a program from inside a program in response to a certain set of
conditions. For example, to halt the HEATPROG after 8 PM:
Program File
If TOD > 2000 then stop the HeatProg
If you do not name a program after STOP, the controller assumes you mean the
current program.

Technical 04-20006-02-en, March 2019


1750
60 Script Programming
60.59 WAIT

60.59 WAIT
Alias: Delay
WAIT makes a program's execution wait for a specified number of seconds and
then resume right after the WAIT command statement.

Syntax
WAIT number

Table: WAIT Parameter


Parameter Description

number Any expression that results in a number.


Interpreted as the number of seconds to
wait.

Products Supported
EcoStruxure BMS servers

Examples
Wait 5 'waits for 5 seconds
Wait (3) 'waits for 3 seconds
Delay 10 'waits for 10 seconds

Restrictions
You can only use the WAIT keyword in the following situations:
• At the EcoStruxure BMS server level
• In a Script program and not in a Script function

Tip
WAIT is not supported inside a For loop.

04-20006-02-en, March 2019 Technical


1751
60 Script Programming
60.60 WHILE

60.60 WHILE
WHILE carries out the instructions in the statements within the loop over and over
again as long as the given number is TRUE.

Syntax
While number
statement
statement
...
Endwhile

Table: WHILE Parameters


Parameter Description

statement Any complete instruction that tells the


program what to do next or what action to
take.

number Any number, expression, or variable whose


value determines if the WHILE loop is
executed. If the value is TRUE (non-zero) the
WHILE loop is executed. If the value is
FALSE (zero), the WHILE loop is not
executed. If the value is a variable, the value
can be changed inside the WHILE loop to
cause the loop to terminate.

Examples
Initialize a 10 element manual array:
Program File
Numeric Counter
Set Counterto 1
While Counter <= 10
ManualArray[Counter] = Counter*10
Counter = Counter + 1
Endwhile

Technical 04-20006-02-en, March 2019


1752
60 Script Programming
60.61 Qualifier Statements

60.61 Qualifier Statements


Qualifier statements assist in defining input, output, and public variables.

60.61.1 INPUT
INPUT is a binding qualifier that identifies a variable declaration as an input variable.
You can bind an input variable to an object property outside of the program. The
input variable takes on the same value as the property it is bound to. You cannot
set an input variable's value.
For more information, see section 60.62 “INPUT” on page 1754..

60.61.2 Buffered
Buffered is used exclusively as a qualifier for an input variable to indicate that the
variable can hold one or more buffered values. The type of input variable may be
Numeric, String, or DateTime.
For more information, see section 60.63 “Buffered” on page 1755.

60.61.3 OUTPUT
OUTPUT is a binding qualifier that identifies a variable declaration as an output
variable. You can bind an output variable to an object property outside of the
program. When the output variable is set, the bound property value will be set to the
same value.
For more information, see section 60.64 “OUTPUT” on page 1756..

60.61.4 PUBLIC
PUBLIC is a binding qualifier that identifies a variable as a public variable. You can
modify a public variable from outside a Script program, such as from a graphic.
For more information, see section 60.65 “PUBLIC” on page 1757..

04-20006-02-en, March 2019 Technical


1753
60 Script Programming
60.62 INPUT

60.62 INPUT
INPUT is a binding qualifier that identifies a variable declaration as an input variable.
You can bind an input variable to an object property outside of the program. The
input variable takes on the same value as the property it is bound to. You cannot
set an input variable's value.

Syntax
variable_declaration input namelist

Table: INPUT Parameters


Parameter Description

variable_declaration The keyword Numeric, String, or Datetime


which defines the type of input variable.

namelist The name of the input variable you are


defining, or a series of input variables
separated by commas.

Examples
Program File
If you have a program that controls a fan based on the value of a temperature input
point, you define an input variable to bind to the input's value property.
Numeric_input Temp_DegF
If Temp_DegF is greater than 75 then
Turn Fan On
Endif

Technical 04-20006-02-en, March 2019


1754
60 Script Programming
60.63 Buffered

60.63 Buffered
Buffered is used exclusively as a qualifier for an input variable to indicate that the
variable can hold one or more buffered values. The type of input variable may be
Numeric, String, or DateTime.

Note
The buffering of values is performed on a First-In, First-Out basis (that is, a
queue).

Syntax
type buffered input variable_name

Table: Buffered Parameters


Parameter Description

type The keyword Numeric, String, or DateTime


which defines the type of input variable.

variable_name The name of the input variable you are


defining, or a series of input variables
separated by a comma.

Example
You declare a buffered input variable (BIn1) and a pair of output variables in this
sample program. BIn1 has the same value every time it is used as expected.

Note
Buffered inputs are supported only in EcoStruxure BMS server programs. They
are not supported in functions, or on b3 BACnet, Infinet, or MP Series controllers.

Program File
Numeric Buffered Input BIn1
Numeric Buffered Input BIn2
Numeric Output Out1
Out1 = BIn1 + BIn2

04-20006-02-en, March 2019 Technical


1755
60 Script Programming
60.64 OUTPUT

60.64 OUTPUT
OUTPUT is a binding qualifier that identifies a variable declaration as an output
variable. You can bind an output variable to an object property outside of the
program. When the output variable is set, the bound property value will be set to the
same value.

Syntax
variable_declaration output namelist

Table: OUTPUT Parameters


Parameter Description

variable_declaration The keyword Numeric, String, or Datetime


which defines the type of output variable.

namelist The name of the output variable you are


defining, or a series of output variables
separated by commas.

Examples
Program File
If you have a program that controls a thermostat temperature, you define an output
variable to bind to the thermostat's temperature property.
Numeric output Thermostat_Temp_DegF
Thermostat_Temp_DegF = 72.5

Technical 04-20006-02-en, March 2019


1756
60 Script Programming
60.65 PUBLIC

60.65 PUBLIC
PUBLIC is a binding qualifier that identifies a variable as a public variable. You can
modify a public variable from outside a Script program, such as from a graphic.
Public behaves like an output variable, so you may bind the public variable to the
value of a point, or to the input variable of a Script program as you would with any
output variable. Unlike an output variable, you do not have to use the force
capability to modify Public from the Script property grid, or from a graphic.
You should use the Public binding qualifier when you need to directly modify that
variable from the Script property grid (that is, modify the value the Public binding
variable is bound to). Unlike an output variable, you can manually change the value
of the Public variable from a graphic. You can also use Public to monitor and control
user input values from the Script property grid or a graphic.
The advantage here is that you can use Public quickly without forcing the value or
having to edit and save the Script program. Public holds its value even after a Script
program save, power failure, warm start, cold start, or reboot from the Device
Administrator.

Syntax
variable_declaration public namelist

Table: PUBLIC Parameter


Parameter Description

variable_declaration The keywords Numeric, String, or Datetime


which defines the type of public variable.

namelist The name of the public variable you are


defining, or a series of output variables
separated by commas.

Examples
Program File
Assume you want to set an output in your Script program using the PUBLIC
variable.
Numeric public ReceivedValue
Numeric Output OutputValue
Set OutputValue to ReceivedValue

04-20006-02-en, March 2019 Technical


1757
60 Script Programming
60.66 Expressions

60.66 Expressions
Instructions that consist of mathematical operations are called expressions.
Expressions can also be item names or constants that return a numeric or string
result.

60.66.1 Numeric Expressions


Numeric expressions always result in a number. Numeric constants and variables
are expressions. Expressions can also be mathematical calculations that result in a
number or comparisons that produce a TRUE or FALSE response.
The following expressions are valid numeric expressions:
• 2
• SQRT (9)
• 900 DIVIDED BY 8
• WKD IS GREATER THAN MONDAY

60.66.2 String Expressions


String expressions are textual expressions that always result in a string of
characters enclosed in quotation marks. String constants and string variables are
also expressions. String expressions can be combinations that result in a string of
characters.
The following expressions are valid string expressions:
• “WARNING- HIGH TEMPERATURE”
• LEFT (“TEST”, 1)
• “THE NUMBER OF ERRORS IS”, TOTAL1

Technical 04-20006-02-en, March 2019


1758
60 Script Programming
60.67 Variables

60.67 Variables
A variable is a run-time (dynamically changing) property of an object.
Script supports program, system, and runtime variables.

60.67.1 Program Variables


Variables are names that represent numbers, words, or dates and times. Unlike a
constant, a variable has a value that changes or varies.
For more information, see section 60.69 “Program Variables” on page 1761..

60.67.2 System Variables


System variables are objects that the system sets and updates automatically.
System variables are controlled by the system and cannot be changed by the user.
For more information, see section 60.73 “System Variables” on page 1767.

60.67.3 System Variable Keywords


Values that change are represented by system variables. The controller
automatically updates the value of these variables.
For more information, see section 60.79 “System Variable Keywords” on page
1773.

60.67.4 Script Runtime Variables


Script runtime variables are read-only properties that display information about the
state of a program.
For more information, see section 60.74 “Script Runtime Variables” on page 1768.

04-20006-02-en, March 2019 Technical


1759
60 Script Programming
60.68 Declaring a Variable

60.68 Declaring a Variable


You declare local program variables at the beginning of the Script program or
function where the variables are used.
For more information, see section 60.70 “Local Program Variables” on page 1762.

To declare a variable
1. In Script Editor, declare the variable you want to use in the program or
function:
• Declare the variable using the type keyword Numeric, String, or DateTime
before the name of the variable.
• Declare the variable using the binding keyword Input, Output, or Public
after the type keyword, and before the name of the variable, to enable
bindings to the variable.
You have now declared the variables in your Script program or function. These
declarations are then followed by one or more program lines or instructions that
specify the operations to perform.

Technical 04-20006-02-en, March 2019


1760
60 Script Programming
60.69 Program Variables

60.69 Program Variables


Variables are names that represent numbers, words, or dates and times. Unlike a
constant, a variable has a value that changes or varies.

60.69.1 Local Program Variables


Local program variables are related to system variables. Unlike system variables,
which are known to all controllers in the system, local program variables are only
known to the program where they are defined. You define each local variable at the
beginning of the program where they are used. For example, you can bind a local
program variable to an EcoStruxure BMS server variable, an I/O point, or a local
program variable of another program in order to allow them to read or change
values in the system.
For more information, see section 60.70 “Local Program Variables” on page 1762.

60.69.2 Program Arrays


A Script array is a group of variables of the same size that shares a single name, but
is broken up into numbered cells, called elements.
For more information, see section 60.72 “Program Arrays” on page 1766.

60.69.3 Variables Pane Types


The types of variables displayed in the Variables Pane include Integer, Float,
Boolean, String, or DateTime, with Float as the Default value. Each of these types
are applicable to numeric variables only.

04-20006-02-en, March 2019 Technical


1761
60 Script Programming
60.70 Local Program Variables

60.70 Local Program Variables


Local program variables are related to system variables. Unlike system variables,
which are known to all controllers in the system, local program variables are only
known to the program where they are defined. You define each local variable at the
beginning of the program where they are used. For example, you can bind a local
program variable to an EcoStruxure BMS server variable, an I/O point, or a local
program variable of another program in order to allow them to read or change
values in the system.

Note
• Script supports characters at or below ASCII 127. Additional characters are
not supported and are replaced by a question mark (?).

60.70.1 Local Program Variable Declaration


There are two formats available for the Local Program Variable Declaration Line:
Type Local_Variable Name[array_index]
Type Binding_Qualifier Local_Variable Name
In each format, you can use one or more local variables.

Note
• The array index option is not supported for binding variables.

Examples
Numeric A
Datetime D
String S
Numeric Input A1
Numeric Input A2, A3, A4
Numeric Input A2, A3, A4
String Input S1
Datetime Input DT1
Numeric Output B1
String Output outstr1
Datetime Output outdt1
Numeric Fan_SP [20], Temp [20]
You can declare local variable types using the following keyword statements:
• Numeric
• String
• DateTime
• Function

Technical 04-20006-02-en, March 2019


1762
60 Script Programming
60.70 Local Program Variables

• WebService

Numeric keyword
The Numeric keyword assigns the name that follows as a local numeric variable:
Numeric RateOfRise

String Keyword
The String keyword assigns the name that follows as a local string variable:
String DirtyFilterMsg

DateTime Keyword
The DateTime keyword assigns the name that follows as a local variable that
accepts a date and time:
DateTime LocalDateTime

Function Keyword
The Function keyword assigns the name that follows as a local variable, which you
bind to a Script user-defined function.
Function MyFunction

WebService Keyword
The WebService keyword assigns the name that follows as a local variable, which
you bind to a Script Web Service object.
WebService wsCalculator

60.70.2 Local Program Variables and Bindings


To enable a local program variable to bind to the property of an object, you must
include an additional keyword to qualify your declaration. You use the binding
keyword Input, Output, or Public after the type, and before the name of the local
variable.
These binding keywords indicate either the inputs or outputs of the program, or the
public variables that use property bindings outside of the program:
• An Input variable indicates that the program uses the variable to read the
object property that variable is bound to. For this type, the program is not
allowed to set the value of the local variable because the variable is read-only.
• An Output variable indicates that the program uses the variable to set the
object property that variable is bound to.
• A Public variable indicates that the program makes the variable accessible to
other applications. You can then allow an application to bind its output variable
to that public variable.

Tip
The Input and Output qualifiers apply only to the Numeric, String, and DateTime
types.

04-20006-02-en, March 2019 Technical


1763
60 Script Programming
60.70 Local Program Variables

The type of the object property you bind a local variable to must match the type of
the local variable you plan to bind to. For example, you must bind a Numeric local
variable to object property types such as integer, double, float, digital, and
enumeration. Similarly, you must also bind strings to string type properties, and
datetimes to datetime properties.

Technical 04-20006-02-en, March 2019


1764
60 Script Programming
60.71 Variables Pane Types

60.71 Variables Pane Types


The types of variables displayed in the Local or Binding Variables panes include
Integer, Float, Boolean, String, or DateTime, with Float as the Default value. Integer,
Float or Boolean types apply to a numeric variable only.

Table: Types of Variables


Declared Variable Description

Numeric Float Use when binding to a


floating point property, such
as an Analog Value

Int Use when binding to an


integer property, such as a
Multistate Value

Bool Use when binding to a


Boolean (true or false)
property, such as a Digital
Value

String String Use when binding to a String


value.

DateTime DateTime Use when binding to a


DateTime value.

04-20006-02-en, March 2019 Technical


1765
60 Script Programming
60.72 Program Arrays

60.72 Program Arrays


A Script array is a group of variables of the same size that shares a single name, but
is broken up into numbered cells, called elements.
You refer to each element in the array using a number called an index.
For example, if we had an array with 8 elements called CLOCK, you can refer to its
eight possible values as CLOCK[1], CLOCK[2], CLOCK[3], CLOCK[4], and so on.

Table: Example of an Eight Element Array


Index Value

1 8.00

2 8.51

3 9.00

4 9.62

5 10.00

6 10.75

7 11.00

8 11.25

CLOCK[1] is 8.00, CLOCK[2] is 8.51, CLOCK[3] is 9.00, and so on. Each entry in an
array is referred to as an element. An array can contain up to 32,767 elements.
You can also put a numeric variable in place of the index number, such as
CLOCK[COUNT]. The variable is called an index variable.
When you define an array variable, you must specify a type (numeric, string, or
datetime) and the number of elements. The following statement defines (declares) a
local array called “Temperature” as numeric with 50 elements:
NUMERIC TEMPERATURE[50]

Technical 04-20006-02-en, March 2019


1766
60 Script Programming
60.73 System Variables

60.73 System Variables


System variables are objects that the system sets and updates automatically.
System variables are controlled by the system and cannot be changed by the user.
Continuum devices, such as a b3 (with unchanged firmware), are the only
exception. The Date and Hour system variables can be changed in a b3 device with
unchanged firmware. For more information, see section 60.79 “System Variable
Keywords” on page 1773.
The following table provides a complete list of the system variables for EcoStruxure
Building Operation software.

Table: System Variables


Name Description

Date Retrieves current system date and time so


that you can then store that date and time in
a variable.

DayofMonth Supplies the current day of the month from 1


to 31.

DayofYear Supplies the current day of the year between


1 and 366.

Hour Indicates the current hour, from 0 to 23.

HourofDay Indicates the time in decimal form from 0 to


23.99.

Minute Supplies the minute of the current hour, from


0 to 59.

Month Supplies the current month of the year, from


January to December.

Scan Indicates the controller’s last scan time in


seconds.

Second Supplies the number of seconds of the


current minute, from 0 to 59.

TimeofDay Supplies the time of day with the hour and


minute in the format HHMM where HH is a
number between 0 and 23 and MM is a
number between 0 and 59.

UTCOffset Specifies the current Universal Time


Coordinate (UTC) offset in seconds.

Weekday Supplies the current day of the week, from


SUNDAY through SATURDAY.

Year Supplies the current year.

04-20006-02-en, March 2019 Technical


1767
60 Script Programming
60.74 Script Runtime Variables

60.74 Script Runtime Variables


Script runtime variables are read-only properties that display information about the
state of a program.
Script uses four different runtime variables.

60.74.1 TS
TS is a Script program runtime property that contains the number of seconds (Time
in Seconds) that have elapsed since the program has been on the current line.
TS stands for Time in Seconds.
For more information, see section 60.75 “TS” on page 1769..

60.74.2 TM
TM is a Script program runtime property that contains the number of minutes (Time
in Minutes) that have elapsed since the program has been on the current line.
TM stands for Time in Minutes.
For more information, see section 60.76 “TM” on page 1770..

60.74.3 TH
TH is a Script program runtime property that contains the number of hours (Time in
Hours) that have elapsed since the program has been on the current line.
TH stands for Time in Hours.
For more information, see section 60.77 “TH” on page 1771..

60.74.4 TD
TD is a Script program runtime property that contains the number of days (Time in
Days) that have elapsed since the program has been on the current line.
TD stands for Time in Days.
For more information, see section 60.78 “TD” on page 1772..

Technical 04-20006-02-en, March 2019


1768
60 Script Programming
60.75 TS

60.75 TS
TS is a Script program runtime property that contains the number of seconds (Time
in Seconds) that have elapsed since the program has been on the current line.
TS stands for Time in Seconds.

Syntax
TS

Example
To allow for a 90-second valve stroke time, see if 90 seconds have elapsed since
you opened the valve.
Program File:

The controller measures 90 seconds starting the instant that the program is on the
line making the request for elapsed time.

04-20006-02-en, March 2019 Technical


1769
60 Script Programming
60.76 TM

60.76 TM
TM is a Script program runtime property that contains the number of minutes (Time
in Minutes) that have elapsed since the program has been on the current line.
TM stands for Time in Minutes.

Syntax
TM

Example
To have a 5-minute warmup of a fan before turning on the pump, you would check
to see if the fan has been running for 5 minutes after activation.
Program File:

The controller measures 5 minutes starting the instant that the program is on the
line making the request for elapsed time.

Technical 04-20006-02-en, March 2019


1770
60 Script Programming
60.77 TH

60.77 TH
TH is a Script program runtime property that contains the number of hours (Time in
Hours) that have elapsed since the program has been on the current line.
TH stands for Time in Hours.

Syntax
TH

Example
To have the lead fan run 1 hour then run the lag fan, you would check to see if the
fan has been running for 1 hour after activation.
Program File:

The controller measures 1 hour starting the instant that the program is on the line
making the request for elapsed time.

04-20006-02-en, March 2019 Technical


1771
60 Script Programming
60.78 TD

60.78 TD
TD is a Script program runtime property that contains the number of days (Time in
Days) that have elapsed since the program has been on the current line.
TD stands for Time in Days.

Syntax
TD

Example
In order to have a lead pump run for 3 days, then turn on the lag pump, you would
check to see if the pump has been running for 3 days after activation.
Program File:

The controller measures 3 days starting the instant that the program is on the line
making the request for elapsed time.

Technical 04-20006-02-en, March 2019


1772
60 Script Programming
60.79 System Variable Keywords

60.79 System Variable Keywords


Values that change are represented by system variables. The controller
automatically updates the value of these variables.
Script uses two different types of system-variable keywords: date and time and
runtime variable keywords.

60.79.1 Date and Time System Variables


Date and Time System variables represent changeable time of day and calendar
values.
Date and Time System variables include the following keywords:
• DATE
• DAYOFMONTH
• DAYOFYEAR
• HOD
• HOUR
• MINUTE
• MONTH
• SECOND
• TOD
• UTCOffset
• WEEKDAY
• YEAR
For more information, see section 60.80 “Date and Time System Variables ” on
page 1774..

60.79.2 Runtime System Variables


Runtime system variables are variables the controller maintains.
Runtime system variables include the following keywords:
• ERRORS
• FREEMEM
• SCAN
For more information, see section 60.93 “Runtime System Variables ” on page
1791..

04-20006-02-en, March 2019 Technical


1773
60 Script Programming
60.80 Date and Time System Variables

60.80 Date and Time System Variables


Date and Time System variables represent changeable time of day and calendar
values.
A datetime variable is a name that represents a date and time. Datetime constants,
variables, points, expressions, or functions can be compared to other datetime
items. You can retrieve the date and time from the STRTODATE function or from
the DATE system variable.

Tip
You can print out a datetime variable to see what date and time the variable
contains. However, the date and time that prints out is a predefined format you
cannot change. The date and time prints in this format (in the 24-hour clock):
MONTH DD YYYY hh:mm:ss

60.80.1 DATE
DATE retrieves the current system date and time so that you can then store them in
a variable.
The value for DATE is always the current date.
DATE is designed to be used with DIFFTIME, along with a datetime variable (defined
using the DATETIME statement).
For more information, see section 60.81 “DATE” on page 1777..

60.80.2 DAYOFMONTH
DAYOFMONTH gives the day of month from 1 to 31.
You cannot change the DAYOFMONTH. The EcoStruxure BMS server
automatically updates this value.
For more information, see section 60.82 “DAYOFMONTH” on page 1778..

60.80.3 DAYOFYEAR
DAYOFYEAR gives the number of the day of the year, between 1 and 366.
You cannot change the DAYOFYEAR. The EcoStruxure BMS server automatically
updates this value
For more information, see section 60.83 “DAYOFYEAR” on page 1779..

60.80.4 HOD
HOD gives the time in a decimal form from 0.0 to 23.99.
You cannot change the HOD. The system automatically updates this value.

Technical 04-20006-02-en, March 2019


1774
60 Script Programming
60.80 Date and Time System Variables

For more information, see section 60.84 “HOD” on page 1780..

60.80.5 HOUR
HOUR gives the current hour, from 0 to 23.
If the time is 5:23:02, the hour is 5.
The system automatically updates the HOUR variable.
For more information, see section 60.85 “HOUR” on page 1781..

60.80.6 MINUTE
MINUTE gives the exact minute of the current hour, from 0 to 59.
The minute is the minute on the controller clock, so if the time is 5:23:02, the minute
is 23.
You cannot change the MINUTE. The EcoStruxure BMS server automatically
updates this value.
For more information, see section 60.86 “MINUTE” on page 1782...

60.80.7 MONTH
MONTH gives you the current month of year, from January to December.
You cannot change the MONTH. The EcoStruxure BMS server automatically
updates this value.
For more information, see section 60.87 “MONTH” on page 1783...

60.80.8 SECOND
SECOND gives the exact number of seconds of the current minute, from 0 to 59.
The number of seconds is as indicated by the EcoStruxure BMS server clock. If the
time is 10:02:12, then SECOND equals 12.
For more information, see section 60.88 “SECOND” on page 1785..

60.80.9 TOD
TOD gives the time of the day from 0 (midnight) to 2359, where 2359 is the
equivalent of 23:59 on the 24-hour clock.
The time of day is the time from the controller clock. You cannot change TOD since
the controller automatically updates that setting.
For more information, see section 60.89 “TOD” on page 1786..

04-20006-02-en, March 2019 Technical


1775
60 Script Programming
60.80 Date and Time System Variables

60.80.10 UTCOffset
UTCOffset specifies the current Universal Time Coordinate (UTC) offset in seconds.
It represents the difference in seconds between your local time and Greenwich
Mean Time (GMT) as follows:
• 18000 indicates you are 18000 seconds, or 300 minutes, or 5 hours ahead of
GMT.
• -18000 indicates you are 18000 seconds, or 300 minutes or 5 hours behind
GMT.
For more information, see section 60.90 “UTCOffset” on page 1787.

60.80.11 WEEKDAY
WEEKDAY gives current day of week, from SUNDAY through SATURDAY.
When printed, the weekday is spelled out as Sunday, Monday, Tuesday,
Wednesday, and so on through Saturday.
For more information, see section 60.91 “WEEKDAY” on page 1788..

60.80.12 YEAR
YEAR gives the current year. You cannot change the YEAR. The system
automatically updates the value.
When printed, the four-digit year is given.
For more information, see section 60.92 “YEAR” on page 1790...

Technical 04-20006-02-en, March 2019


1776
60 Script Programming
60.81 DATE

60.81 DATE
Alias: TIME
DATE retrieves the current system date and time so that you can then store them in
a variable.
The value for DATE is always the current date.
DATE is designed to be used with DIFFTIME, along with a datetime variable (defined
using the DATETIME statement).

Syntax
Date

Example
Once you have defined the datetime variable called TEMP_DATE using the
DATETIME statement, you can then set the value of that variable using the DATE
system variable, as follows:
Program file
Datetime Temp_Date
Temp_Date = Date
This way, TEMP_DATE retrieves the exact system date and time at a given
moment.
You can, for example, record the date and time that a point changes. You can use
the variable you have created in subsequent calculations.

04-20006-02-en, March 2019 Technical


1777
60 Script Programming
60.82 DAYOFMONTH

60.82 DAYOFMONTH
Alias: DOM
DAYOFMONTH gives the day of month from 1 to 31.
You cannot change the DAYOFMONTH. The EcoStruxure BMS server
automatically updates this value.

Syntax
DayOfMonth

Example
Example 1
To print out a headline that contains the date, you would use DAYOFMONTH, as
shown below:
Program File
Print "The kwh history for", MONTH, DayofMonth, "," , YEAR
The resulting header would print the actual month, day of the month, and year, like
this:
The kwh History for October 15, 2008
Example 2
To make some events occur only on particular days of each month, you could set
up an IF..THEN statement that would check for the day of the month:
Program File
If DayofMonth is between 7 and 14 then…

Technical 04-20006-02-en, March 2019


1778
60 Script Programming
60.83 DAYOFYEAR

60.83 DAYOFYEAR
Alias: DOY
DAYOFYEAR gives the number of the day of the year, between 1 and 366.
You cannot change the DAYOFYEAR. The EcoStruxure BMS server automatically
updates this value

Syntax
DayOfYear

Example
Suppose on a certain date, you need to switch off the heating and switch on
cooling. You would use DAYOFYEAR to instruct the controller:
Program File
If DayofYear is 152 then
Stop the Heating_Prog
Run the Cooling_prog
Endif

04-20006-02-en, March 2019 Technical


1779
60 Script Programming
60.84 HOD

60.84 HOD
Alias: HOUROFDAY
HOD gives the time in a decimal form from 0.0 to 23.99.
You cannot change the HOD. The system automatically updates this value.

Syntax
HOD

Example
Example 1
You can use the decimal form of the time to see if the time is past 5:30 a.m.:
Program File
If HOD is greater than 5.50 then...
Example 2
A simple way to calculate the StartTime based on OutsideAir could use HOD as
follows:
Program File
If OutsideAir > 70 then Goto CoolStart
Set StartTime = (8.00 - (70-OutsideAir) * RateOfRise)
If HOD = StartTime then Goto StartBldg

Technical 04-20006-02-en, March 2019


1780
60 Script Programming
60.85 HOUR

60.85 HOUR
Alias : HR
HOUR gives the current hour, from 0 to 23.
If the time is 5:23:02, the hour is 5.
The system automatically updates the HOUR variable.

Syntax
Hour

Example
To take action every day at 5:00 a.m., you would check the hour with the following
statement:
Program File
If Hour is equal to 5 then Goto Startup

04-20006-02-en, March 2019 Technical


1781
60 Script Programming
60.86 MINUTE

60.86 MINUTE
Alias: MIN
MINUTE gives the exact minute of the current hour, from 0 to 59.
The minute is the minute on the controller clock, so if the time is 5:23:02, the minute
is 23.
You cannot change the MINUTE. The EcoStruxure BMS server automatically
updates this value.

Syntax
Minute

Example
Suppose you have eight programs to run every hour. To avoid customizing scan
time by running all the programs at once, you could run two programs in each
quarter of any hour:
Program File
If Minute equals 15 then
Run the System_Check
Run the Power_Usage
Endif
If Minute equals 30 then
Run the Temp_Check
Run the Temp_Rept
Endif
If Minute equals 45 then
Run the Fan_Check
Run the Damper_Check
Endif
If Minute equals 0 then
Run the Heater_Check
Run the CO_Check
Endif
The SYSTEM_CHECK and POWER_USAGE programs now run at 15 minutes after
the hour every hour of every day, 24 hours a day and 365 days a year.
The TEMP_CHECK and TEMP_REPT programs now run at 30 minutes after the
hour every hour of every day, 24 hours a day and 365 days a year.
The FAN_CHECK and DAMPER_CHECK programs now run at 45 minutes after the
hour every hour of every day, 24 hours a day and 365 days a year.
The HEATER_CHECK and CO_CHECK programs now run on the hour every hour
of every day, 24 hours a day and 365 days a year.

Technical 04-20006-02-en, March 2019


1782
60 Script Programming
60.87 MONTH

60.87 MONTH
Alias: MTH
MONTH gives you the current month of year, from January to December.
You cannot change the MONTH. The EcoStruxure BMS server automatically
updates this value.
When printed, the month is spelled out as January, February, March, and so on
through December. You can also compare the MONTH to:
• The numbers (1 through 12).
• The abbreviated three-letter names (first three letters).
All values for MONTH are listed below:

Table: MONTH Values


Constant Short Name Long Name

1 JAN JANUARY

2 FEB FEBRUARY

3 MAR MARCH

4 APR APRIL

5 MAY MAY

6 JUN JUNE

7 JUL JULY

8 AUG AUGUST

9 SEP SEPTEMBER

10 OCT OCTOBER

11 NOV NOVEMBER

12 DEC DECEMBER

Syntax
Month

Example
Example 1
You can use the spelled out (long) names for printing or for comparing to an actual
month:
Program File
If Month is December then print Month
Output

04-20006-02-en, March 2019 Technical


1783
60 Script Programming
60.87 MONTH

Saturday
Example 2
You can use the short names for comparing the month:
Program File
If Month is either JUN, JUL, AUG or SEP then…
Example 3
You can use the constants 1 through 12 for comparing the month:
Program File
If Month is 2 then…

Technical 04-20006-02-en, March 2019


1784
60 Script Programming
60.88 SECOND

60.88 SECOND
Alias: SEC
SECOND gives the exact number of seconds of the current minute, from 0 to 59.
The number of seconds is as indicated by the EcoStruxure BMS server clock. If the
time is 10:02:12, then SECOND equals 12.

Syntax
Second

Example
If you want to take action every time 50 seconds of the minute have gone by, you
enter the following program statement:
Program File
If Second is greater than 50 then…

04-20006-02-en, March 2019 Technical


1785
60 Script Programming
60.89 TOD

60.89 TOD
Alias: TIMEOFDAY
TOD gives the time of the day from 0 (midnight) to 2359, where 2359 is the
equivalent of 23:59 on the 24-hour clock.
The time of day is the time from the controller clock. You cannot change TOD since
the controller automatically updates that setting.

Syntax
TOD

Example
Example 1
To check to see if the time of day is past 5:00 AM, you enter the following program
line:
Program File
If TOD is greater than 500 then…
Example 2
When you print out TOD, as in the following example, you always receive the 24-
hour time:
Print TOD
The time displays as follows:
20.000 (that means 8:00:00 PM)

Technical 04-20006-02-en, March 2019


1786
60 Script Programming
60.90 UTCOffset

60.90 UTCOffset
Alias: none
UTCOffset specifies the current Universal Time Coordinate (UTC) offset in seconds.
It represents the difference in seconds between your local time and Greenwich
Mean Time (GMT) as follows:
• 18000 indicates you are 18000 seconds, or 300 minutes, or 5 hours ahead of
GMT.
• -18000 indicates you are 18000 seconds, or 300 minutes or 5 hours behind
GMT.

Syntax
UTCOffset

Example
To adjust the local date by the UTC offset of the local server, you enter the
following:
Program File
Datetime Output MyDate
MyDate = Date + UTCOffset

04-20006-02-en, March 2019 Technical


1787
60 Script Programming
60.91 WEEKDAY

60.91 WEEKDAY
Alias: WKD
WEEKDAY gives current day of week, from SUNDAY through SATURDAY.
When printed, the weekday is spelled out as Sunday, Monday, Tuesday,
Wednesday, and so on through Saturday.
You can also compare the WEEKDAY to:
• The numbers 1 through 7 (1 equal to Sunday).
• The abbreviated three-letter names (first three letters).

Note
• If you use both Script and Function Block programming, for example, when
using control sequences, be aware of the following. Script uses Sunday as
the first day of the week and assigns a value of 1 to that day, while Function
Block uses Monday as the first day of the week and assigns Monday a value
of 1.

All values for the weekday are as follows:

Table: WEEKDAY Values


Constant Short Name Long Name

1 SUN SUNDAY

2 MON MONDAY

3 TUE TUESDAY

4 WED WEDNESDAY

5 THU THURSDAY

6 FRI FRIDAY

7 SAT SATURDAY

Syntax
Weekday

Example
Example 1
You can spell out names for printing or for comparing to an actual day:
Program File
If Weekday is Saturday then Print Weekday
Output
Saturday
Example 2

Technical 04-20006-02-en, March 2019


1788
60 Script Programming
60.91 WEEKDAY

You can use the short name or the constants 1 through 7 for comparing the
weekday in an IF statement:
Program File
If Weekday > Sun OR Weekday < 7 then…

04-20006-02-en, March 2019 Technical


1789
60 Script Programming
60.92 YEAR

60.92 YEAR
Alias: YR
YEAR gives the current year. You cannot change the YEAR. The system
automatically updates the value.
When printed, the four-digit year is given.

Syntax
Year

Example
To take an action in the distant future, such as sending a reminder message to
check certain pieces of equipment, you use the YEAR system variable to test the
year:
Program File
If year is 2010 THEN PRINT "Welcome to the year Two Thousand and
Ten."

Technical 04-20006-02-en, March 2019


1790
60 Script Programming
60.93 Runtime System Variables

60.93 Runtime System Variables


Runtime system variables are variables the controller maintains.

60.93.1 ERRORS
ERRORS, a variable the controller maintains, indicates the number of system errors
pending. The number increments (increases by one) each time a new error occurs
and is cleared when manually reset to zero (0).
For more information, see section 60.94 “ERRORS” on page 1792..

60.93.2 FREEMEM
FREEMEM contains the number of bytes of free memory in the largest single
contiguous memory block on a controller.
For more information, see section 60.95 “FREEMEM” on page 1793..

60.93.3 SCAN
SCAN indicates the length in seconds of the last interpreter scan interval, which the
program updates regularly.
For more information, see section 60.96 “SCAN” on page 1794..

04-20006-02-en, March 2019 Technical


1791
60 Script Programming
60.94 ERRORS

60.94 ERRORS
ERRORS, a variable the controller maintains, indicates the number of system errors
pending. The number increments (increases by one) each time a new error occurs
and is cleared when manually reset to zero (0).
The controller automatically updates ERRORS. You can only reset the controller to
zero.
The controller increments ERRORS when any of the following occurs:
• A Script program error disables a program (which also sets the program
ERROR attribute).
• The controller’s input reference voltage goes out of its normal range, usually
when you apply too much voltage to one or more inputs.
• The controller’s output reference voltage goes out of its normal range, usually
when drawing too much current from one or more inputs.
• The EcoStruxure BMS server has trouble transmitting or receiving data.
• Someone resets a controller.
• Someone turns off the AC power to a controller so that the AC power shuts
down, but the battery retains memory.

Syntax
Errors

Example
Since the ERRORS variable automatically decrements after you acknowledge an
error, the value of the variable should never get very large.
In the sample program below, you set a limit to how many errors can accumulate
and generate a report on all errors if the limit is exceeded:
Program File
If Errors > 10 then
Goto Report_Error

Technical 04-20006-02-en, March 2019


1792
60 Script Programming
60.95 FREEMEM

60.95 FREEMEM
FREEMEM contains the number of bytes of free memory in the largest single
contiguous memory block on a controller.
For system managers only. Primarily designed to be used on the command line
only, not in programs, because the value of FREEMEM does not change
dynamically. Primarily, FREEMEM is used in the programs to slow the controller
scan.

Syntax
Freemem

Example
If you want to know the size of the largest block of free memory available on a
controller, enter the following:
Program File
Print Freemem

04-20006-02-en, March 2019 Technical


1793
60 Script Programming
60.96 SCAN

60.96 SCAN
Alias: SC
SCAN indicates the length in seconds of the last interpreter scan interval, which the
program updates regularly.

Syntax
Scan

Example
To find the average number of seconds per scan, you would run the following
program once every scan after all other programs have been run.
Program File
Numeric Tot_Scan_SCS, Scan_Count, Scan_Avg
Set Tot_Scan_SCS, Scan_Count, Scan_Avg = 0
Line Totaling
Tot_Scan_SCS = Tot_Scan_SCS + Scan
Scan_Count = Scan_Count + 1
If TOD = 2359 then
Scan_Avg = Tot_Scan_SCS/Scan_Count
Print "The average scan for", WKD " is", Scan_Avg, "sec"
Set Scan_Avg = 0
Set Scan_Count = 0
Set Tot_ScSCS = 0
Endif
For each scan the program adds the seconds that scan took to the total seconds
for the day. Also for each scan, the program adds 1 to the scan counter.
At the end of the day (2359, or 11:59 PM), the program divides the scan total by the
number of scans to get the average length of the scans that day. The program then
prints the average for the day.
The numeric variables used to calculate the average number of scans per day are all
set to zero at the end of each day, so that they start at zero the next day.

Technical 04-20006-02-en, March 2019


1794
60 Script Programming
60.97 Script Functions

60.97 Script Functions


A function is a routine designed to carry out an often repeated task or series of
tasks. Your Script function then becomes a subroutine that can be called whenever
that particular action needs to be performed.
When a function is used to calculate or provide a value, the function “returns” the
value to the program that calls the function. A program can also provide (“pass”) the
function some values (called “arguments”) to use in calculations or actions the
program must take. Arguments (separated by commas) are included in parentheses
following the function name. Function calls require parentheses, so you should
include the parentheses even if the function is empty (that is, function ()).

Note
Script functions support up to 15 arguments.

60.97.1 Script Function Workflow


In Script, you must declare a local variable of type Function and bind it to a Script
function object within the same EcoStruxure BMS server or field device.
For more information, see section 60.98 “Script Function Workflow” on page 1796.

60.97.2 Script Functions and Programs


You create a function just like you create a program, using standard Script
keywords, and then save that function to a file.
Functions perform specific tasks or calculations that return a resulting value. They
are simple and flexible and can make programs run in a much more efficient manner
by eliminating redundant tasks.
For more information, see section 60.102 “Script Functions and Programs” on page
1801.

60.97.3 System Functions


System functions carry out a particular set of calculations or actions and can return
one or more specific values, such as Sum, Sqrt, Length, and Avg.
For more information, see section 60.108 “System Functions” on page 1808.

04-20006-02-en, March 2019 Technical


1795
60 Script Programming
60.98 Script Function Workflow

60.98 Script Function Workflow


In Script, you must declare a local variable of type Function and bind it to a Script
function object within the same EcoStruxure BMS server or field device.
You do this as follows:
• Write a Script program and in that program, declare a local variable of the type,
Function. For more information, see section 60.104 “Declaring and Calling a
Script Function” on page 1804.
• Bind the local variable to the Script Function object.
For more information, see section 46.10 “Binding Values Using a Binding
Template” on page 1246.
For more information, see section 59.15 “Binding Values in Script Editor Using
a Binding Template” on page 1629.
• Use the name of that local variable to activate the function
You do so by using the Function keyword, thus enabling the program to refer to or
call the function, through its binding. This is similar to the way in which the program
calls a system function.

Tip
You can use the RETURN statement to return a value to the calling program or
function.

There are several different types of Script functions, including:


• Functions without arguments
• Functions with arguments
• Functions that return a value

60.98.1 Script Functions without Arguments


A function need not have arguments.
For more information, see section 60.99 “Script Functions without Arguments” on
page 1798.

60.98.2 Script Functions with Arguments


Functions can have valid Script expressions for arguments, including local variables
from the calling program, or function.
For more information, see section 60.100 “Script Functions with Arguments” on
page 1799.

60.98.3 Script Functions that Return a Value


In addition to returning to the calling program, RETURN can also bring back the
results of a calculation. These results are: a variable, a constant, or an expression.

Technical 04-20006-02-en, March 2019


1796
60 Script Programming
60.98 Script Function Workflow

For more information, see section 60.101 “Script Functions that Return a Value” on
page 1800.

04-20006-02-en, March 2019 Technical


1797
60 Script Programming
60.99 Script Functions without Arguments

60.99 Script Functions without Arguments


A function need not have arguments. For example, you can define a function that
stops all fans and name that function FANSTOP.
Numeric Output Fan1, Fan2, Fan3, Fan4
Stop Fan1, Fan2, Fan3, AND Fan4
Return
Calling Program:
Function Fanstop
If TOD > 1800 and TOD < 800 then FanStop ( )
FANSTOP knows about the fans because they are points on the controller.

Technical 04-20006-02-en, March 2019


1798
60 Script Programming
60.100 Script Functions with Arguments

60.100 Script Functions with Arguments


Functions can have valid Script expressions for arguments, including local variables
from the calling program, or function.
The following example shows a function that starts and stops two programs.
ARG 1 Program1
ARG 2 Program2
Start Program1
Start Program2
Return
The calling program can send any two arguments to this function that can be acted
on by START or STOP. You can start and stop any object (piece of equipment) or
program.

04-20006-02-en, March 2019 Technical


1799
60 Script Programming
60.101 Script Functions that Return a Value

60.101 Script Functions that Return a Value


In addition to returning to the calling program, RETURN can also bring back the
results of a calculation. These results are: a variable, a constant, or an expression.
The following example shows a function that returns a value. In this case, the
RETURN statement contains an expression. The function returns the value of that
expression to the program.
ARG 1 Tmp1
ARG 2 Tmp2
ARG 3 Tmp3
ARG 4 Tmp4
Numeric Total_Change
Total_Change = (Tmp1 - Tmp2) + (Tmp2 - Tmp3) + (Tmp3 - Tmp4)
Return (Total_Change/3)
As shown below, you could also give the expression a local variable name.
ARG 1 Tmp1
ARG 2 Tmp2
ARG 3 Tmp3
ARG 4 Tmp4
Numeric Total_Change, Mid_Change
Total_Change = (Tmp1 - Tmp2) + (Tmp2 - Tmp3) + (Tmp3 - Tmp4)
Mid_Change = Total_Change/3
Return Mid_Change

Note
• Use a variable instead of an expression in the RETURN statement because
the name of the variable, when created, should generally describes its
purpose.

Technical 04-20006-02-en, March 2019


1800
60 Script Programming
60.102 Script Functions and Programs

60.102 Script Functions and Programs


You create a function just like you create a program, using standard Script
keywords, and then save that function to a file.
Functions perform specific tasks or calculations that return a resulting value. They
are simple and flexible and can make programs run in a much more efficient manner
by eliminating redundant tasks.
If your system performs complex calculations or processes repeatedly, you can
avoid retyping these programs every time you need them by making them
functions. You can think of these functions as tools you use to build larger
programs. To determine whether you need a function, look at the kinds of actions
you repeat. For example, suppose you repeatedly test for occupancy. You can
create a function that performs the task, then call that function whenever necessary.
An example of a function is a PID loop. Some PID loops can be very large and
contain cumbersome portions of programming code. Rather than clutter up a
program with the PID code, you can create a function that contains all of the PID
code. When you need to use the PID loop, you call the PID function. As a result, the
main program is much smaller and easier to understand.
You call functions in a Script program or function by declaring a function at the
beginning of the program or function in which you would like to use that function. A
function variable is a name that represents a Script function. Any function call using
the local variable name means a call to the actual function. For more information,
see section 60.103 “Function Declarations and Statements” on page 1802.
Be sure that any local variable of type Function declared in a program or function is
bound to an actual function object. If the local variable is declared, but not properly
bound, that program does not run.

60.102.1 Function Declarations and Statements


Unlike Script programs, Script functions do not support the concept of lines as
execution units. Instead, Script functions consist of declarations and statements.
For more information, see section 60.103 “Function Declarations and Statements”
on page 1802.

04-20006-02-en, March 2019 Technical


1801
60 Script Programming
60.103 Function Declarations and Statements

60.103 Function Declarations and Statements


Unlike Script programs, Script functions do not support the concept of lines as
execution units. Instead, Script functions consist of declarations and statements.
Declarations specify the arguments that the function takes, followed by the local
variables. Statements specify the actions the function must perform and must be
executed together. Typically, the function returns a value to the calling program.
Argument declarations begin with the ARG keyword. For example, the following
basic Script function, called myaverage, adds 3 variables and then determines their
average.
The optional comment preceded by the single quotation mark (') helps explain the
operation and purpose of the function. You can place comments either at the
beginning or end of the declaration or function as you wish.

Figure: Function Example


Once you finish creating the function, you then add a declaration (1) and a function
call (2) in the designated program to invoke that function.

Technical 04-20006-02-en, March 2019


1802
60 Script Programming
60.103 Function Declarations and Statements

Figure: Function Declaration and Call

04-20006-02-en, March 2019 Technical


1803
60 Script Programming
60.104 Declaring and Calling a Script Function

60.104 Declaring and Calling a Script Function


You can declare and call a Script function in a Script program or another Script
function. For example, you include a function as a subroutine and access it
repeatedly in the same program or any other program.
For more information, see section 60.103 “Function Declarations and Statements”
on page 1802.

To declare and call a Script function


1. In Script Editor, declare the function you want to call by using the keyword
Function before the name of the function.
2. Add the function call.
You have now declared and called a function in a Script program or another Script
function.

Technical 04-20006-02-en, March 2019


1804
60 Script Programming
60.105 Creating a Script Function

60.105 Creating a Script Function


You create Script functions so that you can program code that can be used in one
or several Script programs or functions.
For more information, see section 60.102 “Script Functions and Programs” on page
1801.

To create a Script function


1. In WorkStation, in the System Tree pane, select the EcoStruxure BMS
server or folder where you want to create the Script function.
2. On the File menu, point to New and then click Program.
3. In the Create Object wizard, in the object type list, select Script Function.
4. In the Name box, type a name for the Script function.
5. In the Description box, type a description for the Script function.
6. Click Create.

04-20006-02-en, March 2019 Technical


1805
60 Script Programming
60.106 Declaring a Script Function Argument

60.106 Declaring a Script Function Argument


You declare arguments at the beginning of the Script function where they are used.
The argument values are provided by the calling Script program or function.
For more information, see section 60.103 “Function Declarations and Statements”
on page 1802.

To declare a Script function argument


1. In Script Editor, declare the Script function arguments using the ARG
keyword.
You have now declared the arguments in the Script function. You can now add one
or more instructions that specify the operations to perform.

Technical 04-20006-02-en, March 2019


1806
60 Script Programming
60.107 Checking and Saving a Script Function

60.107 Checking and Saving a Script Function


You check your Script function to ensure there are no syntax errors. You perform a
save operation to check and then save your Script function.
For more information, see section 60.102 “Script Functions and Programs” on page
1801.

To check and save a Script function


1. In Script Editor, click Check.
2. In the Check pane, double-click on an error message to go to the line of code
that contains the error.

3. Click Save to check and save your Script function.


You have now checked and saved your Script function.
The Script Editor displays the Save Successful message, even if the function
contains errors and does not compile successfully.
If you save a function that contains errors, that function will not run. The function
must have a successful check prior to running.

04-20006-02-en, March 2019 Technical


1807
60 Script Programming
60.108 System Functions

60.108 System Functions


System functions carry out a particular set of calculations or actions and can return
one or more specific values, such as Sum, Sqrt, Length, and Avg.
For example, the system function SQRT returns the square root of a given number:
Result = SQRT (25)
The number on which the function operates (25) is included within the parentheses.
This function returns the value 5.

60.108.1 System Function Keywords


Script uses the following types of system function keywords:
• Buffered variable functions
• Conversion functions
• Mathematical functions
• Object functions
• Passed function
• Rounding functions
• Statistical functions
• String functions
• Time functions
• Trigonometric functions
For more information, see section 60.109 “System Function Keywords” on page
1809.

Technical 04-20006-02-en, March 2019


1808
60 Script Programming
60.109 System Function Keywords

60.109 System Function Keywords


System functions carry out a particular set of calculations or actions and can return
one or more specific values, such as Sum, Sqrt, Length, and Avg.
Script uses the following types of system function keywords:
• Buffered variable functions
• Conversion functions
• Mathematical functions
• Object functions
• Passed function
• Rounding functions
• Statistical functions
• String functions
• Time functions
• Trigonometric functions

60.109.1 Buffered Variable Functions


Buffered variable functions perform input variable-related operations.
For more information, see section 60.110 “Buffered Variable Functions” on page
1813.

60.109.2 Conversion Functions


Conversion functions convert numeric or string variables.
Conversion functions include the following keywords:
• NUMTOSTR
• STRTODATE
• STRTONUM
For more information, see section 60.113 “Conversion Functions” on page 1817...

60.109.3 Mathematical Functions


Mathematical functions perform mathematical operations.
Mathematical functions include the following keywords:
• ABS
• EXPONENTIAL
• FACTORIAL
• LN

04-20006-02-en, March 2019 Technical


1809
60 Script Programming
60.109 System Function Keywords

• LOG
• RANDOM
• SQRT
• SUM
For more information, see section 60.117 “Mathematical Functions” on page
1822...

60.109.4 Object Functions


Object functions perform operations on mathematical objects.
Object functions include the following keywords:
• ReadProperty
• Relinquish
• WriteProperty
For more information, see section 60.126 “Object Functions” on page 1833...

60.109.5 PASSED Function


The PASSED function keyword indicates whether or not the argument with the
arg_number has been passed into the current function. Returns TRUE (numeric 1) if
the argument is actually passed and FALSE (numeric 0) if not.
For more information, see section 60.130 “PASSED Function” on page 1838..

60.109.6 Rounding Functions


Rounding functions round numbers to the next integer and then return values.
Rounding functions include the following keywords:
• CEILING
• FLOOR
• ROUND
• TRUNCATE
For more information, see section 60.131 “Rounding Functions” on page 1839...

60.109.7 Statistical Functions


Statistical functions perform statistical operations.
Statistical functions include the following keywords:
• AVERAGE
• MAXIMUM
• MAXITEM

Technical 04-20006-02-en, March 2019


1810
60 Script Programming
60.109 System Function Keywords

• MINIMUM
• MINITEM
• StandardDeviation
For more information, see section 60.136 “Statistical Functions” on page 1844...

60.109.8 String Functions


String functions perform string-related operations.
String functions include the following keywords:
• ASC
• CHR
• LEFT
• LENGTH
• MID
• RIGHT
• SEARCH
• STRINGFILL
• TAB
For more information, see section 60.143 “String Functions” on page 1857...

60.109.9 Time Functions


Time functions perform time-related operations.
Time functions include the following keywords:
• DIFFTIME
• TIMEPIECE
For more information, see section 60.154 “Time Functions” on page 1870.. .

60.109.10 Trigonomentric Functions


Trigonometric functions return arccosine, arctangents, and arcsines of given
numbers.
Trigonometric functions include the following keywords:
• ACOS
• ASIN
• ATAN
• ATAN2
• COS
• SIN

04-20006-02-en, March 2019 Technical


1811
60 Script Programming
60.109 System Function Keywords

• TAN
For more information, see section 60.157 “Trigonometric Functions” on page
1874.. .

Technical 04-20006-02-en, March 2019


1812
60 Script Programming
60.110 Buffered Variable Functions

60.110 Buffered Variable Functions


Buffered variable functions perform input variable-related operations.

60.110.1 GetBufferSize
GetBufferSize returns the current buffer size (that is, the number of buffered values)
of a passed buffered input variable.
For more information, see section 60.111 “GetBufferSize” on page 1814.

60.110.2 GetBufferedValue
GetBufferedValue gets the next available value of the passed buffered input
variable. This function returns Success or Failure.
For more information, see section 60.112 “GetBufferedValue” on page 1816.

04-20006-02-en, March 2019 Technical


1813
60 Script Programming
60.111 GetBufferSize

60.111 GetBufferSize
GetBufferSize returns the current buffer size (that is, the number of buffered values)
of a passed buffered input variable.
GetBufferSize is not supported in the MP Series controller.

Note
A returned value of 0 indicates that the passed argument is not a buffered input
variable, or that there is no buffered input variable value. If two or more arguments
are passed, the program goes to Line E if one exists. When the program goes to
Line E, it indicates that an error has occurred.

Syntax
GetBufferSize (variable_name)

Table: GetBufferSize Parameter


Parameter Description

variable_name The name of the passed input variable


whose buffer size you are querying.

Example
You can use the following program to check the buffer size and if the number of
items in the buffer exceeds 15, empty the buffer.
Program File

Technical 04-20006-02-en, March 2019


1814
60 Script Programming
60.111 GetBufferSize

Note
This program, [Link], is included in the Sample Import Files
folder in the Code Library. For more information, see section 61.24 “Working with
Code Library Sample Import Files” on page 1919.

04-20006-02-en, March 2019 Technical


1815
60 Script Programming
60.112 GetBufferedValue

60.112 GetBufferedValue
GetBufferedValue gets the next available value of the passed buffered input
variable. This function returns Success or Failure.
GetBufferValue is not supported in the MP Series controller.

Note
If the returned value is zero, it is not a buffered input variable. If two or more
arguments are passed, the program is disabled or goes to Line E if one exists.
When the program goes to Line E, it indicates an error has occurred.

Syntax
GetBufferedValue (variable_name)

Table: GetBufferedValue Parameter


Parameter Description

variable_name The name of the passed input variable


whose next available value you wish to
determine.

Example
You declare two buffered input variables (BIn1 and BIn2) and two output variables in
this example. BIn1 has the same value every time it is used as expected until a call
is made to the function GetBufferedValue to obtain the next buffered value. This
example checks to see if there are any buffered values for BIn1 by calling the
GetBufferSize function and making sure that the number of buffered values is
greater than zero. Then, it gets the next available value from the buffer. BIn1
assumes that newly-obtained value.
Program File
Numeric Buffered Input BIn1
Numeric Buffered Input BIn2
Numeric Output Out1
Numeric Output Out2
Out1 = BIn1 + BIn1
Out2 = 0
While GetBufferSize (BIn2) > 0
if GetBufferedValue (BIn2) = Success then
Out2 = Out2 + Bin2 'add all buffered values
Endif
EndWhile

Technical 04-20006-02-en, March 2019


1816
60 Script Programming
60.113 Conversion Functions

60.113 Conversion Functions


Conversion functions convert numeric or string variables.

60.113.1 NUMTOSTR
NUMTOSTR converts a number in a numeric variable or other numeric form to a
string variable so the number can be used in string operations. NUMTOSTR returns
the converted string value.
For more information, see section 60.114 “NUMTOSTR” on page 1818...

60.113.2 STRTODATE
STRTODATE returns a datetime that corresponds to the particular date and time
you specify in the date_time. The controller has a unique number for each
understandable moment in time.
For more information, see section 60.115 “STRTODATE” on page 1819..

60.113.3 STRTONUM
STRTONUM converts a string that contains a number in a string variable or other
string form to a numeric variable for use in mathematical operations. StrToNum
returns the converted numeric value.
For more information, see section 60.116 “STRTONUM” on page 1821..

04-20006-02-en, March 2019 Technical


1817
60 Script Programming
60.114 NUMTOSTR

60.114 NUMTOSTR
NUMTOSTR converts a number in a numeric variable or other numeric form to a
string variable so the number can be used in string operations. NUMTOSTR returns
the converted string value.

Syntax
NumToStr ( number )

Table: NUMTOSTR Parameter


Parameter Description

number Any number or expression.


A number in a string variable can be used in
string operations..

Examples
The following program translates the number 240 into a string:
Program File
String Trans
Trans = NumToStr (240)
Print TRANS
TRANS is no longer numeric and cannot be used in calculations.

Technical 04-20006-02-en, March 2019


1818
60 Script Programming
60.115 STRTODATE

60.115 STRTODATE
Alias: STRTOTIME
STRTODATE returns a datetime that corresponds to the particular date and time
you specify in the date_time. The controller has a unique number for each
understandable moment in time.
The system uses this date_time to process information about the date and time. If
you print a variable that is equal to a STRTODATE, you receive the date_time.

Note
Be aware that STRTODATE converts a text string to local rather than UTC time.

To receive the date and time from STRTODATE, you must enter both the date and
the time in one continuous input line. You can position the time before the date on
that line, if you prefer.
You can set up the date in any reasonably interpretable format—using all numbers
or spelling the month as either the full word or the three-letter abbreviation. You can
also separate the month, day, and year with spaces, slashes, dashes, periods,
commas, or any combination of these punctuation characters.
DAY and MONTH If you prefer to put the day first, ensure that the day is obviously a
day. There are two ways that a day cannot be misinterpreted as a month:
• Spell the month as a word so that the day is the only other number so low.
• Use numbers for both month and day only if the day is greater than 12, since
any number between 1 and 12 could be a month.
The month can be any of the following options:
• JAN[UARY]
• FEB[RUARY]
• MAR[CH]
• APR[IL]
• MAY
• JUN[E]
• JUL[Y]
• AUG[UST]
• SEP[TEMBER]
• OCT[OBER]
• NOV[EMBER]
• DEC[EMBER]
YEAR
You must enter the year as a four-digit year after 2008.
WEEKDAY
Since the controller already knows the day of the week that corresponds to each
date, you don’t need the day. You can, however, place the day of the week after
the date. The day of week must be either the three-letter abbreviation or the
completely spelled-out name of the day.

04-20006-02-en, March 2019 Technical


1819
60 Script Programming
60.115 STRTODATE

The weekday can be any of the following options:


• MON[DAY]
• TUE[SDAY]
• WED[NESDAY]
• THU[RSDAY]
• FRI[DAY]
• SAT[URDAY]
• SUN[DAY]
TIME
You enter the time as the one- or two-digit hour and one- or two-digit minute
separated by a colon. You can type another colon and follow that colon with
seconds.
You can enter the time in 24-hour time or use regular time with AM or PM following.
The controller translates that time into the 24-hour clock. For example, you can
enter 3:00 PM which the controller automatically translates to 15:00:00.
The following formats are acceptable:
• hh:mm:ss [AM/PM]
• hh:mm [AM/PM]
Where AM and PM (upper- or lowercase) are optional and the following are true:
• hh is hours (00 – 23)
• mm is minutes (00 – 59)
• ss is seconds (00 – 59)

Syntax
StrToDate (date_time)

Table: STRTODATE Parameter


Parameter Description

date_time Any actual date and time in a string


(surrounded by quotation marks) or a name
that stands for a date and time.

Examples
Program File
CONV_DATE = StrToDate (‘SEPTEMBER-21-2000 11:00 pm’)

Technical 04-20006-02-en, March 2019


1820
60 Script Programming
60.116 STRTONUM

60.116 STRTONUM
Alias: VAL
STRTONUM converts a string that contains a number in a string variable or other
string form to a numeric variable for use in mathematical operations. StrToNum
returns the converted numeric value.
Once a number is in a numeric variable, the number can be used in mathematical
expressions and operations.

Syntax
StrToNum (string)

Table: STRTONUM Parameter


Parameter Description

string Any number in string form (in quotation


marks) or string expression that stands for a
number in text form.
If string is not a valid numeral or series of
numerals, STRTONUM fails. If STRTONUM
fails, the program either goes to LINE E (see
LINE keyword) or disables.

Examples
If you receive string input from the keyboard, but want the input to be numeric so
you can add another number, you use STRTONUM. The following program adds
the string (in quotation marks) that contains 78.5 to the number 92.8:
Program File
Numeric Trans
Trans = StrToNum ("78.5") + 92.8
Output
171.3

04-20006-02-en, March 2019 Technical


1821
60 Script Programming
60.117 Mathematical Functions

60.117 Mathematical Functions


Mathematical functions perform mathematical operations.

60.117.1 ABS
ABS returns the absolute value of number. The absolute value of any number,
positive or negative, is always the positive number.
For more information, see section 60.118 “ABS” on page 1824..

60.117.2 EXPONENTIAL
EXPONENTIAL returns a value equal to the base e raised to the number power.
For more information, see section 60.119 “EXPONENTIAL” on page 1825..

60.117.3 FACTORIAL
FACTORIAL returns the factorial of integer_expression.
For more information, see section 60.120 “FACTORIAL” on page 1826..

60.117.4 LN
LN returns the natural logarithm of any number_expression.
For more information, see section 60.121 “LN” on page 1827..

60.117.5 LOG
LOG returns the base 10 logarithm of integer_expression.
For more information, see section 60.122 “LOG” on page 1828..

60.117.6 RANDOM
RANDOM returns a random number from 0 to 32,767 using number. Random is
used to simulate real-life values to test programs.
For more information, see section 60.123 “RANDOM” on page 1829..

60.117.7 SQRT
SQRT returns the square root of the number.

Technical 04-20006-02-en, March 2019


1822
60 Script Programming
60.117 Mathematical Functions

For more information, see section 60.124 “SQRT” on page 1830..

60.117.8 SUM
SUM returns the sum of the listed items (Syntax 1), the sum of an array (Syntax 2),
or the sum of a numeric log (Syntax 3).
For more information, see section 60.125 “SUM” on page 1831.

04-20006-02-en, March 2019 Technical


1823
60 Script Programming
60.118 ABS

60.118 ABS
ABS returns the absolute value of number. The absolute value of any number,
positive or negative, is always the positive number.

Syntax
ABS (number)

Table: ABS Parameter


Parameter Description

number Any number or expression.

Examples
Example 1
You find the absolute value of -3 as follows:
Program File
Result=ABS(-3)
This statement sets RESULT to 3.
To maintain a setpoint temperature to within plus or minus 3 degrees, when the
temperature changes in either direction, the fan should blow in either the heating or
cooling as required.
In this situation, you should find the absolute value of the change to control the fan.
Whether the change is positive or negative makes no difference.
Example 2
Program File
If ABS(Temp_SP - Temp_2) >= 3 then run Fan_2

Technical 04-20006-02-en, March 2019


1824
60 Script Programming
60.119 EXPONENTIAL

60.119 EXPONENTIAL
Alias: EXP
EXPONENTIAL returns a value equal to the base e raised to the number power.

Syntax
Exponential (number)

Table: EXPONENTIAL Parameter


Parameter Description

number Any number or expression.

Examples
Example 1
Program File
EVAL = Exponential (0)
The result of e to the 0 power is 1. Because the EXPONENTIAL function returns 1,
EVAL is set to 1.
Example 2
Program File
R_VAL = Exponential (-1)
The result of e to the -1 power is 0.368, so R_VAL is set to 0.368.

04-20006-02-en, March 2019 Technical


1825
60 Script Programming
60.120 FACTORIAL

60.120 FACTORIAL
Alias: FACT
FACTORIAL returns the factorial of integer_expression.

Syntax
Factorial (integer_expression)

Table: FACTORIAL Parameters


Parameter Description

integer_expression Factorial (integer_expression)

The integer_expression is an integer greater than or equal to zero. The largest


number on which you can use FACTORIAL is 34.

Examples
The following statement sets FVAL to the result of factorial 3:
Program File
FVAL = Factorial (3)
The function returns 6, so FVAL = 6.

Technical 04-20006-02-en, March 2019


1826
60 Script Programming
60.121 LN

60.121 LN
LN returns the natural logarithm of any number_expression.

Syntax
LN (number_expression)

Table: LN Parameter
Parameter Description

integer_expression Any number not equal to zero.

Examples
Program File
LGVAL = LN(3.2)
The natural log is returned and placed in LGVAL.

04-20006-02-en, March 2019 Technical


1827
60 Script Programming
60.122 LOG

60.122 LOG
LOG returns the base 10 logarithm of integer_expression.

Syntax
LOG (number_expression)

Table: LOG Parameter


Parameter Description

integer_expression An integer greater than zero.

Examples
Program File
Result = LOG(10)
This statement sets RESULT equal to 1.

Technical 04-20006-02-en, March 2019


1828
60 Script Programming
60.123 RANDOM

60.123 RANDOM
Alias: RND
RANDOM returns a random number from 0 to 32,767 using number. Random is
used to simulate real-life values to test programs.
You must vary the number to generate different random sequences. If you do not
vary the number, you can see a repetitious pattern of values emerging over time.

Syntax
Random (number)

Table: RANDOM Parameter


Parameter Description

number Any number or expression.


You can omit number, but the parentheses
are required, as with all functions.

Examples
To simulate fluctuations of temperature between 50 and 70 degrees, you put any
number in the number. To generate a result in the range of 20 possible
temperatures, you divide the random number you generate by 32767, which gives
you a number between 0 and 1. Then multiply the result by 20. Finally, add 50
degrees to set the bottom of the range.
Program File
Random (8)/32767 times 20
Finally you add the bottom of the range you are trying to simulate to the random
number:
Program File
Temp = (Random (8)/32767 times 20) + 50

04-20006-02-en, March 2019 Technical


1829
60 Script Programming
60.124 SQRT

60.124 SQRT
SQRT returns the square root of the number.

Syntax
SQRT (number)

Table: SQRT Parameter


Parameter Description

number Any number or expression.

Examples
Program File
MVAL = SQRT (4)
The SQRT function returns 2 and the statement sets MVAL to 2.

Technical 04-20006-02-en, March 2019


1830
60 Script Programming
60.125 SUM

60.125 SUM
SUM returns the sum of the listed items (Syntax 1), the sum of an array (Syntax 2),
or the sum of a numeric log (Syntax 3).
Items in the list must all be either numbers or variables that contains numbers.
If any of the items in the list in Syntax 1 is an array or a log, the controller retrieves
the first item from the array or log and treats that item like any other single one in the
list.

Syntax
Format 1: Sum (numeric_list)
Format 2: Sum (numeric_array)
Format 3: Sum (numeric_log)

Table: SUM Parameters


Parameter Description

numeric_list One or more numbers or names that stand


for numbers, separated by commas.

numeric_array Any defined array that contains numbers.

numeric_log Any defined log that contains numbers.

Examples
Example 1
To sum several timers, you place them directly in the SUM function statement. You
list them in parentheses after SUM, as follows:
Program File
Total_Timers = Sum (Timer1, Timer2. Timer3, Timer4)
Example 2
You have been storing calculated values in an array called PARTTME. You then use
the sum on that array, as follows:
Program File
TotalTime = Sum (PartTime)
Example 3
You have been logging temperatures in a log for several hours. To find the sum of
them, you find the sum of that log, as follows:
Program File
HourlyTot = Sum (TempLog)
Example 4
You find the sum of several temperatures in a list, including the current value of
TEMPLOG, as follows:
Program File
HourlyAvg = Sum (Tmp801, Tmp802, TempLog)

04-20006-02-en, March 2019 Technical


1831
60 Script Programming
60.125 SUM

In this example, TEMPLOG is interpreted as the current value of TEMPLOG.

Technical 04-20006-02-en, March 2019


1832
60 Script Programming
60.126 Object Functions

60.126 Object Functions


Object functions perform operations on mathematical objects.

60.126.1 ReadProperty
ReadProperty retrieves the value of a property of a BACnet object.
For more information, see section 60.127 “ReadProperty” on page 1834...

60.126.2 Relinquish
Relinquish relinquishes a command. (You may also use WriteProperty and pass no
argument for the value).
For more information, see section 60.128 “Relinquish” on page 1835..

60.126.3 WriteProperty
WriteProperty sets the value of a property of a BACnet object. The returned value is
either SUCCESS or FAILURE.
For more information, see section 60.129 “WriteProperty” on page 1836..

04-20006-02-en, March 2019 Technical


1833
60 Script Programming
60.127 ReadProperty

60.127 ReadProperty
ReadProperty retrieves the value of a property of a BACnet object.

Syntax
ReadProperty (object_property)

Table: ReadProperty Parameters


Parameter Description

local var This is bound to the object property.

If an index is passed as a second argument, when attempting to read a value at


some command priority, it is simply ignored.
For EcoStruxure BMS Script programs, you can establish a binding directly to the
desired command priority.
For b3 BACnet device Script programs, you can only establish a binding to the
value property, and any index is always ignored.

Products Supported
b3 series controllers, EcoStruxure BMS servers

Examples
Example 1
Use ReadProperty to get a property value, without designating the property name:
Numeric Input AV1
Numeric Temp
Temp = ReadProperty (AV1)
Example 2
Use ReadProperty to get the description of an analog point and place it in a string
point:
String Input AV1_Description
String StringPoint
StringPoint = ReadProperty (AV1_Description)

Technical 04-20006-02-en, March 2019


1834
60 Script Programming
60.128 Relinquish

60.128 Relinquish
Relinquish relinquishes a command. (You may also use WriteProperty and pass no
argument for the value).
Either an application program or operator issues a command to write to the
commandable property of a BACnet object, or relinquishes a command issued at
an earlier time.
A relinquish operation is similar to a WriteProperty operation, except that it places a
NULL value in the Priority_Array corresponding to the appropriate priority. When
that occurs, the next lower priority, non-NULL position, takes control of the
property.
If all the priority table array elements are NULL, the commandable property
assumes the one defined in the Relinquish Default property of the object.

Note
• Present Value is the commandable property for the following classes: Analog
Output, Binary Output, Multistate Output, Analog Value, Multistate value,
Binary Value.

Syntax
Relinquish (object_property, priority)

Table: Relinquish Parameters


Parameter Description

local var Bound to object property.

priority Priority number, ranging from 1 (highest) to


16 (lowest).
This applies only to a BACnet commandable
property. For controllers: If not present, the
property value that matches priority 16, if
applicable, is used.

Products Supported
b3 series controllers, EcoStruxure BMS servers

Example
Use Relinquish to relinquish the last command issued with priority 5. This statement
places a NULL in the fifth entry of the priority array (1-biased):
Numeric Output AV1
Relinquish (AV1,5)

04-20006-02-en, March 2019 Technical


1835
60 Script Programming
60.129 WriteProperty

60.129 WriteProperty
WriteProperty sets the value of a property of a BACnet object. The returned value is
either SUCCESS or FAILURE.

Syntax
WriteProperty (object_property, value, priority, index)

Table: WriteProperty Parameters


Parameter Description

local var Bound to an object property.


The object identifier and property identifier
are combined as one argument.

value Actual value to which the property is set.


This is optional. If it is not present, then the
next argument, priority, must be present to
perform a Relinquish command.

priority Priority number, ranging from 1 (highest) to


16 (lowest).
This is optional. It applies only to a BACnet
commandable property.
For controllers: If it is not present, priority 10,
if applicable, is used.

index This is optional. It applies only to an array-


type BACnet property. The index is ignored
whenever it is not applicable.

Products Supported
b3 series controllers, EcoStruxure BMS servers

Examples
Example 1
Use WriteProperty to set the analog value of an object to 100.
‘Value property is assumed
Numeric Output AV1
WriteProperty (AV1, 100)
Example 2
Use WriteProperty to set the Present_Value property of an object to 100, using
priority 5:
Numeric Output AV1
WriteProperty (AV1, 100, 5)
Example 3
Use WriteProperty to relinquish a command using priority 5:

Technical 04-20006-02-en, March 2019


1836
60 Script Programming
60.129 WriteProperty

‘Value is not passed; This is equivalent to a relinquish


Numeric Output AV1
WriteProperty (AV1, , 5)

Exceptions
When an EcoStruxure BMS server program uses the WriteProperty keyword to set
the value of a BACnet object (including b3 objects), the value is always written to
priority 16. For example, if you bind the program’s output to an analog value in
$SERVER/BACnet Device/Application and add it to a task, the value is written to
the analog output’s priority 16.
To write to a specific priority in a BACnet object from an EcoStruxure BMS server
program, the program must be bound directly to the priority you wish to write to.
This means that the priority no longer gets passed an argument as shown in the
examples that follow.
‘bound to BACnet analog value AV1 Priority 5
Numeric output x
Numeric a
‘places the value of 100 into AV1 Priority 5 slot
WriteProperty (x, 100)
‘places the value of AV1 Priority 5 into variable a
a = ReadProperty (x)
‘relinquishes the AV1 Priority 5 value
Relinquish (x)
‘relinquishes the AV1 Priority 5 value
‘Value argument is not passed into the WriteProperty
‘function
WriteProperty (x, )
WriteProperty (x)

04-20006-02-en, March 2019 Technical


1837
60 Script Programming
60.130 PASSED Function

60.130 PASSED Function


The PASSED function keyword indicates whether or not the argument with the
arg_number has been passed into the current function. Returns TRUE (numeric 1) if
the argument is actually passed and FALSE (numeric 0) if not.

Syntax
Passed (arg_number)

Table: PASSED Parameter


Parameter Description

arg_number Returns TRUE (numeric 1) if the argument is


actually passed and FALSE (numeric 0) if
not.

Examples
You can create a function that takes an argument and checks to see if the
argument is passed. The function below returns the number of the argument that
has the highest value and also returns after finding the first argument that is not
passed. The function called MAXITEM, predefined in the language, is shown as
follows:
Function File
Numeric Count, Lastmax
Lastmax = 1
For Count = 1 TO 15
If not(Passed (Count)) then return (Lastmax)
If ARG[Count] > Lastmax then Lastmax = Count
Next Count

Technical 04-20006-02-en, March 2019


1838
60 Script Programming
60.131 Rounding Functions

60.131 Rounding Functions


Rounding functions round numbers to the next integer and then return values.

60.131.1 CEILING
CEILING rounds a number to the next larger integer on the number line and returns
that integer.
For more information, see section 60.132 “CEILING” on page 1840..

60.131.2 FLOOR
FLOOR returns the next smaller integer on the number line and returns that integer.
For more information, see section 60.133 “FLOOR” on page 1841..

60.131.3 ROUND
ROUND rounds a number to the nearest integer and returns that value.
For more information, see section 60.134 “ROUND” on page 1842..

60.131.4 TRUNCATE
TRUNCATE drops the fractional part of number and returns the integer.
For more information, see section 60.135 “TRUNCATE” on page 1843..

04-20006-02-en, March 2019 Technical


1839
60 Script Programming
60.132 CEILING

60.132 CEILING
CEILING rounds a number to the next larger integer on the number line and returns
that integer.
See ROUND for a comparison of all rounding functions.

Syntax
Ceiling (number)

Table: CEILING Parameter


Parameter Description

number Any number or expression.

Examples
Example 1
Program File
The following shows how the controller calculates the ceiling of -2.7:
Top = Ceiling(-2.7)
This statement returns -2.
Example 2
Program File
RndVal = Ceiling(4.3)
This statement returns 5.

Technical 04-20006-02-en, March 2019


1840
60 Script Programming
60.133 FLOOR

60.133 FLOOR
FLOOR returns the next smaller integer on the number line and returns that integer.

Syntax
Floor (number)

Table: FLOOR Parameter


Parameter Description

number Any number or expression. (See ROUND for


a comparison of all rounding functions.)

Examples
Example 1
Program File
TmpVar = Floor (42.7)
This statement returns 42.
Example 2
Program File
Result = Floor(-1.1)
This statement returns -2.

04-20006-02-en, March 2019 Technical


1841
60 Script Programming
60.134 ROUND

60.134 ROUND
ROUND rounds a number to the nearest integer and returns that value.
The number is any number or expression.
ROUND, CEILING, FLOOR, and TRUNCATE are similar, but differ in the following
ways:
• ROUND rounds up if the decimal is .5 or higher and down if the decimal is
below .5. ROUND (-1.7) gives -2 (see figure below).
• CEILING always rounds up. CEILING (-2.7) gives the closest higher number on
the number line, -2. For more information, see section 60.132 “CEILING” on
page 1840.
• FLOOR always rounds down. FLOOR (-3.8) gives the closest lower number on
the number line, -4. For more information, see section 60.133 “FLOOR” on
page 1841.
• TRUNCATE cuts off the decimal value. TRUNCATE (-3.8) gives the integer
without the decimal, -3.
The following table illustrates how the four functions differ:

Table: ROUND Functions


Function 4.2 4.7 -3.1 -3.7

ROUND 4 5 -3 -4

CEILING 5 5 -3 -3

FLOOR 4 4 -4 -4

TRUNCATE 4 4 -3 -3

Syntax
Round (number)
Parameter Description

number Any number or expression.

Examples
Example 1
Program File
Tmpvar = Round (-42.7)
This statement returns -43.
Example 2
Program File
Rndval = Round (4.3)
This statement returns 4.

Technical 04-20006-02-en, March 2019


1842
60 Script Programming
60.135 TRUNCATE

60.135 TRUNCATE
Alias: TRUNC
TRUNCATE drops the fractional part of number and returns the integer.

Syntax
Truncate (number)

Table: TRUNCATE Parameter


Parameter Description

number Any number or expression.

Examples
Example 1
Program File
CHP = Truncate (4.5)
TRUNCATE returns 4 and the program statement sets CHP to 4.
Example 2
Program File
VAL_C = Truncate (-1.7)
TRUNCATE returns -1 and the program statement sets VAL_C to -1.

04-20006-02-en, March 2019 Technical


1843
60 Script Programming
60.136 Statistical Functions

60.136 Statistical Functions


Statistical functions perform statistical operations.

60.136.1 AVERAGE
AVERAGE returns the average of a list of items, the average of the items in an array
you name, or the average of the items in the log you name.
For more information, see section 60.137 “AVERAGE” on page 1845..

60.136.2 MAXIMUM
MAXIMUM finds the maximum number in a list of numeric values, a numeric array,
or a numeric log.
For more information, see section 60.138 “MAXIMUM” on page 1847..

60.136.3 MAXITEM
MAXITEM finds the position of the largest number in a list, an array, or a log. For
example, MAXITEM returns 1 if the largest number is the first one in the list.
For more information, see section 60.139 “MAXITEM” on page 1849..

60.136.4 MINIMUM
MINIMUM finds the minimum number in a list of numeric values, a numeric array, or
a numeric log.
For more information, see section 60.140 “MINIMUM” on page 1851..

60.136.5 MINITEM
MINITEM finds the position of the smallest number in a list, an array, or log. For
example, MINITEM returns 1 if the smallest number is the first one in the list.
For more information, see section 60.141 “MINITEM” on page 1853..

60.136.6 StandardDeviation
StandardDeviation finds the standard deviation of a series of numbers.
For more information, see section 60.142 “StandardDeviation” on page 1855..

Technical 04-20006-02-en, March 2019


1844
60 Script Programming
60.137 AVERAGE

60.137 AVERAGE
Alias: AVG
AVERAGE returns the average of a list of items, the average of the items in an array
you name, or the average of the items in the log you name.

Syntax
Format 1: Average (numeric_list)
Format 2: Average (numeric_array)
Format 3: Average (numeric_log)
• Format 1 is supported in a Script program running in an EcoStruxure BMS
server and in field devices, such as b3 BACnet devices.
• Format 2 is supported for local variables declared in a Script program running
in an EcoStruxure BMS server and in field devices, such as b3 BACnet
devices.
• Format 2 is not supported in a Script program running in an EcoStruxure BMS
server. This is true for binding variables bound to a numeric, manual, array
external to the program.
• Format 3 is supported in a Script program running in a field device, such as a
b3 BACnet device, that accesses a numeric log.
• Format 3 is not supported in a Script program running in an EcoStruxure BMS
server. This is true for binding variables bound to any numeric log in the
EcoStruxure BMS server itself or any other devices, including field devices such
as b3 BACnet devices.

Table: AVERAGE Parameters


Parameter Description

numeric_list One or more numbers or names that stand


for number, separated by commas.

numeric_array Any defined array that contains numbers.

numeric_log Any defined log that contains numbers.

Items in the list must all be either numbers or variables that contain numbers.
Element numbers are not required. Omitting element numbers averages the entire
array or log.

Examples
Example 1
To average several temperatures, you place them directly in the AVERAGE function
statement. You list them in parentheses after AVERAGE, as follows:
Program File
Flr8_AVG = Average (TMP801, TMP802, TMP803, TMP804)
Example 2
Since you know a certain temperature varies, you have been storing readings in an
array called OAT. You then use the AVERAGE function on that array, as follows:

04-20006-02-en, March 2019 Technical


1845
60 Script Programming
60.137 AVERAGE

Program File
OAT_AVG = Average (OAT)
Example 3
You have been logging temperatures in a log, called TEMPLOG, for several hours.
To find their average, you use the AVERAGE function as follows:
Program File
HourlyAVG = Average (TEMPLOG)

Technical 04-20006-02-en, March 2019


1846
60 Script Programming
60.138 MAXIMUM

60.138 MAXIMUM
Alias: MAX
MAXIMUM finds the maximum number in a list of numeric values, a numeric array,
or a numeric log.

Syntax
Format 1: Maximum (numeric_list)
Format 2: Maximum (numeric_array)
Format 3: Maximum (numeric_log)
• Format 1 is supported in a Script program running in an EcoStruxure BMS
server and in field devices, such as b3 BACnet devices.
• Format 2 is supported for local variables declared in a Script program running
in an EcoStruxure BMS server and in field devices, such as b3 BACnet
devices.
• Format 2 is not supported in a Script program running in an EcoStruxure BMS
server. This is true for binding variables bound to a numeric, manual, array
external to the program.
• Format 3 is supported in a Script program running in a field device, such as a
b3 BACnet device, that accesses a numeric log.
• Format 3 is not supported in a Script program running in an EcoStruxure BMS
server. This is true for binding variables bound to any numeric log in the
EcoStruxure BMS server itself or any other devices, including field devices such
as b3 BACnet devices.

Table: MAXIMUM Parameters


Parameter Description

numeric_list One or more numbers or names that stand


for numbers, separated by commas.

numeric_array Any defined array that contains numbers.

numeric_log Any defined log that contains numbers.

Items in the list must all be either numbers or variables that contain numbers.
If any of the items in the list in Format 1 is an array or a log but does not indicate an
element number, the controller retrieves the current value of the point and treats
that point like any other single item in the list.

Examples
Example 1
The MAXIMUM function finds the maximum number in a list of variables as follows:
Program File
TOPNUMBER = Maximum (Zone1, Zone2, Zone3, Zone4)
The TOPNUMBER variable is assigned the maximum value found.
Example 2

04-20006-02-en, March 2019 Technical


1847
60 Script Programming
60.138 MAXIMUM

You can find the maximum number of kilowatts (KW) in the array of variables as
follows:
Program File
TOPNUMBER = Maximum (KW)
Example 3
You find the highest of several temperatures, including the current value of
TEMPLOG, as follows:
Program File
TOPNUMBER = Maximum (TMP801, TMP802, TEMPLOG)
In this example, TEMPLOG is interpreted as the current value of TEMPLOG.

Technical 04-20006-02-en, March 2019


1848
60 Script Programming
60.139 MAXITEM

60.139 MAXITEM
MAXITEM finds the position of the largest number in a list, an array, or a log. For
example, MAXITEM returns 1 if the largest number is the first one in the list.

Syntax
Format 1: Maxitem (numeric_list)
Format 2: Maxitem (numeric_array)
Format 3: Maxitem (numeric_log)
• Format 1 is supported in a Script program running in an EcoStruxure BMS
server and in field devices, such as b3 BACnet devices.
• Format 2 is supported for local variables declared in a Script program running
in an EcoStruxure BMS server and in field devices, such as b3 BACnet
devices.
• Format 2 is not supported in a Script program running in an EcoStruxure BMS
server. This is true for binding variables bound to a numeric, manual, array
external to the program.
• Format 3 is supported in a Script program running in a field device, such as a
b3 BACnet device, that accesses a numeric log.
• Format 3 is not supported in a Script program running in an EcoStruxure BMS
server. This is true for binding variables bound to any numeric log in the
EcoStruxure BMS server itself or any other devices, including field devices such
as b3 BACnet devices.

Table: MAXITEMS Parameters


Parameter Description

numeric_list One or more numbers or names that stand


for numbers, separated by commas.

numeric_array Any defined array that contains numbers.

numeric_log Any defined log that contains numbers.

If any of the items in the list in Format 1 is an array or a log, the controller retrieves
the first item from the array or log and treats that item like any other single item in
the list.

Examples
Example 1
To find the position of the largest number in a series of numbers, you enter the
series in the parentheses:
Program File
Temp1 = 60
Temp2 = 65
Temp3 = 70
Temp4 = 67

04-20006-02-en, March 2019 Technical


1849
60 Script Programming
60.139 MAXITEM

Maxitem (Temp1, Temp2, Temp3, Temp4)


The Maxitem statement returns 3, because the third item in the list contains the
largest number.
Example 2
To find the index position of the largest number in an array, you give the array name
in parentheses:
Program File
Maxitem (KW)
Example 3
To find the index position of the largest number in a log, you give the log name in
parentheses:
Program File
Maxitem(Temp)
Example 4
You find the position of the highest of several temperatures in a list, including the
current value of TEMPLOG, as follows:
Program File
Maxindex = Maxitem (TMP801, TMP802, TEMPLOG)
In this example, TEMPLOG is interpreted as the current value of TEMPLOG.

Technical 04-20006-02-en, March 2019


1850
60 Script Programming
60.140 MINIMUM

60.140 MINIMUM
MINIMUM finds the minimum number in a list of numeric values, a numeric array, or
a numeric log.
Items in the list must all be either numbers or variables that contains numbers.
If any of the items in the list in Format 1 is an array or a log but does not indicate an
element number, the controller retrieves the current value of the point and treats
that value like any other single item in the list.

Syntax
Format 1: Minimum (numeric_list)
Format 2: Minimum (numeric_array)
Format 3: Minimum (numeric_log)
• Format 1 is supported in a Script program running in an EcoStruxure BMS
server and in field devices, such as b3 BACnet devices.
• Format 2 is supported for local variables declared in a Script program running
in an EcoStruxure BMS server and in field devices, such as b3 BACnet
devices.
• Format 2 is not supported in a Script program running in an EcoStruxure BMS
server. This is true for binding variables bound to a numeric, manual, array
external to the program.
• Format 3 is supported in a Script program running in a field device, such as a
b3 BACnet device, that accesses a numeric log.
• Format 3 is not supported in a Script program running in an EcoStruxure BMS
server. This is true for binding variables bound to any numeric log in the
EcoStruxure BMS server itself or any other devices, including field devices such
as b3 BACnet devices.

Table: MINIMUM Parameters


Parameter Description

numeric_list One or more numbers or names that stand


for numbers.

numeric_array Any defined array that contains numbers.

numeric_log Any defined log that contains numbers.

Examples
Example 1
The MINIMUM function finds the minimum number in a list of variables as follows:
Program File
BotNumber = Minimum (Zone1, Zone2, Zone3, Zone4)
The BotNumber variable is assigned the minimum value found.
Example 2
You can find the minimum number of kilowatts in the array of variables as follows:

04-20006-02-en, March 2019 Technical


1851
60 Script Programming
60.140 MINIMUM

Program File
BottomNumber = Minimum (KW)
Example 3
You find the minimum of several temperatures, including the current value of
TEMPLOG, as follows:
Program File
BottomNumber = Minimum (TMP801, TMP802, TEMPLOG)
In this example, TEMPLOG is interpreted as the current value of TEMPLOG.
Example 4
You have a log called AV_TEMP that holds the average temperature for each of the
last five days. You can use the MINIMUM function to find the minimum temperature:
Program File
WklyMin = Minimum (AV_TEMP)
If AV_TEMP contains 110, 114, 112, 108, 109, MINIMUM returns 108 and the
program statement sets WKLYMIN to 108.

Technical 04-20006-02-en, March 2019


1852
60 Script Programming
60.141 MINITEM

60.141 MINITEM
MINITEM finds the position of the smallest number in a list, an array, or log. For
example, MINITEM returns 1 if the smallest number is the first one in the list.
If any of the items in the list in Format 1 is an array or a log, the controller retrieves
the first item from the array or log and treats that item like any other single item in
the list.

Syntax
Format 1: Minitem (numeric_list)
Format 2: Minitem (numeric_array)
Format 3: Minitem (numeric_log)
• Format 1 is supported in a Script program running in an EcoStruxure BMS
server and in field devices, such as b3 BACnet devices.
• Format 2 is supported for local variables declared in a Script program running
in an EcoStruxure BMS server and in field devices, such as b3 BACnet
devices.
• Format 2 is not supported in a Script program running in an EcoStruxure BMS
server. This is true for binding variables bound to a numeric, manual, array
external to the program.
• Format 3 is supported in a Script program running in a field device, such as a
b3 BACnet device, that accesses a numeric log.
• Format 3 is not supported in a Script program running in an EcoStruxure BMS
server. This is true for binding variables bound to any numeric log in the
EcoStruxure BMS server itself or any other devices, including field devices such
as b3 BACnet devices.

Table: MINITEM Parameters


Parameter Description

numeric_list One or more numbers or names that stand


for numbers.

numeric_array Any defined array that contains numbers.

numeric_log Any defined log that contains numbers.

Examples
Example 1
To find the position of the smallest number in a series of numbers, you enter the
series in the parentheses:
Program File
Temp1 = 60
Temp2 = 65
Temp3 = 70
Temp4 = 67
Minitem (Temp1, Temp2, Temp3, Temp4)

04-20006-02-en, March 2019 Technical


1853
60 Script Programming
60.141 MINITEM

The MINITEM statement returns 2, because the second item in the list contains the
smallest number.
Example 2
To find the index position of the smallest number in an array, you give the array
name in parentheses:
Program File
Minindex = Minitem (KW)
Example 3
To find the index position of the smallest number in a log, called TEMPLOG, you
give the log name in parentheses:
Program File
Minindex = Minitem (TEMPLOG)
Example 4
You find the position of the lowest of several temperatures in a list, including the
current value of TEMPLOG, as follows:
Program File
Minindex = Minitem(TMP801, TMP802, TEMPLOG)
In this example, TEMPLOG is interpreted as the current value of TEMPLOG.

Technical 04-20006-02-en, March 2019


1854
60 Script Programming
60.142 StandardDeviation

60.142 StandardDeviation
Alias: SD
StandardDeviation finds the standard deviation of a series of numbers.
The standard deviation is the result of the following steps:

Table: Finding the Standard Deviation


Step Action

1 Find the average of the list.

2 Find the differences between the average


and each number.
If the average is 110 and one of the numbers
is 112 that difference is 2.

3 Square the differences, so 2 becomes 4.

4 Add up the squares and find the average of


them.

5 Take the square root of the average.

Items in the list must all be either numbers or variables that contain numbers.
If any of the items in the list in Format 1 is an array or a log but does not indicate an
element number, the controller retrieves the current value of the point and treats
that point like any other single item in the list.

Syntax
Format 1: StandardDeviation (numeric_list)
Returns the standard deviation of the listed items.
Format 2: StandardDeviation (numeric_array)
Returns the standard deviation of the items in the array.
Format 3: StandardDeviation (numeric_log)
Returns the standard deviation of the items in the log.
• Format 1 is supported in a Script program running in an EcoStruxure BMS
server and in field devices, such as b3 BACnet devices.
• Format 2 is supported for local variables declared in a Script program running
in an EcoStruxure BMS server and in field devices, such as b3 BACnet
devices.
• Format 2 is not supported in a Script program running in an EcoStruxure BMS
server. This is true for binding variables bound to a numeric, manual, array
external to the program.
• Format 3 is supported in a Script program running in a field device, such as a
b3 BACnet device, that accesses a numeric log.

04-20006-02-en, March 2019 Technical


1855
60 Script Programming
60.142 StandardDeviation

• Format 3 is not supported in a Script program running in an EcoStruxure BMS


server. This is true for binding variables bound to any numeric log in the
EcoStruxure BMS server itself or any other devices, including field devices such
as b3 BACnet devices.

Table: StandardDeviation Parameters


Parameter Description

numeric_list One or more numbers or names that stand


for numbers, separated by commas.

numeric_array Any defined array that contains numbers.

numeric_log Any defined log that contains numbers.

Examples
Example 1
To find the standard deviation of several temperatures, you place them directly in
the STANDARDDEVIATION statement. You list them in parentheses as follows:
Program File
TempDev = StandardDeviation (70, 72, 74)
The standard deviation returned is 2.
Example 2
Since you know a certain temperature varies, you have been storing readings in an
array called VARTMP. You then use the STANDARDDEVIATION function on that
array, as follows:
Program File
Variation = StandardDeviation (VARTMP)
Example 3
You have been logging temperatures in a log for several hours. You find the
standard deviation of them as follows:
Program File
Deviance = StandardDeviation (TEMPLOG)
Example 4
You find the standard deviation of several temperatures in a list, including the
current value of TEMPLOG, as follows:
Program File
StdDev = StandardDeviation (TMP1, TMP2, TEMPLOG)
In this example, TEMPLOG is interpreted as the current value of TEMPLOG.

Technical 04-20006-02-en, March 2019


1856
60 Script Programming
60.143 String Functions

60.143 String Functions


String functions perform string-related operations.

60.143.1 ASC
ASC returns the ASCII value of the first character of the string.
For more information, see section 60.144 “ASC” on page 1859..

60.143.2 CHR
CHR returns one character whose ASCII code is number. CHR can be used to
send non-printing characters to a terminal, computer, or printer to initiate action.
For more information, see section 60.145 “CHR” on page 1860..

60.143.3 LEFT
LEFT returns a string consisting of the leftmost characters of string with a length
specified by integer.
For more information, see section 60.146 “LEFT” on page 1861..

60.143.4 LENGTH
LENGTH returns the number of characters in the string.
For more information, see section 60.147 “LENGTH” on page 1862..

60.143.5 MID
MID returns a string number character extracted from the string starting at offset.
For more information, see section 60.148 “MID” on page 1863..

60.143.6 RIGHT
RIGHT returns the number of requested characters (the integer) from the text string
starting from the right side (end) and counting left.
For more information, see section 60.149 “RIGHT” on page 1864..

04-20006-02-en, March 2019 Technical


1857
60 Script Programming
60.143 String Functions

60.143.7 SEARCH
SEARCH returns the position of the given search_string within string or 0 if the
controller can’t find the search_string.
For more information, see section 60.150 “SEARCH” on page 1865..

60.143.8 FIND
FIND performs a case sensitive or insensitive string search.
For more information, see section 60.151 “FIND” on page 1866.

60.143.9 STRINGFILL
STRINGFILL returns a string of number length containing a particular character that
you specify with the ASCII character code named by character code.
For more information, see section 60.152 “STRINGFILL” on page 1867..

60.143.10 TAB
TAB returns a series of continuous blank spaces. The number of blank spaces is
number.
For more information, see section 60.153 “TAB” on page 1869..

Technical 04-20006-02-en, March 2019


1858
60 Script Programming
60.144 ASC

60.144 ASC
ASC returns the ASCII value of the first character of the string.

Syntax
ASC (string)

Table: ASC Parameter


Parameter Description

string Any text (word or words) or text expression

Examples
This statement returns 83, which is the ASCII value of the character S:
Program File
ASC ("S")

04-20006-02-en, March 2019 Technical


1859
60 Script Programming
60.145 CHR

60.145 CHR
CHR returns one character whose ASCII code is number. CHR can be used to
send non-printing characters to a terminal, computer, or printer to initiate action.

Syntax
CHR (number)

Table: CHR Parameter


Parameter Description

number Any number or expression.

Examples
Example 1
After several pages of messages print, you then want to send a report to that
printer.
You make sure the report starts on a clean sheet of paper by sending an instruction
telling the printer to bring the paper to the top of a new page. This action is called a
formfeed. The code to generate a formfeed is 12. You write the formfeed as follows:
Program File
‘Generate a formfeed and report title
Print CHR(12); "Weekly Energy Report"
Example 2
Another way to use the CHR function is to send a bell to a terminal, computer, or
printer to warn that the ERRORS variable has reached a critically high value. The
ASCII code to generate a bell sound is 7. You write the errors variable notification as
follows:
Program File
‘Decides if too many errors are not acknowledged and generates a
bell
If errors > 15 then print CHR(7)

Technical 04-20006-02-en, March 2019


1860
60 Script Programming
60.146 LEFT

60.146 LEFT
Alias: FIRST
LEFT returns a string consisting of the leftmost characters of string with a length
specified by integer.

Syntax
Left (string, integer)

Table: LEFT Parameters


Parameter Description

string Any text (word or words) or text expression.

integer Any integer or integer expression up to the


length of the string that tells how many
characters you want from the string.
If integer is greater than the length of the
string then the controller returns the entire
string.

Examples
Example 1
Program File
LVAL = Left("ABCDEF", 2)
This statement returns AB.
Example 2
Suppose that the TEXT variable contains ROOM808; the following statement
retrieves the word ROOM by carrying out the LEFT function:
Program File
LVAL = Left(TEXT, 4)
This statement returns ROOM.

04-20006-02-en, March 2019 Technical


1861
60 Script Programming
60.147 LENGTH

60.147 LENGTH
Alias: LEN
LENGTH returns the number of characters in the string.

Syntax
Length (string)

Table: LENGTH Parameter


Parameter Description

string Any text (word or words) or text expression.

Examples
Example 1
Program File
Result = Length ("ABCDE")
The LENGTH function returns 5 and the statement sets RESULT to 5.
Example 2
Program File
Result = Length ("")
The LENGTH function returns 0 and the statement sets RESULT to 0.

Technical 04-20006-02-en, March 2019


1862
60 Script Programming
60.148 MID

60.148 MID
MID returns a string number character extracted from the string starting at offset.

Syntax
MID (string, offset, number)

Table: MID Parameters


Parameter Description

string Any text (word or words) or text expression.

offset The number (or a variable that contains the


number) of the position where you want the
controller to start extracting the string of
characters.
If offset is greater than the length of the
string expression, then MID returns the
empty string, " ".

number Any number or expression. Tells how many


characters you want extracted from the text
string.

Examples
Example 1
Program File
MIDSTR = MID("ABCDE", 2, 3)
MID returns BCD and the statement sets MIDSTR to BCD.
Example 2
Program File
PARTSTR = MID (ABCDE, 9, 2) returns " ".

04-20006-02-en, March 2019 Technical


1863
60 Script Programming
60.149 RIGHT

60.149 RIGHT
Alias: LAST
RIGHT returns the number of requested characters (the integer) from the text string
starting from the right side (end) and counting left.

Syntax
Right ( string, integer )

Table: RIGHT Parameters


Parameter Description

string Any text (word or words) or text expression.

integer Any integer or integer expression up to the


length of the string that tells how many
characters you want from the string.
If integer is greater than the length of the
string, then the controller returns the entire
string.

Example
Program File
RGTVAL = Right ("ABCDE", 3)
This statement returns CDE.

Technical 04-20006-02-en, March 2019


1864
60 Script Programming
60.150 SEARCH

60.150 SEARCH
SEARCH returns the position of the given search_string within string or 0 if the
controller can’t find the search_string.

Tip
SEARCH is case sensitive. If you would like to perform a case insensitive string
search, use the FIND keyword instead. For more information, see section 60.151
“FIND” on page 1866.

Syntax
Search (string, search_string)

Table: SEARCH Parameters


Parameter Description

string Any text (word or words) or text expression.

search_string Any text (word or words) that you want to


search for in the string.

Examples
Example 1
Program File
NSTR = Search ("ABCDE", "BC")
The search returns 2 and sets NSTR to 2, the position BC starts at in the string.
Example 2
Program File
NSTR = Search ("ABCDE", "CB")
The search returns 0 and sets NSTR to 0 because CB is not in the string.

04-20006-02-en, March 2019 Technical


1865
60 Script Programming
60.151 FIND

60.151 FIND
FIND performs a case sensitive or insensitive string search.

Syntax
Find (string, search_string, [0 or 1])

Table: FIND Parameters


Parameter Description

string Any text (word or words) or text expression.

search_string Any text (word or words) that you want to


search for in the string.

0 Performs a case sensitive search on the


string.
1
Performs a case insensitive search on the
string.
If no argument is present, a case insensitive
search is performed.

Examples
Example 1
Program File
NSTR = Find ("ABCDE", "bc")
The find returns 2 and sets NSTR to 2, the position bc starts at in the string.
Example 2
Program File
NSTR = Find ("ABCDE", "CB")
The find returns 0 and sets NSTR to 0 because CB is not in the string.
Example 3
Program File
NSTR = Find ("ABCDE", "bc", 0)
The find returns 0 and sets NSTR to 0 because the search string is case sensitive
and the lowercase bc is not present in the string.
Example 4
Program File
NSTR = Find ("ABCDE", "bc", 1)
The find returns 2 and sets NSTR to 2 because the search is case insensitive and 2
is the position bc starts at in the string.

Technical 04-20006-02-en, March 2019


1866
60 Script Programming
60.152 STRINGFILL

60.152 STRINGFILL
STRINGFILL returns a string of number length containing a particular character that
you specify with the ASCII character code named by character code.

Syntax
Stringfill (number, charactercode)

Table: STRINGFILL Parameters


Parameter Description

number Any number or expression. Gives the length


of the string.

charactercode The ASCII character code of the character


you want to fill the string.

Examples
Example 1
Suppose you want to print a series of 60 asterisks across the top of a report. You
use STRINGFILL to print the asterisks by providing the number 60 for the number of
asterisks, and the number 42 as the ASCII code for the asterisk, as follows:
Print Stringfill(60, 42)
Example 2
You can draw dashed horizontal lines in a report using STRINGFILL by providing
the number of spaces you want the line to print across (60) and the ASCII code for a
dash (45):
Report File
Print Stringfill(60, 45)
Example 3
Suppose you want to design a graph to show the peak kilowatt demand for each
day in the last week. You can create a bar graph by filling the appropriate number of
spaces with, for example, asterisks. The following program sets up such a graph:
Program File
Numeric ShortDays, DayX
Print "Peak KW Demand for Week"
Print " "
For DayX = 1 TO 7
Print ST(ShortDays, DayX);" | "; ~
Stringfill (KWD[DayX]/100, 42)
Next DayX
Print " +----+----+----+----+----+"
Print " 0 500 1000 1500 2000 2500 "
The program prints the title and proceeds to a FOR...NEXT loop.

04-20006-02-en, March 2019 Technical


1867
60 Script Programming
60.152 STRINGFILL

Inside the FOR...NEXT loop, the program first prints the short name of the weekday,
based on the number for the day (1 for SUN) using a customized function called ST.
Next, the program prints a plus sign after the name.
STRINGFILL then uses two values to print the kilowatt demand for that day:
Kilowatt demand for the day from the KWD array (KWD[1] = Sunday’s kilowatt
demand, KWD[2] = Monday’s kilowatt demand, and KWD[3] = Tuesday’s kilowatt
demand, and so on.
ASCII code for the asterisk (42).
To see how STRINGFILL uses these two values, take a look at Sunday in the graph
the program produces:
Program File Output
PEAK KWDEMAND FOR WEEK
SUN +******
MON +**********
TUE +********
WED +*********
THU +*******
FRI +********
SAT +***
+---+-----+-----+-----+-----+
0 500 1000 1500 2000 2500
First the program retrieves Sunday’s kilowatt demand from the KWD array.
Sunday’s kilowatt demand is 600 Kw. The program divides the demand by 100,
giving 6. So STRINGFILL prints six asterisks for Sunday.
The program then retrieves Monday’s kilowatt demand from the KWD array.
Monday’s kilowatt demand is 1000 Kw. The program divides the demand by 100,
giving 10. So STRINGFILL prints 10 asterisks for Monday.
The program continues to carry out the same process for each day of the week.
After printing Saturday’s kilowatt demand, the program prints the scale for the
graph, which displays 0 to 2500 Kw.

Technical 04-20006-02-en, March 2019


1868
60 Script Programming
60.153 TAB

60.153 TAB
TAB returns a series of continuous blank spaces. The number of blank spaces is
number.

Syntax
Tab (number)

Table: TAB Parameter


Parameter Description

number Any number or expression.


The number represents the number of
spaces you want to push the printed text to
the right, as on a typewriter. Must be less
than 132.

Examples
Program File
Print Tab (10); "This is a Title"
Output
This is a Title
The text is moved ten spaces to the right.

04-20006-02-en, March 2019 Technical


1869
60 Script Programming
60.154 Time Functions

60.154 Time Functions


Time functions perform time-related operations.

60.154.1 DIFFTIME
DIFFTIME calculates the difference in whole seconds, minutes, hours, or days
between two dates and times, date_time1 and date_time2. (Subtracts date_time1
from date_time2.)
For more information, see section 60.155 “DIFFTIME” on page 1871..

60.154.2 TIMEPIECE
TIMEPIECE retrieves the piece of time (hour, minute, second) or the piece of the
date (weekday, month, day of the month, year, day of the year) from a variable or
point.
For more information, see section 60.156 “TIMEPIECE” on page 1873..

Technical 04-20006-02-en, March 2019


1870
60 Script Programming
60.155 DIFFTIME

60.155 DIFFTIME
DIFFTIME calculates the difference in whole seconds, minutes, hours, or days
between two dates and times, date_time1 and date_time2. (Subtracts date_time1
from date_time2.)

Syntax
Syntax 1: Difftime ( SECOND, date_time1, date_time2 )
Calculates the difference in whole seconds between two dates and times,
date_time1 and date_time2. (Subtracts date_time1 from date_time2.)
Syntax 2: Difftime ( MINUTE, date_time1, date_time2 )
Calculates the different in whole minutes between two dates and times, date_time1
and date_time2. (Subtracts date_time1 from date_time2.)
Syntax 3: Difftime ( HOUR, date_time1, date_time2 )
Calculates the different in whole hours between two dates ad times, date_time1
and date_time2. (Subtracts date_time1 from date_time2.)
Syntax 4: Difftime ( WKD, date_time1, date_time2 )
Calculates and returns the different in whole days between two times and dates,
date_time1 and date_time2. (Subtracts date_time1 from date_time2.)

Table: DIFFTIME Parameters


Parameter Description

date_time1 Any actual date and time or a datetime


variable.
DIFFTIME always subtracts the first datetime
from the second one.
With SECOND, any time beyond a complete
second is not counted. So, 2 1/2 seconds
becomes 2 seconds.
With MINUTE, any time beyond a complete
minute is not counted. So, 2 minutes and 15
seconds becomes 2 minutes.
With HOUR, any time beyond a complete
hour is not counted. So, 2 hours and 15
minutes becomes 2 hours.
With WKD, any time beyond a complete day
is not counted. So, two days and 15 hours
becomes two days.

date_time2 If date_time1 is later than date_time2,


DIFFTIME returns a negative number.

Examples
Example 1
You can use DIFFTIME with SECOND to determine how many seconds have
passed. The sample program below calculates the difference between two readings
of the datetime variable TIMER.
Program File

04-20006-02-en, March 2019 Technical


1871
60 Script Programming
60.155 DIFFTIME

Datetime Timer[2]
If Difftime (second, Timer[1], Timer[2]) > 30 then Run Test
The statement determines the result of TIMER[2] - TIMER[1]. If the difference is
greater than 30 seconds, TEST runs.
You would substitute MINUTE or HOUR in the above example to get time difference
in minutes or hours.
Example 2
You can use DIFFTIME with WKD to determine how many days have passed. The
sample program that follows calculates the difference between the old date (stored
in the OLDDATE variable) and the current date (in the DATE system variable).
Program File
Datetime Timer[2]
Result = Difftime (WKD, OLDTIME, DATE)
The statement sets RESULT to the number of days that DATE - OLDDATE gives.

Technical 04-20006-02-en, March 2019


1872
60 Script Programming
60.156 TIMEPIECE

60.156 TIMEPIECE
TIMEPIECE retrieves the piece of time (hour, minute, second) or the piece of the
date (weekday, month, day of the month, year, day of the year) from a variable or
point.

Note
Be aware that the days of the week correspond to the following digits:
• Sunday = 1
• Monday = 2
• Tuesday = 3
• Wednesday = 4
• Thursday = 5
• Friday = 6
• Saturday = 7

Syntax
Timepiece (datetime_system_variable, datetime_name)

Table: TIMEPIECE Parameters


Parameter Description

datetime_system_variable One of the date or time system variables:


HOUR, MINUTE, SECOND, HOD, TOD,
WEEKDAY, MONTH, DAYOFMONTH,
YEAR, DAYOFYEAR.

datetime_name Any name that stands for a date and time,


including datetime variables and points and
the DATE system variable.

Examples
Example 1
Program File
Datetime Date1
Numeric CurrentMin
Date1 = StrToDate ("5-25-98 11:13:23")
CurrentMin = Timepiece (Minute, Date1)
In this program, the TIMEPIECE function retrieves the minute from DATE1 and
returns 13.
Example 2
Program File
Numeric TodayMonth
TodayMonth = Timepiece (Month, Date)
In this program, the TIMEPIECE function retrieves the month from the DATE system
variable. If the date is June 20, 2005, TODAYMONTH is set to JUNE.

04-20006-02-en, March 2019 Technical


1873
60 Script Programming
60.157 Trigonometric Functions

60.157 Trigonometric Functions


Trigonometric functions return arccosine, arctangents, and arcsines of given
numbers.

60.157.1 ACOS
ACOS returns the arccosine of the given number.
For more information, see section 60.158 “ACOS” on page 1875..

60.157.2 ASIN
ASIN returns the arcsine of the number.
For more information, see section 60.159 “ASIN” on page 1876..

60.157.3 ATAN
ATAN returns the arctangent of number.
For more information, see section 60.160 “ATAN” on page 1877..

60.157.4 ATAN2
ATAN2 returns an angle with a sine of sin and a cosine of cos.
For more information, see section 60.161 “ATAN2” on page 1878..

60.157.5 COS
COS returns the cosine of number.
For more information, see section 60.162 “COS” on page 1879..

60.157.6 SIN
SIN returns the sine of the angle you specify.
For more information, see section 60.163 “SIN” on page 1880..

60.157.7 TAN
TAN returns the tangent of number.
For more information, see section 60.164 “TAN” on page 1881..

Technical 04-20006-02-en, March 2019


1874
60 Script Programming
60.158 ACOS

60.158 ACOS
Alias: ARCCOSINE
ACOS returns the arccosine of the given number.

Syntax
ACOS (number)

Table: ACOS Parameter


Parameter Description

number Any number or expression that gives a result


between -1 and 1 inclusive.

The value returned is between 0 and pi (3.14159) radians.


Radians = degrees TIMES (3.14159/180).
Degrees = radians TIMES (180/3.14159).

Examples
Program File
AN_VALUE = ACOS(.7071)

04-20006-02-en, March 2019 Technical


1875
60 Script Programming
60.159 ASIN

60.159 ASIN
Alias: ARCSINE
ASIN returns the arcsine of the number.

Syntax
ASIN (number)

Table: ASIN Parameter


Parameter Description

number Any number or expression that gives a result


between -1 and 1 inclusive, or expression
that gives a result in that range.

Returns the arcsine of number as an angle between -3.14159/2 and 3.14159/2.


Radians = degrees TIMES (3.14159/180).
Degrees = radians TIMES (180/3.14159).

Examples
Program File
Result = ASIN(1)

Technical 04-20006-02-en, March 2019


1876
60 Script Programming
60.160 ATAN

60.160 ATAN
Alias: ARCTANGENT
ATAN returns the arctangent of number.

Syntax
ATAN (number)

Table: ATAN Parameter


Parameter Description

number Any number or expression.

Returns an angle value between -3.14159/2 and 3.14159/2.


Radians = degrees TIMES (3.14159/180).
Degrees = radians TIMES (180/3.14159).

Examples
Program File
Val_ARC = ATAN(0)

04-20006-02-en, March 2019 Technical


1877
60 Script Programming
60.161 ATAN2

60.161 ATAN2
Alias: ARCTANGENT2
ATAN2 returns an angle with a sine of sin and a cosine of cos.

Syntax
ATAN2 (sin, cos)

Table: ATAN2 Parameter


Parameter Description

sin A number that is the sine of an angle.

cos A number that is the cosine of an angle.

The angle returned is between -3.14159 and 3.14159 radians.


Radians = degrees TIMES (3.14159/180).
Degrees = radians TIMES (180/3.14159).

Examples
Program File
Ang_Damper = ATAN2(0.0, 1.0)

Technical 04-20006-02-en, March 2019


1878
60 Script Programming
60.162 COS

60.162 COS
Alias: COSINE
COS returns the cosine of number.

Syntax
COS (number)

Table: COS Parameter


Parameter Description

number Any number or expression that represents


an angle measured in radians, between
-65536 and 65536.
Radians = degrees TIMES (3.14159/180).
Degrees = radians TIMES (180/3.14159).

Examples
Example 1
Program File
My_COS = COS(3.14159/2)
Example 2
Program File
My_COS = COS(angle)

04-20006-02-en, March 2019 Technical


1879
60 Script Programming
60.163 SIN

60.163 SIN
Alias: SINE
SIN returns the sine of the angle you specify.

Syntax
SIN (number)

Table: SIN Parameter


Parameter Description

number Any number or expression. The number


represents an angle in radians, between
-65536 and 65536.
Radians = degrees TIMES (3.14159/180).
Degrees = radians TIMES (180/3.14159).

Examples
Program File
Result = SIN (1)

Technical 04-20006-02-en, March 2019


1880
60 Script Programming
60.164 TAN

60.164 TAN
Alias: TANGENT
TAN returns the tangent of number.

Syntax
TAN (number)

Table: TAN Parameter


Parameter Description

number Any number or expression.


The number represents an angle measured
in radians.
Radians = degrees TIMES (3.14159/180).
Degrees = radians TIMES (180/3.14159).

Examples
Program File
Position = TAN (3.14159/180)

04-20006-02-en, March 2019 Technical


1881
61 Script Editor

Topics
Script Editor Overview
Script Editor Program Creation
Script Compiler Errors
Script Runtime Errors
Script Editor Features
Script Editor Program Elements and Colors
Keyboard Shortcuts for Script Editor
Collapsible Code Segments
Adding a Line
Script Auto-Completion
Using Script Auto-Completion
Script Editor Initial Binding Variable Values
Comments in Script Programs
Adding a Comment
Checking and Saving a Script Program
Executing a Script Program
Importing Script Program Code
Exporting a Script Program
Converting a Plain English File
Customizing the Script Editor
61 Using a Collapsible Script Code Block
Adding an Entry to the Code Library
Working with Code Library Folders
Working with Code Library Sample Import Files
Working with Code Library Items
Inserting a Code Library Item in a Script Program or
Function
Referencing the Code Library File
Finding Text in Script Editor
Using Undo and Redo in Script Editor
Script Debugger
Script Debugger Function Keys
Debugging a Script Program
Controlling the Trace Operation in the Script Debugger
Changing Values in the Script Debugger Local or Binding
Variables Pane
BACnet Priority Level Access
Configuring BACnet Priority Level Access
Configuring BACnet Priority Level Access for a b3 BACnet
Device
61 Script Editor
61.1 Script Editor Overview

61.1 Script Editor Overview


Script Editor is a text programming tool you use to create Script programs that
control and monitor building automation systems. Script Editor opens when you
edit a Script program in WorkStation.

61.1.1 Script Editor Program Creation


Script Editor is a text programming tool you use to create Script programs that
control and monitor building automation systems. For example, in WorkStation, you
can create a basic program, called OfficeLights, to control lighting and ventilation in
a room based on occupancy.
For more information, see section 61.2 “Script Editor Program Creation” on page
1886.

61.1.2 Script Editor Features


There are a number of features in Script Editor that allow you to improve the
readability and efficiency of your Script programs. These include:
• Program elements and colors
• Keystrokes
• Collapsible code segments
• Comments
• Auto-completion
For more information, see section 61.5 “Script Editor Features” on page 1896.

61.1.3 Script Compiler Errors


Script compiler errors identify problems that may occur in Script programming.
For more information, see section 61.3 “Script Compiler Errors” on page 1891.

61.1.4 Script Runtime Errors


Script runtime errors identify problems that may occur in Script programming.
For more information, see section 61.4 “Script Runtime Errors” on page 1894.

04-20006-02-en, March 2019 Technical


1885
61 Script Editor
61.2 Script Editor Program Creation

61.2 Script Editor Program Creation


Script Editor is a text programming tool you use to create Script programs that
control and monitor building automation systems. For example, in WorkStation, you
can create a basic program, called OfficeLights, to control lighting and ventilation in
a room based on occupancy.

Important
Ensure that you have a working and available Script license. A working license is
required to start Script. For more information, see the Licenses topic on
WebHelp.

Figure: OfficeLights Program in the List View


When you open your new OfficeLights program in Script Editor, you begin by
declaring local variables for the program input and output followed by names for the
variables. For more information, see section 59.16 “Local Variable Declarations” on
page 1630.

Technical 04-20006-02-en, March 2019


1886
61 Script Editor
61.2 Script Editor Program Creation

Figure: Variable Declarations


Once you have declared and referenced these variables, you then create the
program lines to specify the type of action you wish the program to perform. Script
programs are composed of everyday language statements, called instructions, so
you do not need to be a programmer to learn how to program with the Script
Editor.
After you finish writing the instructions in your program, you create points in
WorkStation.

04-20006-02-en, March 2019 Technical


1887
61 Script Editor
61.2 Script Editor Program Creation

Figure: WorkStation Points


You then bind the variables to those points to view the output.

Figure: Script Program Bindings

Technical 04-20006-02-en, March 2019


1888
61 Script Editor
61.2 Script Editor Program Creation

By using bindings, you can increase the flexibility of your building automation
system. For example, you can use your OfficeLights program to control lighting and
ventilation in one room and then use that program for another room by changing
the bindings. You do not need to change all of the local variable names to suit the
new program. When you are finished, you use Script Editor to check the program
for errors and save the program.

Figure: Script Program Check and Save Process


In WorkStation, in the Properties pane, you select the task in which you wish to
include your program. You then execute your Script program.

04-20006-02-en, March 2019 Technical


1889
61 Script Editor
61.2 Script Editor Program Creation

Figure: Script Program Execution


You can store your Script programs like a common document and include them
later in other projects for use in your control system. You can also write programs
that perform very complex control system decisions, such as controlling lighting,
boilers, and air handling units at multiple sites.
A single program file controls one piece of equipment, which makes programs
easier to maintain and debug. The capability to control one piece of equipment also
eliminates the possibility of a conflict occurring between the instructions in two
different programs. For example, a program that locks and unlocks a door prevents
the likelihood of an accidental door locking and unlocking.

Technical 04-20006-02-en, March 2019


1890
61 Script Editor
61.3 Script Compiler Errors

61.3 Script Compiler Errors


Script compiler errors identify problems that may occur in Script programming.

Table: Script Compiler Error Messages (1001...1102)


Error Error Text

1001

1002 Identifier <name> is too long.

1025 String <name> is too long.

1026 Comment exceeds maximum number of


characters.

1027 Syntax error, unexpected character


<character>.

1029 Syntax error, unexpected token <token>.

1030 Array size <number> is not an integer


between 1 and 36,767.

1031 FOR loop variable and NEXT variable are


different.

1032 GOTO statement is not allowed inside a


loop.

1033 Not enough free memory.

1034 Line <label> is redefined.

1035 Line <label> is not defined.

1036 Local variable <name> is redeclared.

1037 Variable <name> is not declared.

1038 Cannot define any more local variables.

1039 BREAK or CONTINUE is outside a loop or


block.

1040 Argument <name> is redeclared.

1041 Unsupported operational code.

1042 <number> is not a valid number.

1043 Number cannot be longer than 132 digits.

1044 Internal error: Invalid Stack Address.

1045 Internal error: Illegal stack pop operation.

1046 No function with that name exists.

04-20006-02-en, March 2019 Technical


1891
61 Script Editor
61.3 Script Compiler Errors

Continued
Error Error Text

1047 Variable is not an attribute.

1048 No quotation marks at end of string.

1054 Path name is too long.

1055 Attribute <name> does not apply to object


<name>.

1056 <name> defines an argument that cannot be


a local variable.

1057 Incorrect array entry type.

1058 Alarm expression is too large.

1059 Cannot set this variable. Make sure the


variable is not an input or function variable.

1060 Cannot set this attribute.

1061 Illegal rotate identifier type.

1062 Cannot enable or disable that object.

1064 Internal error: Stack overflow.

1065 Illegal use of a FOR loop variable. You must


use a local numeric variable.

1067 Cannot set a system variable.

1068 Statement is too long.

1069 System reserved label.

1070 Unsupported feature.

1071 Non integer number.

1072 Passed too many arguments to a function.


Be aware that Script functions support up to
15 arguments.

1073 Argument outside of index range.

1074 No character is allowed after continuation


symbol.

1075 Cannot Run or Stop program.

1076 Cannot compile report.

1077 Illegal command option.

Technical 04-20006-02-en, March 2019


1892
61 Script Editor
61.3 Script Compiler Errors

Continued
Error Error Text

1080 Command is valid only in a program or


function.

1081 Illegal name in alarm expression.

1083 Operation is not available.

1084 Total number of errors: <number>

1086 Syntax error, unexpected keyword


<keyword>

1087 Syntax error, unexpected symbol <symbol>

1088 Syntax error, unexpected symbol.

1089 Syntax error, unexpected comment.

1090 Local variable <name> is not an array.

1091 Syntax error, unexpected end of line.

1092 Syntax error, unexpected end of file.

1093 File not saved - You have not made any


changes.

1095 No Errors.

1096 Total number of characters used in line


labels exceeded maximum.

1097 Object <name> and the program are not in


the same network.

1098 Cannot use custom attribute in Program and


Function.

1099 Exceeded number of displayable lines.

1100 Unknown identifier.

1101 Unknown file type.

1102 End of file.

04-20006-02-en, March 2019 Technical


1893
61 Script Editor
61.4 Script Runtime Errors

61.4 Script Runtime Errors


Script runtime errors identify problems that may occur in Script programming.

Table: Script Runtime Error Messages


Error Text

Illegal type of assignment left-hand identifier

Set type mismatch

Local variable does not exist

Illegal expression type

Illegal hour value

String has more than 255 characters

Operation not supported

Stack Overflow

Illegal argument

Invalid destination

Illegal identifier type

Illegal variable type

Tried to divide a value by zero

Index out of range

Illegal array index

Illegal argument count

Invalid DateTime value

Executed too many statements on one line

Loop variable is not numeric

Error stopping current program

Illegal import ID

Bad path name

Illegal attribute usage

Exit User Function

Invalid set value

Preparse failed

Technical 04-20006-02-en, March 2019


1894
61 Script Editor
61.4 Script Runtime Errors

Continued
Error Text

Could not read from text file

Could not write to text file

Execution failed

Text file open failed

Comm failed

Cannot set attribute

Recursion not supported

04-20006-02-en, March 2019 Technical


1895
61 Script Editor
61.5 Script Editor Features

61.5 Script Editor Features


There are a number of features in Script Editor that allow you to improve the
readability and efficiency of your Script programs. These include:
• Program elements and colors
• Keystrokes
• Collapsible code segments
• Comments
• Auto-completion
• Initial binding variable values

61.5.1 Script Editor Program Elements and Colors


Within the Script Editor, each program element is displayed in a different color to
differentiate it from other program elements.
For more information, see section 61.6 “Script Editor Program Elements and
Colors” on page 1898.

61.5.2 Keyboard Shortcuts for Script Editor


You use keystrokes to change, move, find, cut, and paste text in the Script Editor.
For more information, see section 61.7 “Keyboard Shortcuts for Script Editor” on
page 1899.

61.5.3 Collapsible Code Segments


You can improve the readability of your programs by using collapsible code
segments within the Script Editor.
For more information, see section 61.8 “Collapsible Code Segments” on page
1900.

61.5.4 Comments in Script Programs


Comments are optional sentences you use to help document the operation and
purpose of your Script programs for the reader.
For more information, see section 61.13 “Comments in Script Programs” on page
1908.

Technical 04-20006-02-en, March 2019


1896
61 Script Editor
61.5 Script Editor Features

61.5.5 Script Auto-Completion


You can use auto-completion to fill in predictive text based on the possible matches
to the text that you type. Intellisense™ is an auto-completion tool that the
EcoStruxure Building Operation software uses to store a collection of keywords,
function names, and constants that you can use in Script programming.
For more information, see section 61.10 “Script Auto-Completion” on page 1904.

61.5.6 Script Editor Initial Binding Variable Values


In the Script Editor, you have two different ways of setting the initial binding variable
values:
• You can write statements in your Script program
• You can use the Initial Value field in the Variables pane
For more information, see section 61.12 “Script Editor Initial Binding Variable
Values” on page 1906.

04-20006-02-en, March 2019 Technical


1897
61 Script Editor
61.6 Script Editor Program Elements and Colors

61.6 Script Editor Program Elements and


Colors
Within the Script Editor, each program element is displayed in a different color to
differentiate it from other program elements.

Table: Program Elements and Default Colors


Program Element Default Color

Text Black

Keyword Blue

Function Dodger Blue

Value Maroon

String Red

Number Navy

Operator Teal

Comment Green

Technical 04-20006-02-en, March 2019


1898
61 Script Editor
61.7 Keyboard Shortcuts for Script Editor

61.7 Keyboard Shortcuts for Script Editor


You use keystrokes to change, move, find, cut, and paste text in the Script Editor.

Table: Changing and Moving Text


Keystroke Action

Backspace Deletes any selected text, or deletes one


character to the left of the cursor.

CTRL + F Opens the Find dialog box.

Ctrl + Insert or CTRL + C Copies selected text and stores that text in
the clipboard.

Shift + Insert Inserts text wherever you wish.

Delete Deletes selected text or deletes one


character to the right of the cursor. If the
cursor is at the end of a line, connects the
line to the next one.

Enter Ends a line and starts a new one.

Insert Toggles between two modes:


• Insert – Inserting text into current text
• Overwrite – Typing over current text
The current mode is shown on the Status
bar on the bottom of the Script Editor
screen.

Shift + Delete or CTRL + X Cuts the selected text and stores that text in
the clipboard.

Shift + Insert or CTRL + V Pastes the text you last cut or copied at the
current cursor position in your program.

04-20006-02-en, March 2019 Technical


1899
61 Script Editor
61.8 Collapsible Code Segments

61.8 Collapsible Code Segments


You can improve the readability of your programs by using collapsible code
segments within the Script Editor.
You can expand or collapse code for the following types of code segments:
• For...Next
• While...Endwhile
• Repeat...Until
• Select Case...Endselect
Collapsed code segments display as text within the program next to a Maximize
button indicating the keyword/collapser name in place of the full code lines.

61.8.1 Clipboard
You use the Clipboard pane as the area to store copied and cut items while
programming. You can paste items from the Clipboard into any of the program
editor panes that are being used. For example, by double-clicking on an item in the
clipboard pane, you can insert that text into the program where the cursor is
currently located.
You access the cut, copy, and paste commands in one of two ways:
• By using the toolbar buttons
• Through the use of keyboard shortcuts

61.8.2 Code Library


Within Script Editor, the Code Library is a helpful programming tool that allows you
to create multiple folders to save, organize, and recall frequently used text. You
store folders on your PC and these folders appear alphabetically in the Code Library
pane.

Technical 04-20006-02-en, March 2019


1900
61 Script Editor
61.8 Collapsible Code Segments

Figure: Folders
A code library folder is made up of frequently used units of text called entries. These
entries can be single words, a full code line, a function, or even an entire Script
program. You can decide how much and what kind of text is stored as an item
according to your programming preferences.
You can also give entries meaningful names to help you identify and use them
easily. You can reference the code library file from anywhere on the PC that you use
to run WorkStation.

System-Provided Programs, Functions, and Sample Import Files


The Script Editor Code Library contains a series of system-provided programs,
functions, and sample import files that can help you solve common problems. For
example, the sample import files help to implement and utilize Script program
features such as simulation and calculation programs. The Code Library contains
the entire set of objects, such as programs, functions, and values necessary for the
application to function.
You can use these system-provided programs, functions, and sample import files
as-is or as samples when developing your own Script programs. They are located in
the designated folders in the Code Library.

04-20006-02-en, March 2019 Technical


1901
61 Script Editor
61.8 Collapsible Code Segments

Figure: System-Provided Code Library Programs, Functions, and Import Files

Technical 04-20006-02-en, March 2019


1902
61 Script Editor
61.9 Adding a Line

61.9 Adding a Line


You add lines to specify the type of action you want your Script program to perform.
A line is an instruction or series of instructions that belong together under one line
label.
For more information, see section 59.11 “Lines and Line Numbers” on page 1622.

To add a line
1. In Script Editor, type a line label that is preceded by the Line keyword or
followed by a colon, and then add the instructions that belong to the line label.

You have now added line labels and instructions in your program.

04-20006-02-en, March 2019 Technical


1903
61 Script Editor
61.10 Script Auto-Completion

61.10 Script Auto-Completion


You can use auto-completion to fill in predictive text based on the possible matches
to the text that you type. Intellisense™ is an auto-completion tool that the
EcoStruxure Building Operation software uses to store a collection of keywords,
function names, and constants that you can use in Script programming.
These matches display for Script keywords, functions, and constants. The list of
words displays in a box to the right side of the cursor when you start typing a new
word.

Figure: Auto-completion
As more characters are typed, the list shrinks as the possible matches decrease. If
there are no matches, the box closes automatically.
ToolTips display next to the text options with information about each, such as
function description, keyword name, and function parameters. You can use
ToolTips to auto-complete the text by selecting any of the options listed.

Technical 04-20006-02-en, March 2019


1904
61 Script Editor
61.11 Using Script Auto-Completion

61.11 Using Script Auto-Completion


To save time, you use auto-completion to fill in predictive text based on possible
matches to the text you enter in your Script programs or functions.
For more information, see section 61.10 “Script Auto-Completion” on page 1904.

To Use Script auto-completion


1. In Script Editor, start typing and notice the predictive text that displays for
Script keywords, functions, and constants.
2. In the list, double-click the text you want to use.

04-20006-02-en, March 2019 Technical


1905
61 Script Editor
61.12 Script Editor Initial Binding Variable Values

61.12 Script Editor Initial Binding Variable


Values
In the Script Editor, you have two different ways of setting the initial binding variable
values:
• You can write statements in your Script program
• You can use the Initial Value field in the Variables pane

61.12.1 Statements in Script Programs


You can write statements directly in your Script program using an initialization line,
with one or more statements typically setting the output variables.
Initializing:
Set Output1 to 1
Set Output2 to 2
...
E:
'Some Error occurred, Restart Execution
GoTo Initializing

Tip
With this method, you can issue a GoTo statement to the initialization line
anywhere in the program. This GoTo statement directs the program to re-execute
the initialization statements and start over (based on program execution logic).

61.12.2 Script Editor Variables Pane Initial Value Field


You can configure initial binding variables values using the Initial Value field in Script
Editor's Variables pane.

Technical 04-20006-02-en, March 2019


1906
61 Script Editor
61.12 Script Editor Initial Binding Variable Values

Figure: Script Editor Variables Pane


When you configure the initial binding variable values in the Variables pane, the
program uses those values. However, when those variables are bound to object
properties, the program uses the variable values of the objects when it runs, instead
of the initial ones from the Variables pane.
The table that follows explains how to configure an initial value for each variable
type.

Table: Initial Value Variable Types


Variable Expected Value Configuration object

Float Numeric Text box

Integer Numeric Text box

Boolean Numeric Dropdown

String String Text box

DateTime DateTime Date and time picker

04-20006-02-en, March 2019 Technical


1907
61 Script Editor
61.13 Comments in Script Programs

61.13 Comments in Script Programs


Comments are optional sentences you use to help document the operation and
purpose of your Script programs for the reader.
Comments are not operated upon. Instead, you enter comments as single lines
preceded by a single quotation mark (‘).

Note
• Script supports characters at or below ASCII 127. Additional characters are
not supported and are replaced by a question mark (?).

Figure: Comments in Script Program


You can add as many comments as necessary, but each is restricted to one
physical (132 characters) line.
You can also add a comment after a statement on the same physical line, such as
the following:
TURN THE FAN ON ‘start cooling

Technical 04-20006-02-en, March 2019


1908
61 Script Editor
61.14 Adding a Comment

61.14 Adding a Comment


You use optional comments to help document the operation and purpose of a
Script program or function.
For more information, see section 61.13 “Comments in Script Programs” on page
1908.

To add a comment
1. In Script Editor, type a single quotation mark (') and then type a comment.

You can add a comment at the beginning of the program or function to explain its
purpose. You can also add comments at the end of any statement in a Script
program or function.

04-20006-02-en, March 2019 Technical


1909
61 Script Editor
61.15 Checking and Saving a Script Program

61.15 Checking and Saving a Script Program


You check your Script program to ensure there are no syntax errors. You perform a
save operation to check and then save your Script program.

Important
If you save a program that contains errors, that program will not run. The progam
must have a successful check before running.

For more information, see section 59.3 “Script Programs” on page 1605.

To check and save a Script program


1. In Script Editor, click Check.
2. In the Check pane, double-click on an error message to go to the line of code
that contains the error.
3. Click Save to check and save your Script program.
When you save a program that contains Input, Output, Public, Function and
WebService variables, the entries are automatically added to the
corresponding binding tabs in the Properties pane.
The Script Editor displays a Save Successful message, even if the program
contains errors and does not compile successfully.
You have now checked and saved your Script program.

Technical 04-20006-02-en, March 2019


1910
61 Script Editor
61.16 Executing a Script Program

61.16 Executing a Script Program


You execute a Script program in order to tell the EcoStruxure BMS server to take a
specific action to control a building.
For more information, see section 59.17 “Tasks” on page 1634.

To execute a Script program


1. In WorkStation, in the List View, select the Script program.
2. On the File menu, click Properties.
3. Click the Basic tab.
4. In the Task box, enter the task you want to add to the program.
5. Click OK.
6. In the List View, select the program you want to execute.
7. On the Actions menu, click Restart.
8. In the Script Program Properties Basic tab, observe that the Runtime
fields, such as TS, TM, and TH, update as the program executes.

04-20006-02-en, March 2019 Technical


1911
61 Script Editor
61.17 Importing Script Program Code

61.17 Importing Script Program Code


You import Script program code to reuse all or parts of existing code. Script Editor
supports import of .txt files created using the Plain English tool, as well as previously
created Script program files.
For more information, see section 59.10 “Script Program Instructions” on page
1620.

To import Script program code


1. In WorkStation, in the System Tree pane, select the Script program or
function you want to import program code to.
2. On the Actions menu, click Edit.
3. In Script Editor, position the insertion point in the program or function where
you want to import program code.

4. Click the Script menu button .


5. Point to Import and click Text or Plain English.
6. Select the file you want to import.
7. Click Open.
8. Click Save.

Tip
• When a Plain English .txt file is imported, you have to load the file
and complete a conversion process. As a result of these
conversions, you may need to make adjustments to the
imported script program code.

Technical 04-20006-02-en, March 2019


1912
61 Script Editor
61.18 Exporting a Script Program

61.18 Exporting a Script Program


You can export the contents of any program file to a .txt file in the Script Editor. This
lets you export programs and modify them in a text editor application separate from
WorkStation, or write them to a text file for use in another location.

Note
• To import text into a new program, create the program in a text editor first
and then import the .txt file.

For more information, see section 59.3 “Script Programs” on page 1605.

To export a Script program


1. In WorkStation, in the List View, select the Script program or function you
want to open.
2. On the Actions menu, click Edit.
3. In Script Editor, select the text in the program that you want to export.

4. Click the Script menu button .


5. Click Export.
6. Select the location where you want to save the exported text.
7. In the File name box, enter a name for the .txt file.
8. Click Save.

04-20006-02-en, March 2019 Technical


1913
61 Script Editor
61.19 Converting a Plain English File

61.19 Converting a Plain English File


You convert Plain English files to Script to reuse all or parts of existing Plain English
code.

To convert a Plain English file


1. In WorkStation, in the System Tree pane, select the Script program or
function you want to convert Plain English code to.
2. On the Actions menu, click Edit.
3. In Script Editor, position the insertion point in the program or function where
you want to import the Plain English code.

4. Click the Script menu icon , point to Import and then click Plain
English.
5. In the Import Plain English dialog box, click Load file to load an entire PE
file, or paste the text you want from your PE program or function into the Plain
English Editor pane.
6. Select the .txt file you want to convert.
7. Click Open.
8. Convert all or part of the file:
• Click Convert all to convert the entire PE file to a Script program.
• Select the lines you want to convert and then click Convert selected to
convert the selected lines to the Script program or function.
9. Correct any errors that occur during the conversion.
10. Click Close.
11. In Script Editor, click Save.

Technical 04-20006-02-en, March 2019


1914
61 Script Editor
61.20 Customizing the Script Editor

61.20 Customizing the Script Editor


You can customize the Script Editor and choose the preferred layout, line numbers,
or colors you want to use. You can also customize the appearance of programming
elements for easy identification, or select a path for use with code libraries and the
import/export tool.
For more information, see section 61.5 “Script Editor Features” on page 1896.

To customize the Script Editor


1. In Script Editor, click Options.
2. In the Options dialog box, click the General tab.
3. Select Tabbed documents to display your programs and functions as
tabbed documents in the Script Editor.
4. Select Multiple documents to display your programs and functions as
multiple documents in the Script Editor.
5. Select Enable IntelliSense to auto-complete keywords, function names,
and constants as you create programs in the Script Editor.
For more information, see section 61.10 “Script Auto-Completion” on page
1904.
6. Select Enable outlining to show the code segments eligible for collapse.
7. Select Show line numbers to display line numbers in the program window.
8. Click Restore default settings to restore the settings to their default values.
9. Click the Fonts and Colors tab.
10. In the Font box, click the drop-down menu to select the font you want to use.
11. In the Size box, select the font size.
12. In the Display items list, select the Script programming language element
you want to locate and highlight in your program.
For example, specify that a string in your Script program is highlighted in red.
13. Click Apply. The string in your Script program is now highlighted.
14. Click the Paths tab.
15. For Code library path, enter a path:
• Click Browse to locate and select a path.
Click Restore to specify the default path.
16. For Import / export path, enter a path:
• Click Browse to locate and select a path.
• Click Restore to specify the default path.
17. Click OK.

04-20006-02-en, March 2019 Technical


1915
61 Script Editor
61.21 Using a Collapsible Script Code Block

61.21 Using a Collapsible Script Code Block


You improve the readability of your Script programs and functions by using
collapsible code blocks within Script Editor. Code blocks are elements that Script
Editor automatically adds for certain types of program statements, such as
For...Next, Repeat...Until, Select Case...Endselect, and While...Endwhile.
For more information, see section 61.8 “Collapsible Code Segments” on page
1900.

To use a collapsible Script code block


1. In Script Editor, create a code block that determines squares using the
For...Next, Repeat...Until, Select Case...Endselect, or While...Endwhile
statements.
2. Expand or collapse the code in the code block by clicking + (Maximize), or -
(Minimize).
Collapsed code blocks appear as text within the program next to a + button
that indicates the keyword/collapser name in place of the full code lines.
You have now utilized a collapsible code block.

Technical 04-20006-02-en, March 2019


1916
61 Script Editor
61.22 Adding an Entry to the Code Library

61.22 Adding an Entry to the Code Library


You can add entries to the code library in Script Editor. Entries can be single words,
a full code line, a function, or a Script program.
For more information, see section 61.8 “Collapsible Code Segments” on page
1900.

To add an entry to the code library


1. In Script Editor, select the text that you want to save.
2. Right-click and select Add to library.
3. In the Add to Code Library dialog box, in the Entry name box, type an
entry name.
4. In the Create in box, select a code library folder:
• Select a folder from the list to add the entry to an existing folder.
• Click New folder to add the entry to a new folder.
5. Click Add.

04-20006-02-en, March 2019 Technical


1917
61 Script Editor
61.23 Working with Code Library Folders

61.23 Working with Code Library Folders


You can add, delete, and rename code library folders on your PC using Script
Editor. A code library is composed of frequently used units of text called entries.
For more information, see section 61.8 “Collapsible Code Segments” on page
1900.

To work with code library folders


1. In Script Editor, click Library.
2. In the Library pane, click a folder.
3. To add a new folder, right-click and click New folder. Then, enter a name for
the folder and click OK.
4. To change a folder name, right-click and click Rename folder. Then, enter a
new name for the folder and click OK.
5. To delete a folder and its contents, right-click and click Delete folder. Then,
click Yes.

Technical 04-20006-02-en, March 2019


1918
61 Script Editor
61.24 Working with Code Library Sample Import Files

61.24 Working with Code Library Sample


Import Files
You use the system-provided sample import files in the Script Editor Code Library
to develop your own Script programs that utilize Web Services. In this procedure,
the sample import file provides you with weather data, such as temperature and
humidity, for a given US city.
For more information, see section 62.1 “Script Web Services” on page 1937.

To work with code library sample import files


1. In Script Editor, click Library.
2. In the Library pane, click Sample Import Files.
3. Double-click the sample import file you want, such as WebService Restful GET
US City [Link] file.

Tip
By default, the path for the import is the Server. You cannot change
the path.

4. Click Import.
All of the objects contained in the import sample file are created in the
EcoStruxure BMS server.
5. In the List View, click the City variable.
6. On the File menu, click Properties.
7. In the Basic tab, enter the city name.
8. Click OK.
9. Drag these City values to the Watch pane and observe the functioning
program as it obtains the temperature and weather conditions for Boston.
10. In the List View, click the Get US City Weather by ZIP program.
11. On the Actions menu, click Edit.
12. View and edit the program as needed.
13. Click Save to execute the updated Get US City Weather by Zip program.

04-20006-02-en, March 2019 Technical


1919
61 Script Editor
61.25 Working with Code Library Items

61.25 Working with Code Library Items


You use items such as programs and functions in the code library when developing
your own Script programs and functions.
For more information, see section 61.8 “Collapsible Code Segments” on page
1900.

To work with code library items


1. In Script Editor, click Library.
2. In the Library pane, click the folder that contains the item.
3. Right-click the item and then click Rename item.
4. Enter a new name in the highlighted area.
5. To delete a code library item, click Delete item and then click Yes when
prompted.
6. To move a code library item, click Move to folder and then select the code
library location from the list.

Technical 04-20006-02-en, March 2019


1920
61 Script Editor
61.26 Inserting a Code Library Item in a Script Program or Function

61.26 Inserting a Code Library Item in a Script


Program or Function
You insert a code library item in a Script program or function to add a frequently
used unit of text such as a single word, a program instruction, a program line or set
of instructions, or a complete function or program.
For more information, see section 61.8 “Collapsible Code Segments” on page
1900.

To insert a code library item in a Script program or function


1. In Script Editor, position the insertion point in the program or function where
you want to insert the item.
2. Click Library.
3. In the Library pane, click the folder that contains the item.
4. Right-click the item and click Insert in editor.
The item appears at your insertion point in the Script program or function.

04-20006-02-en, March 2019 Technical


1921
61 Script Editor
61.27 Referencing the Code Library File

61.27 Referencing the Code Library File


You reference the code library file from anywhere on the PC you choose to run
Script.
For more information, see section 61.8 “Collapsible Code Segments” on page
1900.

To reference the code library file


1. In Script Editor, click Options.
2. Click the Paths tab.
3. For Code library path, enter a path:
• Click Browse to locate and select a path.
• Click Restore to specify the default path.
4. Click OK.

Technical 04-20006-02-en, March 2019


1922
61 Script Editor
61.28 Finding Text in Script Editor

61.28 Finding Text in Script Editor


You can find text in a Script program or function using the Script Editor toolbar Find
field.

Important
• Use this method when you want to search only the current program.

For more information, see section 61.5 “Script Editor Features” on page 1896.

To find text in Script Editor


1. In Script Editor, position the insertion point where you want to begin searching
in the program or function.
2. In the Find box, type the text or string you want to find in the program or
function.

3. Click the Find bbutton .


4. In the Find and replace dialog box, click Find.
5. In the current program or function, view the highlighted results.
6. Click Enter to find the next instance of the queried text.

04-20006-02-en, March 2019 Technical


1923
61 Script Editor
61.29 Using Undo and Redo in Script Editor

61.29 Using Undo and Redo in Script Editor


You use the Undo button on the Quick access toolbar in Script Editor to undo the
last keystroke or action. You use the Redo button to repeat the last keystroke or
action that you previously undid.
For more information, see section 61.5 “Script Editor Features” on page 1896.

To use Undo and Redo in Script Editor

1. In Script Editor, click the Undo button to undo the last keystroke or
action.

2. Click the Redo button to repeat the last keystroke or action that you
previously undid.

Note
• The limit of Undo and Redo actions is forward or backwards by
24 instances.

Technical 04-20006-02-en, March 2019


1924
61 Script Editor
61.30 Script Debugger

61.30 Script Debugger


In order to solve complex problems, Script programs have become more and more
sophisticated. With this increased sophistication, finding and fixing issues in the
program's logic has become even more difficult. The Script Debugger is designed
to address such issues.
For example, in the Script Debugger, you can single step through your Script
programs and proceed to the next executing line. You can visually trace your
program's operation as it highlights every executing statement, potentially
uncovering any problems in the program's logic.
You can also set a breakpoint in order to do the following:
• Establish a line where you want your program execution to stop.
• Examine or change variable values.
• Resume execution from that point.
When setting a breakpoint, you may discover the statement at that line is never
reached, uncovering a potential problem. The ability to identify problems in your
Script programs is one of the major advantages of the Script Debugger. Using its
in-session editing capabilities, you can then edit and fix any of the issues that you
identify.

61.30.1 Debug Mode Editing


In the Script Debugger, you can utilize debug mode editing features that allow you
to skip over troublesome areas in your Script programs and then resolve their
problems later. For example, you can use the following features
• Line E ignores error conditions and continues executing your Script programs.
You can then go back later and clear the error condition by correcting the
program's logic.
• Set next statement places the cursor at any executable statement or line in
your Script program. That line then gets highlighted and when you click Go or
single Step, gets executed. Execution resumes or starts from that newly-
selected statement, thus letting you skip over troublesome program issues.
• Comments selected lets you comment out one or more selected statements in
your Script program. By doing so, you direct Script program execution to
ignore commented statements in the Debugger until you identify and fix the
problems. You may also uncomment one or more selected statements and
direct your program to execute them. This is particularly useful for debugging
large Script programs with a number of loops.

61.30.2 Debug b3 BACnet Script Programs


Directly troubleshooting b3 BACnet device Script programs is not supported in the
Script Debugger. However, you can create a SmartX server Script program that
contains similar logic. You can then use this SmartX server Script program to
access b3 BACnet device points and debug that program. Be aware, however, that
not every syntax permitted in the b3 BACnet device is available in a SmartX server.

04-20006-02-en, March 2019 Technical


1925
61 Script Editor
61.30 Script Debugger

Note
Nested function calls are also not supported in the Script Debugger.

Technical 04-20006-02-en, March 2019


1926
61 Script Editor
61.31 Script Debugger Function Keys

61.31 Script Debugger Function Keys


You can use function keys in the Script Debugger to go to the next executing line in
your Script program, set or remove a breakpoint, or continuously execute your
program until a breakpoint is reached.
Function Key Action Acts like...

F5 Continuously executes a Clicking Go in the Script


Script program until a toolbar
breakpoint is reached or
execution ends.

F9 Sets or removes a Selecting the Insert


breakpoint in your Script breakpoint menu item
program.

F10 Goes to the next executing Clicking Step in the Script


line in the Script program. toolbar

04-20006-02-en, March 2019 Technical


1927
61 Script Editor
61.32 Debugging a Script Program

61.32 Debugging a Script Program


You use the Script Debugger to troubleshoot the Script programs you create.
For more information, see section 61.30 “Script Debugger ” on page 1925.

To debug a Script program


1. In WorkStation, in the List View, select the Script program you want to
debug.
2. On the Actions menu, click Edit.
3. In the Script Editor toolbar, click Start to initiate a Script debugging session.
4. Debug your Script program.
5. Click Trace On to initate a continuous single step operation. This saves you
from having to constantly press Step.

Note
The icon beside the program name changes to indicate the Script
Editor is now in Debug mode. Be aware that you can only debug one
program at a time.

6. Control the Trace operation.


For more information, see section 61.33 “Controlling the Trace Operation in
the Script Debugger ” on page 1929.
7. Click Step to go to the next executing line in your Script program.
8. Click Go to continuously execute a Script program until a breakpoint is
reached, or execution ends
9. Right click and select Insert breakpoint to toggle a breakpoint in your Script
program.
Programs execute until they reach a programmed breakpoint.
10. Place the cursor at any executable statement or line in your Script program.
11. Right click and select Set next statement from the Script Editor context
menu.
That line in the program gets highlighted.
12. Click Go or single Step to execute that statement.
Program execution resumes or starts from that newly-selected statement.
13. When finished, click Stop to terminate your Script debugging session.

Technical 04-20006-02-en, March 2019


1928
61 Script Editor
61.33 Controlling the Trace Operation in the Script Debugger

61.33 Controlling the Trace Operation in the


Script Debugger
You can control the Trace operation in the Script Debugger by setting a breakpoint
stop or specifying the timing trace.
For more information, see section 61.30 “Script Debugger ” on page 1925.

To control the trace operation in the Script Debugger


1. In WorkStation, in the List View, select the Script program you want to
debug.
2. On the Actions menu, click Edit.
3. In the Script Editor toolbar, click Options.
4. In the Options dialog box, click Debugger.
5. Control the Trace operation by clicking the Stop in breakpoint while
tracing check box.
6. In the Trace timer (ms) field, enter a value that specifies the timing of the
Trace operation.
Optionally, you may adjust the frequency of program statement execution,
such as .25, or .50 of a second.
7. Click Apply.
8. Click OK.

04-20006-02-en, March 2019 Technical


1929
61 Script Editor
61.34 Changing Values in the Script Debugger Local or Binding Variables Pane

61.34 Changing Values in the Script Debugger


Local or Binding Variables Pane
While in the Script Debugger, you can use the Local or Binding Variables pane
to re-calculate your Script program values.
For more information, see section 61.30 “Script Debugger ” on page 1925.

To change values in the Script Debugger local or binding


variables pane
1. In WorkStation, in the List View, select the Script program you want to
debug.
2. On the Actions menu, click Edit.
3. Click Start to enter the Script Debugger.
4. In the Script Debugger, click the Value field in the Local or Binding
Variables pane.
5. Type the new value and press Enter.
6. Click Stop to exit the Script Debugger.

Technical 04-20006-02-en, March 2019


1930
61 Script Editor
61.35 BACnet Priority Level Access

61.35 BACnet Priority Level Access


Depending on whether you are configuring BACnet priority level acces in
EcoStruxure Building Operation and MP Series Controller or b3 BACnet device
Script programs, there are several different methods of configuring that access.
When configuring BACnet priority level access in EcoStruxure Building Operation
and MP Series controllers Script programs, you must declare a program binding
variable and bind it to a specific priority level property. You cannot use the full path
name of an object directly.
For more information, see section 61.36 “Configuring BACnet Priority Level Access”
on page 1932.
When configuring BACnet priority level access in b3 BACnet device Script
programs, you use the legacy configuration method because the b3 is a legacy
BACnet device. As a result, you explicitly state the priority level by creating a binding
variable in the b3 Script program. You then bind that variable to the present value of
the commandable object using the WriteProperty or Relinquish function. Otherwise,
the default priority level is assumed.
For more information, see section 61.37 “Configuring BACnet Priority Level Access
for a b3 BACnet Device” on page 1933.

04-20006-02-en, March 2019 Technical


1931
61 Script Editor
61.36 Configuring BACnet Priority Level Access

61.36 Configuring BACnet Priority Level


Access
You must declare a program binding variable and bind it to a specific priority level
property when configuring BACnet priority level access in EcoStruxure Building
Operation and MP Series controller Script programs.
For more information, see section 61.35 “BACnet Priority Level Access ” on page
1931.

To configure BACnet priority level access


1. In WorkStation, in the List View, select a Script program.
2. Right-click and click Edit.
3. In the Script Editor, do not use the full path name of an object directly.
4. Declare a binding variable in the program and bind it to a specific priority level
property (1 through 16) of a commandable object.
5. Then, use the variable name to set the priority level value or relinquish the
value without having to specify the priority level itself in the statement.

Note
• The ReadProperty and WriteProperty keywords are available in
Script, but the priority level argument is not needed in the
statement. It is assumed based on the binding information.

6. Save your Script program.


7. Click Exit.

Technical 04-20006-02-en, March 2019


1932
61 Script Editor
61.37 Configuring BACnet Priority Level Access for a b3 BACnet Device

61.37 Configuring BACnet Priority Level


Access for a b3 BACnet Device
You explicitly configure BACnet priority level access in b3 BACnet device Script
programs by creating a binding variable in the b3 Script program and then binding
that variable to the present value of the commandable object.
For more information, see section 61.35 “BACnet Priority Level Access ” on page
1931.

To configure BACnet Priority Level Access for a b3 BACnet


device
1. In WorkStation, in the List View, select a Script program.
2. Right-click and click Edit.
3. In the Script Editor, create a binding variable in a b3 Script program.
4. Bind that binding variable to the present value of the commandable object
(that is, not a specific priority level).
5. Use the ReadProperty, WriteProperty or Relinquish keywords.
Be sure to use the binding variable name instead of the full path name of the
object.
6. Specify the priority level as needed.

7. Save your Script program.


8. Click Exit.

04-20006-02-en, March 2019 Technical


1933
62 Script Web Services

Topics
Script Web Services
Script Web Services Workflow
Creating a Script Web Service Interface
Configuring a Script Web Service Interface
Configuring a Script Program to use Web Services
Script SOAP Web Services Data Type
Script RESTful Web Services
Using Script to Send a Request to a RESTful Web Service
Using Script to Obtain a Secure Web Page from a RESTful
Web Service
62 Script Web Services
62.1 Script Web Services

62.1 Script Web Services


Web Services are programmable applications accessible from standard Internet
protocols, like HTTP and XML. Web Services help solve application integration
challenges by allowing applications to communicate with one another independent
of the target, host operating system, object model, or programming language.

Figure: Web Services Overview


Web Services are designed to support interoperable, machine-to-machine
interaction over a network. As a result, it makes perfect sense to use a Web Service
from a programming language, like Script. Because the Web Service is an
application delivered and utilized with regular Internet standards, the Web Service
operates as a URL by programmatically returning information for clients to employ.
The URL acts as a URI that specifies the location, identifies the available resource,
and provides a mechanism for retrieving it. For example, the following URLs identify
available online calculator and weather services:
• [Link]
• [Link]
To interact with Web Services, Script uses the Web Services Description Language
(WSDL) file to extract information about functions, parameters, and return types.
WSDL is an XML-based language that provides a model for describing Web
Services. For more information, see section 182.2 “Web Services ” on page 6932.

62.1.1 Script Web Services Workflow


You create and configure a Script Web Service by following these four basic steps:
• Create the Web Service interface
• Configure the Web Service interface
• Create a Script program
• Configure the Script Program to use Web Services

04-20006-02-en, March 2019 Technical


1937
62 Script Web Services
62.1 Script Web Services

For more information, see section 62.2 “Script Web Services Workflow” on page
1939.

62.1.2 Script SOAP Web Services Data Type


The Simple Object Access Protocol (SOAP) is a protocol for exchanging structured
information when implementing Web Services in computer networks. The Web
Service data type supports the interaction between a SOAP-based Web Service
and Script.
For more information, see section 62.6 “Script SOAP Web Services Data Type” on
page 1944.

62.1.3 Script RESTFul Web Services


REST (Representational State Transfer) is a style of software architecture for
distributed hypermedia systems, such as the World Wide Web. REST has emerged
as a predominant Web Service design model since it is lighter and simpler to use
than SOAP.
For more information, see section 62.7 “Script RESTful Web Services” on page
1948.

Technical 04-20006-02-en, March 2019


1938
62 Script Web Services
62.2 Script Web Services Workflow

62.2 Script Web Services Workflow


You create and configure a Script Web Service by following these four basic steps:
• Create the Web Service interface
• Configure the Web Service interface
• Create a Script program
• Configure the Script Program to use Web Services
For example, you can use the online calculator service at Florida State University to
add 2 numerics and calculate the result. In WorkStation, you create a Script Web
Service interface called Calculator and configure this interface by entering the
location of the service you wish to target. In this example, you enter the URL of a
WSDL file located at [Link]

You then create a Script program named Calculator Program and configure this
Script program to use Web Services. In this example, you use the Webservice
keyword to declare the Web Service in the program.

04-20006-02-en, March 2019 Technical


1939
62 Script Web Services
62.2 Script Web Services Workflow

Technical 04-20006-02-en, March 2019


1940
62 Script Web Services
62.3 Creating a Script Web Service Interface

62.3 Creating a Script Web Service Interface


You create a Script Web Service to identify and deliver with standard Internet
protocols an application that you can utilize as a service.
For more information, see section 62.1 “Script Web Services” on page 1937.

To create a Script Web Service interface


1. In WorkStation, in the System Tree pane, select the EcoStruxure BMS
server or folder where you want to create a Web Service interface.
2. On the File menu, point to New and click Interface.
3. In the Create Object wizard, in the object type list, expand Web Service
and then click Script Web Service.
4. In the Name box, type the name of the Web Service interface.
5. In the Description box, type a description of the Web Service interface.
6. Click Create.

04-20006-02-en, March 2019 Technical


1941
62 Script Web Services
62.4 Configuring a Script Web Service Interface

62.4 Configuring a Script Web Service


Interface
You configure a Script Web Service interface by entering the URL or WSDL file
location and then specifying the service you wish to target.
For more information, see section 62.2 “Script Web Services Workflow” on page
1939.

To configure a Script Web Service interface


1. In WorkStation, in the System Tree pane, select the Web Service interface.
2. On the File menu, click Properties.
3. Click the Basic tab.
4. In the Wsdl Url box, type the URL or a WSDL file located on a local PC or on
the Internet.
5. In the Service box, enter the name of the service you want to target.

Tip
• When you create a Web Service, you should ensure that your PC
can connect to the target service.

6. In the EndPoint box, type the URL of the machine where the Web Service
calls are processed.

Note
• Typically, the WSDL file defines the EndPoint, in which case, this
box is completed automatically. In some circumstances, you
may still need to enter an EndPoint, however.

7. Click OK.

Technical 04-20006-02-en, March 2019


1942
62 Script Web Services
62.5 Configuring a Script Program to use Web Services

62.5 Configuring a Script Program to use


Web Services
You select a Script program and then configure that program to use Web Services.
For more information, see section 62.2 “Script Web Services Workflow” on page
1939.

To configure a Script program to use Web Services


1. In WorkStation, in the System Tree pane, select the Script program that you
want to use Web Services.
2. On the Actions menu, click Edit.
3. In Script Editor, use the Webservice keyword to declare the Web Service in
the program.
4. In the Script Editor toolbar, click Save.
5. In the Properties pane, click the Web Services tab.
6. Enter the path to the Script Web Service interface.
7. In the Script Editor toolbar, click Save.
8. Continue building your Script program.
9. In the Script Editor toolbar, click Save.
10. In the Variables pane, view the results of the Web Service program.

04-20006-02-en, March 2019 Technical


1943
62 Script Web Services
62.6 Script SOAP Web Services Data Type

62.6 Script SOAP Web Services Data Type


The Simple Object Access Protocol (SOAP) is a protocol for exchanging structured
information when implementing Web Services in computer networks. The Web
Service data type supports the interaction between a SOAP-based Web Service
and Script.
SOAP relies on XML for its message format, and usually relies on other application
protocols for message negotiation and transmission. SOAP can form the foundation
layer for Web Services and also provide a basic messaging framework upon which
Web Services are built.
You bind the Script Web Services object to a corresponding Script program. Once
you do so, Script extracts all of the necessary material, including the methods, data
type for the arguments, and return values and their types.

Figure: Web Services Object Model


The Script Editor then displays Web Services methods using Intellisense.
Intellisense is an auto-completion tool that you use to fill in predictive text based on
possible matches to the text you type. For more information, see section 61.10
“Script Auto-Completion” on page 1904.

Technical 04-20006-02-en, March 2019


1944
62 Script Web Services
62.6 Script SOAP Web Services Data Type

62.6.1 Supported Data Types


Only simple data types are supported for both Web Service methods and return
values including:
• String
• Numerics
• DateTime

Tip
Web Service method calls need their own execution lines within Script programs.

62.6.2 Web Service Declarations


You declare a Web Service the same way you declare a function. You do so using
the keyword Webservice followed by a local variable name at the beginning of your
Script program. Then, you bind a Web Service object to the Script program using
the binding generated by this Web Service declaration as shown:

Figure: Web Services Declarations

04-20006-02-en, March 2019 Technical


1945
62 Script Web Services
62.6 Script SOAP Web Services Data Type

62.6.3 Web Service Method Calling


In Script Editor, you use the .(dot) syntax to select the Web Service execution
method as shown here.

Figure: Web Services .(Dot) Notation

Tip
Script programs do not support compression in EcoBuilding Building Operation
software. When a Script program attempts to call a Web Service method that
employs compression, it fails and the program does not execute as expected.

62.6.4 Web Service Selection and EndPoints


You select the Web Service you want to target by entering the Wsdl Url in the Basic
tab. In this case, the URL identifies an online calculator service. The Service field is
populated when you enter a valid Web Service URL. A WSDL file can contain one or
more services.

Technical 04-20006-02-en, March 2019


1946
62 Script Web Services
62.6 Script SOAP Web Services Data Type

Figure: Web Service Selection

Tip
When you create a Web Service, be sure that your PC can connect to the target
service.

The EndPoint is a reference to an entity, processor, machine, or resource for target


Web Service messages and calls. It represents the URL of the machine where the
Web Service calls are processed. Typically, information about EndPoints is
embedded inside the WSDL files. In those cases, the box is completed
automatically. In some circumstances, you may still have to enter an EndPoint,
however.

04-20006-02-en, March 2019 Technical


1947
62 Script Web Services
62.7 Script RESTful Web Services

62.7 Script RESTful Web Services


REST (Representational State Transfer) is a style of software architecture for
distributed hypermedia systems, such as the World Wide Web. REST has emerged
as a predominant Web Service design model since it is lighter and simpler to use
than SOAP.
REST defines a set of architectural principles you can use to connect to Web
Services that focus on a system's resources. This includes how resource states are
addressed and transferred over Hypertext Transfer Protocol (HTTP) by a wide range
of clients written in different languages. For more information, see section 62.6
“Script SOAP Web Services Data Type” on page 1944.
Script supports the generic use of REST Web Services through new Application
Programming Interfaces (APIs).

62.7.1 SendWebRequest
The SendWebRequest system function sends a request to a Uniform Resource
Locator (URL). Requests are sent from the running program in Script to a particular
Universal Resource Identifier (URI) following standard HTTP protocols.

Note
SendWebRequest is not supported in the MP Series controller.

The syntax for SendWebRequest is as follows:


SendWebRequest(BaseUrl,Method,ContentType,Headers,Message)
where:
• BaseUrl – A string with the location of the base URL to request data.
• Method – A string that contains the method type to access the URL. It can take
the following values:
– "POST"
– "GET"
• Headers – The headers for the HTTP message. Header fields are colon-
separated name-value pairs that can be concatenated with semi-colons (for
example, "IsMobileApp:TRUE;IsAndroidClient:TRUE")
• ContentType – A string that contains the content type. It is usually defined by
the target URL itself.
• Message – A string that contains the message sent to the URL. It is usually in
query-string values.
The return value is a string, usually in XML, that contains the response from the Web
Service.

Technical 04-20006-02-en, March 2019


1948
62 Script Web Services
62.7 Script RESTful Web Services

62.7.2 UrlEncode
The UrlEncode system function encodes the entire URL, including the message
with its query-string values. If characters, such as blanks, punctuation marks, and
arithmetic are passed directly to the HTTP stream, they may be misinterpreted and
result in the return of incorrect results. This function converts characters that are not
allowed in a URL into their equivalents.

Note
UrlEncode is not supported in the MP Series controller.

The syntax for UrlEncode is as follows:


UrlEncode(Message)
where:
Message is a string that needs Url encoding.
The return value is a string with valid characters the HTTP stream transmits.

04-20006-02-en, March 2019 Technical


1949
62 Script Web Services
62.8 Using Script to Send a Request to a RESTful Web Service

62.8 Using Script to Send a Request to a


RESTful Web Service
You can use the SendWebRequest system function to send a request to a RESTful
Web Service. In this procedure, you use SendWebRequest to request US city
weather data.
For more information, see section 62.7 “Script RESTful Web Services” on page
1948.

To use Script to send a request to a RESTful Web Service


1. In WorkStation, in the System Tree pane, select the EcoStruxure BMS
server or folder where you want to create a Script program.
2. On the File menu, point to New and then click Program.
3. In the Create Object wizard, in the Name box, enter the name of your new
Script program, such as Get US City Weather by ZIP.
4. In the Description box, type a description of the program.
5. Click Create.
6. In the List View, click the new Weather by ZIP Script program.
7. Click Edit.
8. Develop a Script program using the SendWebRequest system function and
the following parameters:
• BaseUrl – [Link]
• Method – GET
• ContentType – txt/xml
• Headers – ""
• Message –
/WeatherWS/[Link]/GetCityWeatherbyZIP?ZIP=02109
9. In the Script Editor toolbar, click Save.
10. Close the Script Editor.
11. In the List View, click the Get US City Weather by ZIP Script program.
12. In the Actions menu, click Restart to start the Script program.
13. On the File menu, click File and then Properties.
14. Click the Outputs tab and observe the resultXMLString output for zip code
02109.
The current weather for Boston is as follows:
• Description – Cloudy
• Temperature – 34°F
• Relative Humidity – 72%
• Wind - North at 13 MPH
• Barometric Pressure – 30.45 Steady

Technical 04-20006-02-en, March 2019


1950
62 Script Web Services
62.9 Using Script to Obtain a Secure Web Page from a RESTful Web Service

62.9 Using Script to Obtain a Secure Web


Page from a RESTful Web Service
You can use the SendWebRequest system function to obtain a secure web page
from a RESTful Web Service. In this procedure, you obtain a secure SSL certificate
authority page.
For more information, see section 62.7 “Script RESTful Web Services” on page
1948.

To use Script to obtain a secure web page from a RESTful Web


Service
1. In WorkStation, in the System Tree pane, select the EcoStruxure BMS
server or folder where you want to create a Script program.
2. On the File menu, click New and Program.
3. In the Create Object wizard, in the Name box, type the name of your new
Script program, such as Get Secure Web Page.
4. In the Description box, enter a description of the program.
5. Click Create.
6. In the List View, click the new Get Secure Web Page program.
7. Click Edit.
8. Develop a Script program using the SendWebRequest system function and
the following parameters:
• BaseUrl – [Link]
• Method – GET
• ContentType – txt/xml
• Headers – ""
• Message – None
9. In the Script Editor toolbar, click Save.
10. Close the Script Editor.
11. In the List View, click the Get Secure Web Page Script program.
12. In the Actions menu, click Restart to start the Script program.
13. On the File menu, click File and then Properties.
14. Click the Outputs tab and observe the webPageString output.

04-20006-02-en, March 2019 Technical


1951
63 Script User Interface

Topics
Script Editor
Script Editor Toolbars
Script Editor – Binding Variables Pane
Script Editor – Local Variables Pane
Script Editor Context Menu
Import Plain English Dialog Box
Script Editor Code Library
Script Program Properties – Basic Tab
Script Program Properties – Advanced Tab
Script Program Properties – Inputs Tab
Script Program Properties – Outputs Tab
Script Program Properties – Publics Tab
Script Program Properties – Functions Tab
Script Program Properties – Web Services Tab
Script Function Properties – Basic Tab
Script Function Properties – Inputs Tab
Script Function Properties – Outputs Tab
Script Function Properties – Publics Tab
Script Function Properties – Functions Tab
Script Web Service – Basic Tab
63 Script Web Service – Methods Tab
63 Script User Interface
63.1 Script Editor

63.1 Script Editor


Use the Script Editor to develop Script programs.

Figure:

Table: Script Editor


Number Description

Script Editor Toolbars


Use the toolbars to perform a variety of
functions, including opening, closing, saving,
printing, importing, and exporting Script
programs.

Clipboard pane
Use this pane to store copied and cut items
to use in Script programming. By double-
clicking on an item in the clipboard pane,
you can insert that text into the program
where the cursor is currently located.

04-20006-02-en, March 2019 Technical


1955
63 Script User Interface
63.1 Script Editor

Continued
Number Description

Status bar
Use this pane to review the path of the active
Script program or function. You can view the
line and column where the cursor is
positioned within the current editor pane.
The status bar also identifies the input
method, Insert or Overwrite, currently being
used in the editor.

Code Library pane


Use this pane to create and display the
folders and entries contained within your
code library. You can use the Code Library
to create multiple folders to save, organize,
and recall frequently used text. You can also
use the system-provided programs and
functions available in the Code Library when
developing your Script programs and
functions.

Properties pane
Use this pane to view and change general,
configuration, and runtime information about
your Script programs and fuctions and their
inputs and outputs tabs.

Local Variables pane


Binding Variables pane
Use these panes to view and edit properties
of the local or binding variables in the Script
Editor.
For more information, see section 63.4
“Script Editor – Local Variables Pane” on
page 1962.
For more information, see section 63.3
“Script Editor – Binding Variables Pane” on
page 1961.

Check pane
Use this pane to review the results of your
program compilation, including any syntax
errors. If the Script Editor checks a program
and finds no errors, a Check Successful
message displays. If errors occur, they
display with the error message number, line
and column location within the program, and
text or keywords involved.

Technical 04-20006-02-en, March 2019


1956
63 Script User Interface
63.1 Script Editor

Continued
Number Description

Find pane
Use this pane to locate and display queried
text. The Find pane displays the queried text
in quotes on the first line of the pane, the
open program the instance is located in, the
line number within the program where the
text can be found, and the context in which
the queried text is found.

Bindings view
Click to display the Bindings view for a Script
program. You can access the Bindings view
without leaving the Script Editor. For more
information, see section 59.16 “Local
Variable Declarations” on page 1630.

04-20006-02-en, March 2019 Technical


1957
63 Script User Interface
63.2 Script Editor Toolbars

63.2 Script Editor Toolbars


Use the Script Editor toolbar to perform a variety of different tasks within the
application.

Figure: Script Editor toolbars

Table: Script Editor Toolbars


Button Description

Open
Click to open an existing Script or b3
program or function.

Save
Click to save the currently active program.

Save All
Click to save all open programs.

Print
Click to print the current program.

Cut
Click to cut the selected text.

Copy
Click to copy the selected text.

Paste
Click to paste text.

Window
Click to open a pane or activate a minimized
pane.

Options
Click to configure program editor options
such as fonts, colors, layout, and code
library path.

Refresh
Click to refresh the focus window in the
Script Editor.

Technical 04-20006-02-en, March 2019


1958
63 Script User Interface
63.2 Script Editor Toolbars

Continued
Button Description

Script Bindings
Click to display the read-only Script Binding
View which shows the path for the local
bindings variables in your Script programs.

Check
Click to check a program file for syntax
errors.

Check All
Click to check all open program files for
syntax errors.

Start
Initiates a Script Debugger session. As the
debugger proceeds, it highlights the current
executing line in the Script program.
Stop
Terminates a Script Debugger session.

Trace On
Initiates a continuous single step operation
without the need to keep pressing the Step
icon.
Trace Off
Terminates the continuous single step
operation.

Go
Continuously executes a Script program until
a breakpoint is reached or execution ends.

Step
Goes to the next executing line in the Script
program.

Find
Click to find a specific word in the current
program.

Replace
Click to replace a specific word in the current
program.

Help
Click to view help topics for Script
programming.

04-20006-02-en, March 2019 Technical


1959
63 Script User Interface
63.2 Script Editor Toolbars

Continued
Button Description

Script menu button


Click to open the Script menu.

Script menu
Click to open, save, import, export, print, or
close a program. Export exports the current
Script object to a text file. Import imports
text from a text file, or opens the Import
Plain English dialog box which allows you
to import Plain English text for conversion.
For more information, see section 63.6
“Import Plain English Dialog Box” on page
1965.

Save
Click to save a Script program or function.

Undo
Click to undo or revert back one keystroke
or action in the Script Editor to the last state
of the text.

Redo
Click to redo or move ahead one keystroke
or action in the Script Editor to the state of
the text which was previously undone.

Customize quick access toolbar


Click to access the Customize quick
access toolbar dialog box where you can
add or remove additional buttons from the
Quick access toolbar.

Technical 04-20006-02-en, March 2019


1960
63 Script User Interface
63.3 Script Editor – Binding Variables Pane

63.3 Script Editor – Binding Variables Pane


Use the Binding Variables pane to view and edit the properties of the binding
variables in Script Editor. The Script programs that run in the SmartX server poll by
default, while you need to manually start and stop polling in the programs that run in
b3 BACnet and Infinet field devices.

Figure: Script Editor- binding variables pane

Table: Binding Variables Pane


Component Description

Click Start Update to display the current


value in the Binding Variables pane.
Click Stop Update to improve system
performance if real-time updates are not
required. For more information, see section
168.21 “Best Practices for Infinet Devices”
on page 6636.

Name Displays the variable name.

Value Displays the variable value.

Type Displays the variable type. For more


information, see section 60.71 “Variables
Pane Types” on page 1765.

Unit Displays the variable unit. Property values


bound to the program are automatically
converted to this unit.

Initial value Provides a text box, dropdown, or date and


time picker you can use to configure the
initial binding variable values in your Script
program. For more information, see section
61.12 “Script Editor Initial Binding Variable
Values” on page 1906.

04-20006-02-en, March 2019 Technical


1961
63 Script User Interface
63.4 Script Editor – Local Variables Pane

63.4 Script Editor – Local Variables Pane


Use the Local Variables pane to view and edit the properties of the local variables
in the Script Editor, including arrays. The display limit is the first 1,000 elements of
an array.

Figure: Script Editor – local variables pane

Table: Local Variables Pane


Component Description

Name Displays the variable name.

Value Displays the variable value.

Type Displays the variable type. For more


information, see section 60.71 “Variables
Pane Types” on page 1765.

Technical 04-20006-02-en, March 2019


1962
63 Script User Interface
63.5 Script Editor Context Menu

63.5 Script Editor Context Menu


Use the Script Editor context menu to write or edit Script programs and
functions.

Figure: Script Editor context menu

Table: Script Editor Context Menu


Command Description

Go to definition Positions the cursor at the definition line for


an item within the current Script program. If
the item is a function variable that is already
bound to a function object, the cursor is
positioned at the object definition the
function is bound to (the Script function
opens in the Script Editor).

Go to declaration Positions the cursor at the declaration line


for an item within the current Script program.
If the item is a function variable that is
already bound to a function, the cursor is
positioned at the line declaring the function
variable.

Add to library Opens the Add to Code Library dialog


box where you can save code library entries.

Collapse all Collapses all the collapsible code segments.

Expand all Expands all the collapsible code segments.

Comment selected Creates comments from the selected Script


program lines.

04-20006-02-en, March 2019 Technical


1963
63 Script User Interface
63.5 Script Editor Context Menu

Continued
Command Description

Uncomment selected Uncomments the selected Script program


lines.

Toggle breakpoint Inserts and removes a breakpoint at the


selected program line in the Script
Debugger.

Set Next Statement Highlights the next program statement in the


Script Debugger.

Find Opens the Find tab in the Find and


Replace dialog box where you can find a
specific word in the current program.

Replace Opens the Replace tab in the Find and


Replace dialog box. You can then replace a
specific word in the current program.

Goto Opens the Goto dialog box. You can then


enter a program line to jump to.

Technical 04-20006-02-en, March 2019


1964
63 Script User Interface
63.6 Import Plain English Dialog Box

63.6 Import Plain English Dialog Box


Use the Import Plain English dialog box to import Plain English programs and
functions into Script.

Figure: Import Plain English dialog box

Table: Import Plain English Dialog Box


Component Description

Load file Click to locate and load the Plain English file
that you want to add to your current Script
Editor program or function.

Display pane Use this pane to view and edit the PE


program or function that you want to load in
the Script Editor.

Editor pane Use this pane to review the results of your


Plain English program or function
conversion. If the Script Editor conversion
tool checks a program and finds no errors, a
Converting and then Conversion
Successful message displays. If errors
occur, they display with the error message
number, line and column location within the
program, and text or keywords involved.

04-20006-02-en, March 2019 Technical


1965
63 Script User Interface
63.6 Import Plain English Dialog Box

Continued
Component Description

Convert all Use this button to convert all of the text in


the Plain English program or function to
Script.

Convert selected Use this button to convert the selected text


in the Plain English program or function to
Script.

Close Use this button to close the Import Plain


English dialog box.

Technical 04-20006-02-en, March 2019


1966
63 Script User Interface
63.7 Script Editor Code Library

63.7 Script Editor Code Library


Use the Script Editor Code Library and its system-provided programs, functions,
and sample import files to help solve common problems.

Figure: Script Editor code library

Table: Script Editor Code Library


Component Description

Programs Folder Contains a series of system-provided Script


programs to assist in solving common
problems. You can use these items as-is or
as samples when developing your own
Script programs.

Sample Import Files Folder Contains a group of system-provided import


files. You can use these items as-is or as
samples when developing your own Script
programs.

04-20006-02-en, March 2019 Technical


1967
63 Script User Interface
63.8 Script Program Properties – Basic Tab

63.8 Script Program Properties – Basic Tab


Use the Basic tab to view and change general, configuration, runtime, and status
information about your Script programs.

Figure: Script program properties - basic tab

Table: Basic Tab


Component Description

Compilation valid Displays whether the program compiled


successfully.

Compiler version Displays the Script compiler version.

Status Displays the program status.

Current line Displays the program's current line.

Line start time Displays the program's line start time.

TS Displays the number of seconds that have


elapsed since the program has been on the
current line.

Technical 04-20006-02-en, March 2019


1968
63 Script User Interface
63.8 Script Program Properties – Basic Tab

Continued
Component Description

TM Displays the number of minutes that have


elapsed since the program has been on the
current line.

TH Displays the number of hours that have


elapsed since the program has been on the
current line.

TD Displays the number of days that have


elapsed since the program has been on the
current line.

Scan Specifies the length in seconds of the last


interpreter interval.

Error Indicates whether the program ran


successfully or encountered an error.

Enabled Displays whether or not the program is


enabled.

Task Enter the task you wish to execute. For more


information, see section 59.17 “Tasks” on
page 1634.

Execution precedence Select the order in which two programs are


run when the two programs are in the same
task. Applies when there is a loop
connection between them such that the
input of one program is actually the output of
another. For more information, see section
59.19 “Program Cycles in EcoStruxure
Building Operation Software” on page 1636.

Flow type Select the Looping or FallThru flow type


to order the way Script program instructions
are arranged and executed.

Apply Initial Value Select Yes to apply the initial values of the
binding variables. The default No does not
apply the values, thus ensuring, for example,
that an output point does not reset every
time a program that binds to one of its own
output variables is saved.

Debug mode Displays either On or Off to indicate visually


whether the Script Editor is in Debug mode.
This is a read-only setting.

04-20006-02-en, March 2019 Technical


1969
63 Script User Interface
63.9 Script Program Properties – Advanced Tab

63.9 Script Program Properties – Advanced


Tab
Use the Advanced tab to add or remove object properties that trigger the Script
program currently being edited.

Figure: Script program properties - advanced tab

Table: Advanced Tab


Component Description

Triggers Adds or removes object properties that


trigger the Script program currently being
edited. Any object property value change
triggers or executes the Script program.
Click Add to browse and select the desired
object property, or Edit to modify a selected
item in the Triggers list. Uncheck the box
preceding the object property to remove that
item from the list.

Technical 04-20006-02-en, March 2019


1970
63 Script User Interface
63.10 Script Program Properties – Inputs Tab

63.10 Script Program Properties – Inputs Tab


Use the Inputs tab to display the input bindings associated with the Script
program.

Figure: Script program properties - inputs tab

Table: Inputs Tab


Component Description

[Property Name] Select the value of the bound property. Use


the up and down arrow keys to increment
the value up or down by .5 of a point. Click

the Configure Settings icon to open


the [Property name] dialog and its
Configuration and Operation tabs.

04-20006-02-en, March 2019 Technical


1971
63 Script User Interface
63.11 Script Program Properties – Outputs Tab

63.11 Script Program Properties – Outputs


Tab
Use the Outputs tab to display output bindings associated with the Script
program.

Figure: Script program properties - outputs tab

Table: Outputs Tab


Component Description

[Property Name] Select the value of the bound property. Use


the up and down arrow keys to increment
the value up or down by .5 of a point. Click

the Configure Settings icon to open


the [Property name] dialog and its
Configuration and Operation tabs.

Technical 04-20006-02-en, March 2019


1972
63 Script User Interface
63.12 Script Program Properties – Publics Tab

63.12 Script Program Properties – Publics Tab


Use the Publics tab to display public bindings associated with your Script
programs.

Figure: Script program properties - publics tab

Table: Publics Tab


Component Description

[Property Name] Select the value of the bound property. Use


the up and down arrow keys to increment
the value up or down by .5 of a point. Click

the Configure Settings icon to open


the [Property name] dialog and its
Configuration and Operation tabs.

04-20006-02-en, March 2019 Technical


1973
63 Script User Interface
63.13 Script Program Properties – Functions Tab

63.13 Script Program Properties – Functions


Tab
Use the Functions tab to display output bindings associated with the Script
function.

Figure: Script program properties - functions tab

Table: Functions Tab


Component Description

[Function Name] Select the value of the bound property. Use


the up and down arrow keys to increment
the value up or down by .5 of a point. Click

the Configure Settings icon to open


the [Property name] dialog and its
Configuration and Operation tabs.

Technical 04-20006-02-en, March 2019


1974
63 Script User Interface
63.14 Script Program Properties – Web Services Tab

63.14 Script Program Properties – Web


Services Tab
Use the Web Services tab to select and bind the displayed service to the Web
Service interface you created.

Figure: Script program properties - Web Services tab

Table: Web Services Tab


Component Description

[service name] Displays the Web Service name. Select and


bind this service to the Web Service interface
you created. For more information, see
section 62.3 “Creating a Script Web Service
Interface” on page 1941.

04-20006-02-en, March 2019 Technical


1975
63 Script User Interface
63.15 Script Function Properties – Basic Tab

63.15 Script Function Properties – Basic Tab


Use the Basic tab to view and change general and configuration information about
your Script functions.

Figure: Script function properties - basic tab

Table: Basic Tab


Component Description

Compilation valid Displays whether the program compiled


successfully.

Technical 04-20006-02-en, March 2019


1976
63 Script User Interface
63.16 Script Function Properties – Inputs Tab

63.16 Script Function Properties – Inputs Tab


Use the Inputs tab to display the input bindings associated with the Script
function.

Figure: Script function properties - inputs tab

Table: Inputs Tab


Component Description

[Property Name] Set the value of the bound property. Use the
up and down arrow keys to increment the
value up or down by .5 of a point. Click the

Configure Settings icon to open the


[Property name] dialog and its Operation tab.

04-20006-02-en, March 2019 Technical


1977
63 Script User Interface
63.17 Script Function Properties – Outputs Tab

63.17 Script Function Properties – Outputs


Tab
Use the Outputs tab to display output bindings associated with the Script function.

Figure: Script function properties - outputs tab

Table: Outputs Tab


Component Description

[Property name] Set the value of the bound property. Use the
up and down arrow keys to increment the
value up or down by .5 of a point. Click the

Configure Settings icon to open the


[Property name] dialog and its Operation tab.

Technical 04-20006-02-en, March 2019


1978
63 Script User Interface
63.18 Script Function Properties – Publics Tab

63.18 Script Function Properties – Publics Tab


Use the Publics tab to display public bindings associated with the Script function.

Figure: Script function properties - publics tab

Table: Publics Tab


Component Description

[Property Name] Set the value of the bound property. Use the
up and down arrow keys to increment the
value up or down by .5 of a point. Click the

Configure Settings icon to open the


[Property name] dialog and its Operation tab.

04-20006-02-en, March 2019 Technical


1979
63 Script User Interface
63.19 Script Function Properties – Functions Tab

63.19 Script Function Properties – Functions


Tab
Use the Functions tab to display function bindings associated with the Script
function.

Figure: Script function properties - functions tab

Table: Functions Tab


Component Description

[Function name] Set the value of the bound property. Use the
up and down arrow keys to increment the
value up or down by .5 of a point. Click the

Configure Settings icon to open the


[Property name] dialog and its Operation tab.

Technical 04-20006-02-en, March 2019


1980
63 Script User Interface
63.20 Script Web Service – Basic Tab

63.20 Script Web Service – Basic Tab


Use the Basic tab to specify the location, identify the Web Service, and provide a
mechanism for retrieving it.

Figure: Script Web Service - basic tab

Table: Basic Tab


Component Description

Wsdl Url Type the URL for the WSDL file. The URL
must end with ?wsdl. SOAP 1.1 and 1.2 files
are supported here.

Service Select the Web Service you want to target.


For more information, see section 62.6
“Script SOAP Web Services Data Type” on
page 1944.

EndPoint Type the Web Service endpoint. For more


information, see section 62.6 “Script SOAP
Web Services Data Type” on page 1944.

04-20006-02-en, March 2019 Technical


1981
63 Script User Interface
63.21 Script Web Service – Methods Tab

63.21 Script Web Service – Methods Tab


Use the Methods tab to view a list of the methods supported by Web Services.

Figure: Sript Web Services - methods tab

Table: Methods Tab


Component Description

Methods Displays the list of methods supported by


the Web Service. Methods are the functions
that a Web Service can execute. SOAP 1.1
and 1.2 are supported here.

Technical 04-20006-02-en, March 2019


1982
64 Script Troubleshooting

Topics
Compiler error contains no error text
Runtime error contains no error number
64 Script Troubleshooting
64.1 Compiler error contains no error text

64.1 Compiler error contains no error text


The compiler error number displayed in the Check pane has no accompanying error
text.

64.1.1 Solution
Use the error number in the compiler error table to find the appropriate error text.
For more information, see section 61.3 “Script Compiler Errors” on page 1891.

04-20006-02-en, March 2019 Technical


1985
64 Script Troubleshooting
64.2 Runtime error contains no error number

64.2 Runtime error contains no error number


The runtime error displayed in the Check pane has no error number.

64.2.1 Solution
Use the error text in the runtime error table to troubleshoot the problem.
For more information, see section 61.4 “Script Runtime Errors” on page 1894.

Technical 04-20006-02-en, March 2019


1986

You might also like