IF / ELSE / ENDIF Constructs

The IF, ELSE and ENDIF constructs allow different control cards to be used under certain conditions.

The syntax requirements of IF / ELSE / ENDIF constructs are as follows:

  • The !! characters must be in the first two columns of the line. This is followed by an arbitrary number of spaces, the keyword IF, the expression to be evaluated and the keyword THEN.
    Note: Keywords are case insensitive, for example, Then or then are also valid
  • The block is terminated by a line of the form !!ENDIF (again spaces are allowed between !! and ENDIF but not before the !!).
  • An optional line of the form !!ELSE (the !! must be in the first two columns and spaces are allowed before the keyword, which is not case sensitive).
  • All instructions and input cards between !!IF and !!ENDIF (or !!ELSE if it is present) are processed if the expression is TRUE. If it is present, all lines between !!ELSE and !!ENDIF are processed if the expression is FALSE.
    As an example:
    !!if #a > 5 then
    ...
    !!endif
    Another example is as follows:
    #l = (#a+5 > 21) and (#a < 100)
    !!if ( (3*#a+5 >= #x/2) and not(#l) ) then
    ...
    !!else
    !! if (sin(#x/10) > 0.5) then
    ...
    !! else
    ...
    !! endif
    !!endif