Description
The IF instruction determines that an instruction or a group of instructions will only be executed if its related Boolean expression has the value 1 (true). If the condition is 0 (false), the instruction or the instruction group will not be executed.
The THEN
instruction
identifies the end of the condition and the beginning of the instruction(s).
The END_IF
instruction marks the end of the instruction(s).
IF...THEN...END_IF
instructions
may be nested to generate complex selection instructions.Example IF...THEN...END_IF
The condition can be expressed using a Boolean variable.
If FLAG
is 1, the instructions will be executed;
if FLAG
is 0, they will not be executed.
IF FLAG THEN
C:=SIN(A) * COS(B) ;
B:=C - A ;
END_IF ;
The condition can be expressed using an operation that returns a Boolean result.
If A
is greater
than B
, the instructions will be executed; if A
is less than or equal to B
, they will
not be executed.
IF A>B THEN
C:=SIN(A) * COS(B) ;
B:=C - A ;
END_IF ;
Example IF NOT...THEN...END_IF
The condition can be inverted using NOT
(execution of both instructions at 0).
IF NOT FLAG THEN
C:=SIN_REAL(A) * COS_REAL(B) ;
B:=C - A ;
END_IF ;