Page 1 of 1 1
Topic Options
#81369 - 2002-11-24 06:19 PM For Each with STEP
Raj Offline
Fresh Scripter

Registered: 2002-11-24
Posts: 8
Loc: Atlanta, GA, USA
Probably a simple request... It would be nice to have the For Each command have a STEP option like the For Next command:

code:
For Each $item in $array step 2
? item
Next

Thanks!
/*Raj*/

Top
#81370 - 2002-11-24 06:23 PM Re: For Each with STEP
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
You can
code:
for $i=0 to ubound($Groups) Step 2
? "Group = " + $Groups[$i] + " Desc = " + $Groups[$i+1]
next

where $Groups is an array.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#81371 - 2002-11-24 06:29 PM Re: For Each with STEP
Raj Offline
Fresh Scripter

Registered: 2002-11-24
Posts: 8
Loc: Atlanta, GA, USA
I see what you did and it make sense... but which code looks cleaner? [Cool]

Thanks,
/*Raj*/

[ 24. November 2002, 18:31: Message edited by: Raj ]

Top
#81372 - 2002-11-25 07:15 PM Re: For Each with STEP
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
If you put a STEP into a FOR EACH then it wouldn't be an EACH anymore [Wink]

I have to agree with Howards, suggestion though.
_________________________
There are two types of vessels, submarines and targets.

Top
#81373 - 2002-11-25 07:44 PM Re: For Each with STEP
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
how about a where clause...

for each $item in $array where $item<>""
? $item
next
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#81374 - 2002-11-25 08:01 PM Re: For Each with STEP
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
code:
for each $item in $array if $item<>""
? $item
endif next



[ 25. November 2002, 20:01: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#81375 - 2002-11-25 08:02 PM Re: For Each with STEP
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
just because you put it on the same line, doesn't make it any better... [Smile]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#81376 - 2002-11-25 08:04 PM Re: For Each with STEP
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Damn, I thought you wouldn't notice [Big Grin]
_________________________
There are two types of vessels, submarines and targets.

Top
#81377 - 2002-11-25 09:52 PM Re: For Each with STEP
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
it should be keepen off from there anyway.
making kix parser look for additional switch just makes it slow down the normal loops which do not have that.
_________________________
!

download KiXnet

Top
#81378 - 2002-12-07 11:12 AM Re: For Each with STEP
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

We doesn't support this issue too. When a 'array' contains a random structure: what is
the meaning for skipping (= stepping) items.
Also keyword each becomes meaningless. We prefer the solution of Howard, which
makes your request possible.

We like always new functions, macros and commands which can reduce the amount of tricks
and code dramatically and which can reduce usage of f.e. external tools to do the job.
Also interesting when as scripter it isn't possible. Some
examples
- Command line parameters
- KIX-MACRO: get actual setting of function RedirectOutput by macro "@redirectoutput"

greetings.

[ 07. December 2002, 11:27: Message edited by: MCA ]
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
Page 1 of 1 1


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

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.176 seconds in which 0.124 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