• Syntax:
    IF-statement syntax can be quite variable. Here follows single and multiple line syntaxes.
      IF <exp> THEN <statement> [ ELSE <statement> ]
    
      IF <exp>
        <statements>
      [ ELSEIF <exp>
        <statements> ]    // multiple ELSEIFs may occur
      [ ELSE
        <statements> ]
      ENDIF
    
      IF <exp>       <statement>
      [ ELSEIF <exp> <statement> ]    // multiple ELSEIFs may occur
      ELSE           <statement>
    

    Multiple-line syntaxes (last two above) can be combined. Single statement can be replaced be DO keyword. If you use DO keyword after ELSE keyword, you mustn't use ENDIF keyword:
      IF <exp>     [ DO <statements> ]
      ELSEIF <exp> [ DO <statements> ]
      ELSE           DO <statements>
    

    When using multiple line syntax, you can use also single-line ELSE definition, which shorts down source length. This definition leaves ENDIF keyword:
      IF <exp>
        <statements>
      [ ELSEIF <exp>
        <statements> ]    // multiple ELSEIFs may occur
      ELSE <statement>
    

  • Negated condition:
    If You add 'N' after IF or ELSEIF, the result of contition will be negated:
      IF a>b
      IF a=NIL
    

    is the same as:
      IFN a<=b
      IFN a
    

  • Returning values:
      a:=IF <exp> THEN <texp> ELSE <fexp>
    
      a:=IF <exp>
           <statements>
           EXIT <texp>
         [ ELSEIF <exp>
           <statements>
           EXIT <eexp> ]    // multiple ELSEIFs may occur
         ELSE
           <statements>
           EXIT <fexp>
         ENDIF
    
      a:=IF <exp>       <texp>
         [ ELSEIF <exp> <eexp> ]    // multiple ELSEIFs may occur
         ELSE           <fexp>
    

    IF <exp> is TRUE, a will contain <texp> else a will contain <fexp>. If ELSEIF <exp> is TRUE, a will contain <eexp>. You can also return multiple values. See EXIT keyword for more information.

  • Examples:
      IF age<10 PrintF('Too young!\n')
      ELSEIF age<70
        PrintF('Well, your age is acceptable.\n')
        ok:=TRUE
      ELSE DO PrintF('Too old!\n'); ok:=FALSE