IF

Basic form

IF logexp.

Effect

Used for case distinction.

Depending on whether the logical expression logexp is true or not, this statement triggers the execution of various sections of code enclosed by IF and ENDIF.

There are three different types:

  1. IF logexp.
      processing1
    ENDIF.


    If the logical expression is true, processing1 is executed. Otherwise, the program resumes immediately after ENDIF.


  2. IF logexp.
    processing1
    ELSE.
    processing2
    ENDIF.


    If the logical expression is true, processing1 is executed. Otherwise, processing2 is executed (see ELSE).


  3. IF logexp1.
    processing1
    ELSEIF logexp2.
    processing2
    ELSEIF ...
    ...
    ELSE.
    processingN
    ENDIF.


    If the logexp1 is false, logexp2 is evaluated and so on. You can use any number of ELSEIF statements. If an ELSE statement exists, it always appears after all the ELSEIF statements.


Notes

  1. All IF statements must be concluded in the same processing block by ENDIF.


  2. IF statements can be nested as many times as you like.


  3. The IF statement does not directly affect the selection. For this purpose, you should use the CHECK statement.


Additional help

Conditional Jumps