Xbasic

EXIT, EXIT FOR, EXIT FUNCTION, EXIT WHILE

Syntax

EXIT

EXIT FOR

EXIT FUNCTION

EXIT WHILE

Description

EXIT provides an alternative way to leave a loop or function construct before the NEXT, end FUNCTION, or end while statements are reached.

EXIT FOR is used to exit from a FOR loop and EXIT FUNCTION is used to exit from a FUNCTION body. See also END.

Example

This FOR loop will be exited when the maximum value ( max_val ) is exceeded.

max_val = 5
for i = 1 TO 10
    if (i > max_val) then
        exit for
    end if
next i
trace.writeln( str(i) )

See Also