#80034 - 2001-04-25 09:35 PM
We desperately need an ExitFor statement
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
We're going to "need" an ExitFor statement sooner or later !Just thought I'd just mention this sooner, than later! Anyone have any "clean" workarounds in the meantime (apart from gotos). Artificially bumping-up the index inside the for-next works: code:
break on for $i=1 to 10 ?"i=$i" if $i=5 $i=11 endif next exit
Shawn.
[This message has been edited by Shawn (edited 25 April 2001).]
|
Top
|
|
|
|
#80038 - 2001-04-27 06:25 PM
Re: We desperately need an ExitFor statement
|
Anonymous
Anonymous
Unregistered
|
Thanks, I look into EXITFOR.For now, GOTO can also be used to leave a FOR-NEXT loop. Ruud
|
Top
|
|
|
|
#80039 - 2001-04-30 01:39 PM
Re: We desperately need an ExitFor statement
|
Anonymous
Anonymous
Unregistered
|
Ruud, Is there a risk of a stack overflow, or similar problem, when using GOTO to exit the loop?
|
Top
|
|
|
|
#80040 - 2001-05-01 03:39 PM
Re: We desperately need an ExitFor statement
|
Anonymous
Anonymous
Unregistered
|
I have used 2 commands in other languages called LEAVE and ITERATE that operate in all loop structures (eg DO UNTIL, WHILE LOOP, FOR NEXT and FOR EACH NEXT) LEAVE exits the innermost executing loop, ITERATE goes to the end of the loop (ie the UNTIL, LOOP, NEXT command).
|
Top
|
|
|
|
#80041 - 2001-05-01 05:59 PM
Re: We desperately need an ExitFor statement
|
Anonymous
Anonymous
Unregistered
|
On the question regarding the risk of stack over-/underflow as a result of GOTO'ing out of a loop: no, this is handled by the KiXtart interpreter.Regards, Ruud
|
Top
|
|
|
|
#80042 - 2006-04-07 09:56 AM
Re: We desperately need an ExitFor statement
|
Biro
Fresh Scripter
Registered: 2006-04-07
Posts: 7
Loc: NSW, Australia
|
I so agree with the sentiment of this request. (hope ive posted correctly)
Perhaps my logic was floored but I have found that using a GOTO to exit a loop within a nested loop, it has troubles from having a :Label within that loop. Either way is messy compared to a proper exit command.
I think EXIT should behave differently 'except' that this could really mess with backward compatibility for anyone maintaining scripts written in the past which would be expecting EXIT to exit.
So something else to do it would make more sense?
|
Top
|
|
|
|
Moderator: Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
0 registered
and 323 anonymous users online.
|
|
|