Page 1 of 1 1
Topic Options
#19374 - 2002-04-02 10:58 PM For Next
wmclachlin Offline
Fresh Scripter

Registered: 2002-03-14
Posts: 5
Loc: Niagara Region
What would the 'C' equiv to the break command be in Kix? I need a nice way of breaking out of a for loop without killing the current count.

ie)
code:
For $x = 0 to 12
if (decIP >= ipmin[x]) AND (decIP < ipmax[x])
break;
endif
Next

Thanks,

[ 04 April 2002, 15:25: Message edited by: wmclachlin ]
_________________________
Wes

Top
#19375 - 2002-04-02 11:24 PM Re: For Next
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
in this case $x=13
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#19376 - 2002-04-02 11:38 PM Re: For Next
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well... that is the most elegant way of getting out of the loop but...

Unfortunately does not meet the customer's requirement to save the current count.

So with (or without) your permission, will modify:

$current = $X
$X = 13
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#19377 - 2002-04-02 11:51 PM Re: For Next
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
This also works. Would you consider this poor coding?
code:
 For $x = 0 to 12
? $x
if ($x = 9)
Goto "LoopExit"
endif
Next
:LoopExit
? "exit loop"

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#19378 - 2002-04-03 12:59 AM Re: For Next
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Why not this:
code:
$x=0
WHILE $x<=12 AND NOT (decIP=>ipmin[x] AND decIP<ipmax[x])
$x=$x+1
' do stuff
LOOP

Okay, it doesn't use a FOR loop but it's elegant [Wink]

[ 03 April 2002, 01:00: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#19379 - 2002-04-03 01:27 AM Re: For Next
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well.. I was nearly hung, shot, and pissed on for suggesting a GOTO out of a loop.

Exit a While Loop
Kixtart - enhancement for RETURN command

I did however get a reprieve from Ruud.

We desperately need an ExitFor statement

[ 03 April 2002, 01:33: Message edited by: LLigetfa ]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#19380 - 2002-04-04 03:18 PM Re: For Next
wmclachlin Offline
Fresh Scripter

Registered: 2002-03-14
Posts: 5
Loc: Niagara Region
Thanks ppl for the assistance. Think I'll go with the while loop. Seems to kill two birds with one stone. [Smile]

Thanks,
_________________________
Wes

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 884 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.056 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org