Hi,
Could anyone please explain me escape top and bottom with clear example.
I know its in documentation but still explanation with example would be very helpful for me. Thankyou.
Hi,
Could anyone please explain me escape top and bottom with clear example.
I know its in documentation but still explanation with example would be very helpful for me. Thankyou.
DEFINE DATA LOCAL
1 COUNTER (I4)
1 BUTTON (A1)
END-DEFINE
*
FOR COUNTER = 1 TO 10
IF COUNTER = 5
PRINT 'Continue loop at the top...'
ESCAPE TOP
END-IF
PRINT 'your counter is now:' COUNTER
IF COUNTER = 8
BUTTON := "N"
INPUT 'Do you want to stop? (Y/N)' BUTTON (AD=MT)
IF BUTTON = "Y"
PRINT 'Ok - I stop it.'
ESCAPE BOTTOM
END-IF
END-IF
END-FOR
*
PRINT 'It"s all over. Counter is now:' COUNTER
END
Thankyou for this good example.
Thankyou for this good example.
ESCAPE BOTTOM IMMEDIATE is like a GO TO the statement after the end of a loop. By contrast, ESCAPE BOTTOM, all by itself (no IMMEDIATE) is not quite the same (except for REPEAT and FOR loops). With READ and FIND loops, ESCAPE BOTTOM first “finishes up” a loop before leaving the loop.
“Finishing up” a loop includes doing AT END OF DATA clauses, AT BREAK clauses, etc.
ESCAPE TOP is something of a misnomer; it does not “escape” a loop at all; it merely ends an iteration of the loop. I have met many programmers who thought it transferred control to the statement before a loop; not true. Functionally, ESCAPE TOP is basically identical to ACCEPT/REJECT statements.
steve
… sorry wrong posting …