NET/MASTER Network Control Language (NCL) Reference Manual

An Overview of Expressions
Expressions and Operators
106126 Tandem Computers Incorporated 10–5
Type Conversion and Relational Operators
Simple relational operators attempt to convert operands to numbers. They perform a
numeric comparison (or, if one of the operands is not a number, a character
comparison) and return a Boolean result (either 1 or 0). The result can be used as
either a string or a number.
Strict relational operators compare operands as strings and return a Boolean result
(either 1 or 0). The result can be used as either a string or a number.
Type Conversion and Boolean Operators
The Boolean operators expect operands to be Boolean (either 1 or 0). They return a
Boolean result, which can be used as either a string or a number.
Type Conversion and the Concatenation Operator
The concatenation operators expect operands to be strings. They return a result that
can be used as either a string or a number.
Example of Type Conversion
The following example illustrates automatic data conversion. It uses the following
statement to show how NCL performs automatic type conversion at each step of
processing:
&a = XYZ||LENGTH(1 + 2)
Step Comment
(1 + 2) The addition operator requires numbers. 1 and 2 in this context are numeric.
(3) The result of addition is numeric. 3 in this context is numeric.
LENGTH(3) The built-in function LENGTH requires strings. 3 in this context is a string.
1 The result of LENGTH is a number. 1 in this context is numeric.
XYZ||1 The concatenation operator requires strings. XYZ is a string. 1 in this context is a
string.
XYZ1 The result of concatenation is a string. XYZ1 is a string.
The final result of analysis placed in &a is XYZ1, which is a string.
Numbers and strings can look the same but are stored differently. In particular,
variables can hold values in several different forms at the same time. For example, the
result of the assignment statement &a = 005 is that &a holds a string of 005 and a
number of 5 at the same time.
However, if &a is used in an arithmetic expression—for example in the expression
&a = &a + 1—the result is 6, a number, not 006, a string. In addition, the string value
of 005 is deleted.