#149940 - 2005-10-28 05:07 PM
Re: Knowledge request
|
Sealeopard
KiX Master
Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
|
You have a 5x4 array like this: Code:
Name1 Option1 Option2 Option3 Option4 Name2 Option1 Option2 Option3 Option4 Name3 Option1 Option2 Option3 Option4 Name4 Option1 Option2 Option3 Option4 Name5 Option1 Option2 Option3 Option4 Name6 Option1 Option2 Option3 Option4
If you'd like to solve this as an array of arrays, then you have a options array $op[3] and a names array $nm[6,1] similar to this: Code:
Name1 $op Name2 $op Name3 $op Name4 $op Name5 $op Name6 $op
The code would look like this: Code:
dim $nm[5],$op[3] ; firts name $nm[0,0]='Name1' $op[0]=1 $op[1]=2 $op[2]=3 $op[3]=4 $nm[0,1]=$op
$nm[1,0]='Name2' $op[0]=1 $op[1]=2 $op[2]=3 $op[3]=4 $nm[1,1]=$op ; pull first name ? 'First Name = '+$nm[0,0] ? 'Options:' $options=$nm[0,1] ;pull the options array into it's own new variable for $optnr=0 to 3 ? 'Option '+$optnr+': '+$options[$optnr] ? 'Option '+$optnr+': '+$nm[0,1][$optnr] ;alternative way to reference the element next
Some people consider the array-of-arrays more elegant, however, it requres more care in pulling data.
Please be advised that this code is a figment of my imagination and has not undergone any testing whatsoever and might therefore not work. It is for illustration purposes only.
_________________________
There are two types of vessels, submarines and targets.
|
Top
|
|
|
|
#149941 - 2005-10-28 06:11 PM
Re: Knowledge request
|
Gargoyle
MM club member
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
|
Quote:
understand the basics of arrays
I agree and hence why I have most here shaking their head at me.
If I am understanding the explanation that Jens provided earlier..
For a 2 Dimension array...
Dim the array as follows Dim $Array[Rows,Columns] Once you declare the array you can not change the number of Rows but with a Redim you can change the number of columns.
In my particular use I would Code:
Dim $Array[$index,5] ;Where $index is the # of names that need to be tracked starting from 0
I would then be able to assign to $array[0,0] the name of the first user, $array[0,1] would be the first option, $array[0,2] ... $array[0,5] for the remaining options. Then I would repeat the process for each user moving to the next row $array[1,0] ....
So my data would end up looking like this.... Name1 Opt1 Opt2 Opt3 Opt4 Opt5 Name2 Opt1 Opt2 Opt3 Opt4 Opt5
This would then provide a 2 dimensional array instead of using an array of array's.
If this is a correct understanding of how it works, then I have at least moved a bit forward. Now 3 dimensions.... Well lets just wait for awhile, I don't see a need for them at this point in my script.
_________________________
Today is the tomorrow you worried about yesterday.
|
Top
|
|
|
|
#149942 - 2005-10-28 08:48 PM
Re: Knowledge request
|
Sealeopard
KiX Master
Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
|
Yes, that's exactly whay I tried to convey. Now, a 3-D array is just like a 2D-array, but younow add yet another layer/dimension to it. For exampel, space coordinates are 3-D, you need length, width, height, to descirbe a location/point. In case of a 4-D array, you could consider the fourth dimension beigntime, you now need to also describe the time from when you want toe element. Anyway, hope you get the gist of it.
_________________________
There are two types of vessels, submarines and targets.
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 153 anonymous users online.
|
|
|