• Description:
    LOOP is the infinite loop, it means that everything between the LOOP and ENDLOOP keywords will repeat until RETURN, EXIT or EXITIF keywords are processed.

  • Syntaxes:
    Infinite loops:
      LOOP
        <statements>
      ENDLOOP
    
      LOOP DO <statements> // see DO keyword
    

    Loops repeated <exp> times:
      LOOP <exp>
        <statements>
      ENDLOOP
    
      LOOP <exp> DO <statements> // see DO keyword
    

    where <exp> can be constant, expression, etc.

  • Returning values:
      a:=LOOP
         EXITIF <exp> IS <texp> // see EXITIF
         ENDLOOP
    

    Loop is repeated until <exp> is TRUE and then is <texp> copied to a. You can also return multiple return values.

  • Examples:
    This will write 'Hello' ten times:
      LOOP 10
        PrintF('Hello\n')
      ENDLOOP
    
      LOOP a:=5
        PrintF('Hello(\d)\n',a)
      ENDLOOP
    

    This will write:
      Hello(5)
      Hello(4)
      Hello(3)
      Hello(2)
      Hello(1)