Press "Enter" to skip to content

Script – Variables and formulas

Variables can be created and used freely within the script. The tags may also be used as variables (generic or associated with a equipment).

(To understand how to introduce the script in the SCADA software:  Script – Introduction – Step 1)

There are two types of variables:

1 – Number

2 – String / Text

Numeric variable:

Initialize the variable as number.

Examples:

x=0

y=7.43675

w=&HEEBBFF

y=y+1

The numeric variables can be set or calculated by the operators = + – * /.

 

String/Text variable:

Initialize the variable as text.

Examples:

s= “”

text1 =“Process running!”

 

Convert number to text: s = CStr(x)

Converts text to numbers: x = Val(s)

 

Text constants are set in quotation marks. Texts can be concactenados using + operator.

 

Example text concatenation: s=“Done” +CStr(x) + “Test (s).” (To use text variables in the command If use the operator ==. – See If expression)

 

The variable text can also function as memories or byte packets. They can be used to communication or processing of binary data. (see functions like BytesToStr)

 

Basic Operations

 

Numeric variables:

= Associate. Ex: y=1

+ Sum. Ex: y=y+1

 Subtraction. Ex: y=y1

* Multiplication. Ex: y=y*2

/ Division. Ex: y=y/2

 

String/Text Variables:

= Associates. Ex: s=“Text” 

Concatenate text. Example: s=s+“Text” 

 

Question?