Declaring the Variable Data Type
- Last UpdatedJul 18, 2023
- 2 minute read
You can use variables of the following data types:
|
INT |
Integer (32 bits) |
-2,147,483,648 to 2,147,483,647 |
|
REAL |
Floating point (64 bits) |
-1.7E308 to 1.7E+308 with 15 digits of precision |
|
STRING |
Text string (255 bytes maximum, including null termination character) |
ASCII (null terminated) |
|
OBJECT |
ActiveX control object reference (32 bits) |
|
|
QUALITY |
Represents the Plant SCADA quality (64 bits) |
QUAL_GOOD, QUAL_BAD, QUAL_UNCR |
|
TIMESTAMP |
Represents the number of 100-nanosecond intervals since January 1, 1601 (64 bits) |
If you want to specify a digital data type, use the integer type. Digital types can either be TRUE(1) or FALSE(0), as can integer types.
Note:
• Cicode may internally store floating point values as 64 bit to minimize rounding
errors during floating point calculations.
• When comparing REAL values in Cicode it is recommended you use the Round() function
before doing the comparison.
QUALITY Data Type
The QUALITY data type is a new data type in Cicode which incorporates the Plant SCADA quality. The QUALITY data type and the Cicode quality labels can be used in Cicode expressions.
The operators allowed for the QUALITY data type are:
-
Assignment operator: =.
-
Relational operators: =, <>.
The assignment operation also allows for the QUALITY data type.
Example:
QUALITY q1;
QUALITY q2;
q1 = q2;
q1 = Tag1.Field.Q;
//the following expression will generate a compiler error as a tag //element can
be modified only as a whole
Tag1.Field.Q = q1;
A set of Cicode functions are provided which allow quality fields to be initialized, a specific quality field to be extracted, and other operations on the QUALITY data type. Conversion between the QUALITY data type and other Cicode data types is not allowed. Direct conversion from Quality to string will return an empty string.
Example:
//this will generate a compiler error
INT n = Tag1.Q;
TIMESTAMP Data Type
The TIMESTAMP data type represents the date and time as a 64-bit value by specifying the number of 100-nanosecond intervals since January 1, 1601.This data type is always in Coordinated Universal Time (UTC).
The operators allowed for the TIMESTAMP data type are:
-
Assignment operator: =.
-
Relational operators: =, <>, <, >, <=, >=.
Example:
TIMESTAMP t1;
TIMESTAMP t2;
t1 = Tag1.T;
t1 = t2;
IF t1 < Tag2.T THEN
// insert code here
END
STRING sStr;
REAL Result;
INT x, y;
OBJECT hObject;
The first 32 characters of a variable name needs to be unique.