Compaq AA-PWCBD-TE Computer Accessories User Manual


 
Lexical Elements of the DEC Text Processing Utility Language
4.9 Reserved Words
The ENDIF statement specifies the end of a conditional statement.
Syntax
IF expression THEN statement_1; . . . statement_n [[ELSE alternate-statement_
1;
. . . alternate-statement_n;]] ENDIF;
You can use any DECTPU language statements except ON_ERROR statements in
a THEN or ELSE clause. For example:
PROCEDURE set_direct
MESSAGE ("Press PF3 or PF4 to indicate direction");
temp_char := READ_KEY;
IF temp_char = KP5
THEN
SET (REVERSE, CURRENT_BUFFER);
ELSE
IF temp_char = KP4
THEN
SET (FORWARD, CURRENT_BUFFER);
ENDIF;
ENDIF;
ENDPROCEDURE;
In this example, nested IF/THEN/ELSE statements test whether a buffer
direction should be forward or reverse.
Caution
Do not assume that the DECTPU compiler automatically evaluates all
parts of an IF statement.
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
all clauses of a conditional statement, you should force the compiler to evaluate
each clause before using the conditional statement. To do so, use each clause in
an assignment statement before using it in a conditional statement. For example,
suppose you want the compiler to evaluate both CLAUSE_1 and CLAUSE_2 in a
conditional statement. To get this result, you could use the following code:
relation_1 := clause_1;
relation_2 := clause_2;
IF relation_1 AND relation_2
THEN
.
.
.
ENDIF;
4.9.4.13 Case Statement
The CASE statement is a selection control structure that lets you list several
alternate actions and choose one of them to be executed at run time. In a CASE
statement, case labels are associated with the possible executable statements or
actions to be performed. The CASE statement then executes the statement or
statements labeled with a value that matches the value of the case selector.
Lexical Elements of the DEC Text Processing Utility Language 4–21