#81369 - 2002-11-24 06:19 PM
For Each with STEP
|
Raj
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
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.
|
|
Top
|
|
|
|
#81371 - 2002-11-24 06:29 PM
Re: For Each with STEP
|
Raj
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?
Thanks, /*Raj*/ [ 24. November 2002, 18:31: Message edited by: Raj ]
|
|
Top
|
|
|
|
#81373 - 2002-11-25 07:44 PM
Re: For Each with STEP
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
how about a where clause...
for each $item in $array where $item<>"" ? $item next
|
|
Top
|
|
|
|
#81375 - 2002-11-25 08:02 PM
Re: For Each with STEP
|
Radimus
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...
|
|
Top
|
|
|
|
#81378 - 2002-12-07 11:12 AM
Re: For Each with STEP
|
MCA
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 ]
|
|
Top
|
|
|
|
Moderator: Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
1 registered
(mole)
and 1300 anonymous users online.
|
|
|