#169551 - 2006-10-18 11:39 AM
redim one two dimensional array question
|
mima
Hey THIS is FUN
Registered: 2002-01-25
Posts: 217
Loc: Jönköping, Sweden
|
Hi I have this code and it works fine.. Code:
Dim $Array[5,1]
$Array[0,0] = "A" $Array[1,0] = "B" $Array[2,0] = "C" $Array[3,0] = "D" $Array[4,0] = "E"
$Array[0,1] = "1" $Array[1,1] = "2" $Array[2,1] = "3" $Array[3,1] = "4" $Array[4,1] = "5"
$counter = 0 While $counter < Ubound($array) ? $array[$counter,0] ? $array[$counter,1] $counter = $counter + 1 Loop
Next step is to expand the size of the array with Redim Preserv. If I code like this it wont work. I get ERROR : array reference out of bounds!
Code:
ReDim preserve $Array[6,1]
|
|
Top
|
|
|
|
#169554 - 2006-10-18 01:26 PM
Re: redim one two dimensional array question
|
mima
Hey THIS is FUN
Registered: 2002-01-25
Posts: 217
Loc: Jönköping, Sweden
|
Ok Jochen, I understand now. Made this code and its working. Code:
Dim $Array[1,5]
$Array[0,0] = "A" $Array[0,1] = "B" $Array[0,2] = "C" $Array[0,3] = "D" $Array[0,4] = "E" $Array[0,5] = "F"
$Array[1,0] = "0" $Array[1,1] = "1" $Array[1,2] = "2" $Array[1,3] = "3" $Array[1,4] = "4" $Array[1,5] = "5"
$counter = 0 While $counter <= Ubound($array,2) ? $array[0,$counter] ? $array[1,$counter] $counter = $counter + 1 Loop ?
ReDim preserve $Array[1,Ubound($array,2)+1] $Array[0,6] = "G" $Array[1,6] = "6"
$counter = 0 While $counter <= Ubound($array,2) ? $array[0,$counter] ? $array[1,$counter] $counter = $counter + 1 Loop
|
|
Top
|
|
|
|
#169555 - 2006-10-18 02:50 PM
Re: redim one two dimensional array question
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
Quote:
I dont understand !!, cant I redim my $array[5,1] to $array[6,1] ?
one of the reasons why i like to do array stuffing...
Code:
dim $array[3]
$array[0] = 0,'a' $array[1] = 1,'a' $array[2] = 0,'b' $array[3] = 0,'c'
? $array[0][1]
redim preserve $array[4] $array[4] = 2,'a'
? $array[4][0] ? $array[4][1]
|
|
Top
|
|
|
|
#169556 - 2006-10-18 03:10 PM
Re: redim one two dimensional array question
|
mima
Hey THIS is FUN
Registered: 2002-01-25
Posts: 217
Loc: Jönköping, Sweden
|
It is a bit confusing, this multiarray thing 
What is the difference between Dim $array[1] $array[0] = 0,'a' and Dim $array[1,1] $array[0,0] = 0 $array[0,1] = "a"
|
|
Top
|
|
|
|
#169559 - 2006-10-18 05:41 PM
Re: redim one two dimensional array question
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
As Jochen says, an Array of Arrays is much easier for the brain to grab a hold of, and more flexible. In the most current ver of KFD I use an Array of Arrays of Arrays and that gets a little confusing, but man a great way of storing data.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|