Professional Documents
Culture Documents
Variable Operators
Cicode is used to manipulate data and perform tasks. Data manipulation is achieved
using five classes of operators. These are the Mathematical, Bit, Logical, Relational
and Format operators.
In this chapter we will learn how to use the operators in each of the different classes.
Chapter Objectives
In this chapter you will learn:
2-2
Classes of Operators
The following describes the five classes of operators available in Citect.
Mathematical Operators
The standard mathematical operators used to perform calculations on numeric
variables such as integers and floating point numbers. The available mathematical
operators are:
Operator
Description
Subtraction
Multiplication
Division
MOD
Modulus (Remainder)
Then if TAG_2 is 101, then TAG_1 becomes equal to 1 (the remainder after TAG_2 is
divided by 100).
An example of the concatenation operator is below:
Only a string is allowed to be passed to the Prompt() function and one way that the
value of TAG_1 can be displayed is to use concatenation. Note that since the data
type of TAG_1 is an integer we need to convert its type to a string before we can use
it. Hence the use of the function IntToStr().
Variable Operators
2-3
Logical Operators
Logical operators can be used to test the logical state of an operand. The return
result after the test can only be TRUE (1) or FALSE (0). The three logical operators
are:
Operator
Description
AND
Logical AND
OR
Logical OR
NOT
Logical NOT
Bit Operators
Standard bit operators are provided with Cicode. These are:
Operator
Description
BITAND
Bitwise AND
BITOR
Bitwise OR
BITXOR
Exclusive OR
Eg1.
2-4
Relational Operators
To test the relationship between two values, the relational operators can be used.
Operator
Description
Is EQUAL to
<>
Is NOT Equal to
<
Is LESS than
>
Is GREATER than
<=
>=
Format Operator
The format operator is used to convert numeric values into formatted strings for
display purposes.
Operator
Description
: (colon)
String Format
TAG_1 : ####.#
In this example, TAG_1 will be displayed as four digits before and one digit after the
decimal point. This type of formatting can be used when displaying a number as a
string. We commonly use this in report format files.
Variable Operators
2-5
1.
()
2.
NOT
3.
*, /, MOD
4.
5.
+, -
6.
7.
=, < >
8.
AND
9.
OR
10.
the NOT TAG_3 is evaluated first, which is logically ANDed with TAG_2, the result of
which is logically ORed with TAG_1. This is equivalent to:
NOTE: Having the brackets shows more clearly the order of precedence that will be taken.
2-6
Exercise 2-1
Go to the page YourProgs and create a button called Statement to perform the
logical expression: