Petr Schreiber
29-05-2007, 08:05
Hi,
some EXIT statement sample:
uses "Console"
dim i as long
' -- Classic usage of jumping out of DO/LOOP
Console_WriteLine "DO / LOOP exit:"
DO
incr i
Console_WriteLine "DO -> (i="+FORMAT$(i)+")"
if i = 7 then exit do
Console_WriteLine "LOOP <-"
LOOP
Console_WriteLine "DO / LOOP exit ended..."
Console_WriteLine "Press ENTER to continue..."
Console_ReadLine
' -- Advanced jump from higher level loop
Console_WriteLine "DO / LOOP exit from nested FOR/NEXT:"
do
Console_WriteLine "DO ->"
for i = 1 to 10
Console_WriteLine "FOR/NEXT i="+FORMAT$(i)
if i = 5 then exit do ' -- We are in FOR/NEXT block, but we can jump out from the DO/LOOP here too !
next
Console_WriteLine "LOOP <-" ' -- This line will never be executed
loop
Console_WriteLine "DO / LOOP exit from nested FOR/NEXT ended..."
Console_WriteLine "Press ENTER to quit..."
Console_ReadLine
Bye,
Petr
some EXIT statement sample:
uses "Console"
dim i as long
' -- Classic usage of jumping out of DO/LOOP
Console_WriteLine "DO / LOOP exit:"
DO
incr i
Console_WriteLine "DO -> (i="+FORMAT$(i)+")"
if i = 7 then exit do
Console_WriteLine "LOOP <-"
LOOP
Console_WriteLine "DO / LOOP exit ended..."
Console_WriteLine "Press ENTER to continue..."
Console_ReadLine
' -- Advanced jump from higher level loop
Console_WriteLine "DO / LOOP exit from nested FOR/NEXT:"
do
Console_WriteLine "DO ->"
for i = 1 to 10
Console_WriteLine "FOR/NEXT i="+FORMAT$(i)
if i = 5 then exit do ' -- We are in FOR/NEXT block, but we can jump out from the DO/LOOP here too !
next
Console_WriteLine "LOOP <-" ' -- This line will never be executed
loop
Console_WriteLine "DO / LOOP exit from nested FOR/NEXT ended..."
Console_WriteLine "Press ENTER to quit..."
Console_ReadLine
Bye,
Petr