Repeat Readln sLine If (sLine="") Break Send ProcessLine sLine Until (SeqEof)
Repeat Readln sLine If (sLine="") Begin Send DoSomeCleanup Break End Send ProcessLine sLine // It will execute even after "break" is executed. Until (SeqEof)
Use UI Integer i For i From 1 to 5 If (i=3) Break Begin Showln i Loop InKey i
Use UI Integer i For i From 1 to 5 If (i=3) Begin Break Begin End Showln i Loop InKey i
There have been many debates on the DAW forum/newsgroup regarding whether this should be the correct/desired behavior. Regardless whether it is correct/desired, it's too late to change it now since changing the functionality of "break" now can potentially break a lot of existing code. So, what should we do?
Some DAW forum members have proposed creating a new command specifically for breaking out loop. I would agree. Unfortunately I started programming in VDF version 7.3, and the only knowledge I have on creating commands is from reading FMAC. DAW still hasn't created such command in all these years of the existence of DF/VDF/DF, chances are that nothing will be done in this regard in the foreseeable future. Well, time to brush up my FMAC skill and attempt on creating command to break out of a loop instead of breaking out from the current scope.
#COMMAND BREAKLOOP #IF !0=0 #POP S$ #PUSH !s #ENDIF #IFDEF WHILE$!s Goto END$!s #ELSE #IFDEF WHILE#!s Goto END$!s #ELSE #SET S$ !s-1 BREAKLOOP !s #ENDIF #ENDIF #ENDCOMMAND #COMMAND CONTINUELOOP #IF !0=0 #POP S$ #PUSH !s #ENDIF #IFDEF WHILE$!s Goto BEGIN$!s #ELSE #IFDEF WHILE#!s Goto BEGIN$!s #ELSE #SET S$ !s-1 CONTINUELOOP !s #ENDIF #ENDIF #ENDCOMMAND
Integer i j If (True) Begin For i From 0 to 10 If (True) Begin Repeat If (True) Begin If (True) Begin For J From 0 to 100 If (True) Begin Showln "Breaking While" BreakLoop End Showln "Error:While" Loop Showln "Breaking Repeat" BreakLoop End Showln "Error:Repeat" End Until (False) Showln "Breaking For" BreakLoop End Showln "Error For" Loop Showln "Yes" End InKey i