Page 1 of 1 1
Topic Options
#137036 - 2005-04-03 06:47 PM Array question
supermanzdead Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 50
I have an array I am pulling information from, i'd like to know how to add items to another array while in the for each loop, example

Code:

For Each $item in $array
do something that produces an error code
If @Error <> 0
Add item to bad items array
Else
Add item to good items array
EndIf
Next




Does that make sense?
_________________________
~Mwah

Top
#137037 - 2005-04-03 07:04 PM Re: Array question
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You need to maintain an index of the second array and dim/redim it as needed.
Code:

dim $BadItemsArray[10]
$BIAindex=0
For Each $item in $array
;do something that produces an error code
If @Error <> 0
$BadItemsArray[$BIAindex]=$item ;Add item to bad items array
$BIAindex=$BIAindex+1 ;check UBound here to ReDim
Else
Add item to good items array
EndIf
Next


_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#137038 - 2005-04-03 07:15 PM Re: Array question
supermanzdead Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 50
excellent, I had something close but I kept botching it up, thanks for the assistance
_________________________
~Mwah

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 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.161 seconds in which 0.102 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