IF OPERATOR

Back to:
index

This operator can select one of two alternative branches according to the result of some logical expression analyses.

Reserved words IF, THEN and ELSE of conditional operator put bounds to analysing logic expression and two operators, which are selected in dependence if expression TRUE or FALSE.

Condition analysis compiling is described on special page.

Examples and operator structure

"E97" code examples

Intel code examples


Examples and operator structure

Typical examples of conditional operator, available in "COMPAS":

  • IF a = 1 THEN s:=1 ELSE s:=0;
  • IF a = 1 THEN s:=1;
  • IF a = 1 THEN BEGIN s:=1; q:=s+1 END ELSE BEGIN s:=0; q:=0 END;
  • IF c < ' ' THEN c:=CHR(0);
  • IF b THEN w:=w-1;

Possible structures of this operator can be written the following way:

IF {condition} THEN {operator1} ELSE {operator2} ;

IF {condition} THEN {operator1} ;

IF {BOOLEAN variable} THEN {operator1} ELSE {operator2} ;

IF {BOOLEAN variable} THEN {operator1} ;

Note, that instead of {operator1} and {operator2} several operators, confined between reserved words BEGIN and END - so called compound statement - can be used..

The scheme of full IF operator compilation is set below:
full IF scheme
And the short variant of the operator (without ELSE):
short IF scheme



Back to:
index top E97 Intel