ex.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
EXIT Statement Example
                        Example                Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
' This example uses the EXIT statement to exit a variety of control-flow
' structures. A loop is continuously executed until you press any key.
' Once a key is pressed, the next EXIT statement that executes will cause
' the program to end.
 
' To try this example:
' 1. Choose New Project from the File menu
' 2. Copy the code example below to the code window
' 3. Press F5 to run the example
 
 DECLARE SUB ExitDemo ()
 CLS                               ' Clear the screen
 DO
     PRINT : PRINT "Entering/Reentering ExitDemo"
     ExitDemo
     SLEEP 1
 LOOP WHILE INKEY$ = ""
 PRINT "Exiting 'EXIT' example program"
 
 SUB ExitDemo ()
    DO
        FOR i% = 1 TO 1000
            Num% = INT(RND * 100)
            SELECT CASE Num%
                CASE 7
                    PRINT "Exiting For...Next Loop in ExitDemo SUB"
                    EXIT FOR
                CASE 29
                    PRINT "Exiting Do...Loop in ExitDemo SUB"
                    EXIT DO
                CASE 54
                    PRINT "Exiting ExitDemo SUB"
                    EXIT SUB
                CASE ELSE
            END SELECT
        NEXT i%
    LOOP
 END SUB