This pair of commands will loop a list of AMOS Professional statements forever, with DO acting as the marker position for the LOOP to return to. Both the DO and LOOP should occupy their own lines, as follows:
E> Do Print "FOREVER AND": Wait 25 Loop
EXIT
structure: break out of a loop
Exit
Exit number
EXIT forces the program to leave a loop immediately, and it can be used to escape from all the types of loop employed in AMOS Professional, such as FOR ... NEXT, REPEAT ... UNTIL, WHILE ... WEND and DO ... LOOP. Any number of loops may be nested inside of one another, and when used on its own, EXIT will short-circuit the innermost loop only. By including an optional number after EXIT, that number of nested loops will be taken into account before the EXIT is made, and the program will jump directly to the instruction immediately after the relevant loop.
For example:
E> Do Do Input "Type in a number";X Print "I am the inner loop" If X=1 Then Exit If X=2 Then Exit 2 Loop Print "I am the outer loop" Loop Print "And I am outside both loops!"
EXIT IF
structure: exit from a loop depending on a test
Exit If expression
Exit If expression,number
It is often necessary to leave a loop as a result of a specific set of conditions, and this can be simplified by using the EXIT IF instruction. As explained above, in conditional operations, the value -1 represents True, whereas a zero represents False. After using EXIT IF, an expression is given which consists of one or more tests in standard AMOS Professional format. The EXIT will only be performed IF the result is found to be -1 (True).