Hi,
some EXIT statement sample:
[code=thinbasic]
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
[/code]
Bye,
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Got it.
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Bookmarks