Compaq AA-PWCBD-TE Computer Accessories User Manual


 
Lexical Elements of the DEC Text Processing Utility Language
4.8 Expressions
You can mix data types when using the not equal (<>) and equal ( = )
relational operators.
You can mix strings and integers when doing string replication.
Except for these cases, DECTPU does not perform implicit type conversions to
allow for the mixing of data types within an expression. If you mix data types,
DECTPU issues an error message.
In the following example, the elements (J > 4) and (my_string =
"this is my
string
") each evaluate to an integer type (odd integers are true; even integers are
false) so that they can be used following the DECTPU IF statement:
IF (J > 4) AND (my_string = "this is my string")
THEN
.
.
.
With the exception of patterns and the relational operators, the result of an
expression is the same data type as the elements that make up the expression.
The following example shows a pattern expression that uses a string data type on
the right-hand side of the expression. The LINE_BEGIN and REMAIN pattern
keywords are used with the string constant "the" to create a pattern data type
that is stored in the variable pat1:
pat1 := LINE_BEGIN + "the" + REMAIN;
Whenever possible, the DECTPU compiler evaluates constant expressions at
compile time. DECTPU built-in procedures that can return a constant value
given constant input are evaluated at compile time.
In the following example, the variable fubar has a single string assigned to it:
fubar := ASCII (27) + "[0m";
Note
Do not assume that the DECTPU compiler automatically evaluates an
expression in left-to-right order.
To avoid the need to rewrite code, you should write as if this compiler
optimization were already implemented. If you need the compiler to evaluate an
expression in a particular order, you should force the compiler to evaluate each
operand in order before using the expression. To do so, use each operand in an
assignment statement before using it in an expression. For example, suppose you
want to use ROUTINE_1 and ROUTINE_2 in an expression.
Suppose, too, that ROUTINE_1 must be evaluated first because it prompts for
user input. To get this result, you could use the following code:
PARTIAL_1 := ROUTINE_1;
PARTIAL_2 := ROUTINE_2;
You could then use a statement in which the order of evaluation was important,
such as the following:
IF PARTIAL_1 OR PARTIAL_2
.
.
.
Lexical Elements of the DEC Text Processing Utility Language 4–9