Carriage returns and spaces can be included in the file, enabling the programmer to customise the
layout. It is suggested that each new statement should be started on a new line to make reading of the program
easier.
Comments can also be included anywhere in the program. When the program is interpreted, anything
inside square brackets is ignored. e.g.
[This is a comment.]
Definitions can also be included within UCL programs. These are used to make the programs easier to
read. Here is the general layout of a definition:
#define “new word or symbol” = “old word or symbol”;
All definitions begin with the word “#define”. This means that the next word or symbol can be replaced
(is a direct replacement for) with the word or symbol after the equals sign.
The following code makes “local_control” a direct replacement for “C_DIGITAL_IN1”.
#define local_control=C_DIGITAL_IN1;
Please Note: All #define’s must be at the start of the program (excluding comments), otherwise the
program will fail to compile correctly.
11.6 Types and Type Casting
In programming a data value can have different meanings depending on its type. For example, consider
the data value 1.2. If a floating-point value, it is indeed 1.2. If considered an integer value it is 1. If a boolean
value it is TRUE.
Casting is the conversion of a value from one type to another.
UCL supports four types.
11.6.1 Integer Type
These are whole numbers, positive or negative, including zero.
e.g. 0, 1, 2, 7865, -3 etc.
11.6.2 Floating Point Type
This is the type used to express fractions.
e.g. 0.54325, -3, 2.5 etc.
11.6.3 Boolean Type
This type consists of only two values, TRUE and FALSE. FALSE has a numerical value of 0,
and TRUE is anything other than 0. In a UCL program, if a boolean value is returned it will have the
numerical value of 0 (FALSE), or 1 (TRUE).
11.6.4 Register Names
This type allows the use of register values within a UCL program. A register is identified in the
program by entering its textual name. The type of the value read will depend on the type of the register.
Register values of type: character, int16, int32, alarms and pointers are cast into integers. Register
values of type float are cast into floating point.
Note: When a register name is entered, ensure you include any underscores within the
document.
11.6.5 Casting
Two types of casting are performed by UCL. The first type is the casting of the result from an
expression into the type of the register it is to be stored in. For example, consider the following
statement.
I_USER_INT1 = 5.2;