BB___EXIT

=EXIT= toc

Description
> This command is used to exit a loop or procedure before its real end.

Syntax

 * 1) EXIT FOR
 * 2) EXIT WHILE
 * 3) EXIT DO
 * 4) EXIT FUNCTION
 * 5) EXIT SUB

Hints
> There are examples, then exiting loops (FOR, DO, WHILE) improperly (that is, with GOTO) corrupts JB stack, leading to unexpected behavior. > Exit function/exit sub provides a nice way to finish long muli-step check then one step is failed. See example.

Example
code format="vbnet" NOTE: Also see individual commands under Looping and Procedures for examples. code

Example: using exit function to abort long multi-step check. code format="lb" data "00:00" data "1:23" data "12:34" data "100:00" data ":00" data "1:00" data "1:0" data "1:-0" data "1:-1" data "1a:2b" data "a:bc" data "25:00" data "21:60" data "***"

read t$ while t$ <>"***" print t$, tminutes$(t$) read t$ wend

end

function tminutes$(tpoint$) 'Find total minutes from strict HH:MM input 'strict format check 'returns "InvalidTime" for wrong input tminutes$="InvalidTime"   'assume exit function will show fail 'hours hh$=trim$(word$(tpoint$, 1, ":")) 'check lengths if len(hh$)>2 then exit function 'check numbers if instr("0123456789", mid$(hh$,1,1))=0 then exit function if len(hh$)>1 then if instr("0123456789", mid$(hh$,2,1))=0 then exit function end if   'check range hh=val(hh$) if hh>23 then exit function

'same for minutes mm$=word$(tpoint$, 2, ":") if len(mm$)<>2 then exit function if instr("0123456789", mid$(mm$,1,1))=0 then exit function if instr("0123456789", mid$(mm$,2,1))=0 then exit function mm=val(word$(tpoint$, 2, ":")) if mm>59 then exit function

'if we got here, that means all OK   tminutes$=str$(hh*60+mm) end function code

Useful Functions
code format="lb" Place a useful function using this command here code