Page 2 of 2 <12
Topic Options
#149939 - 2005-10-28 03:23 PM Re: Knowledge request
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Quote:

describe for us exactly what it is you are trying to do



I have form that asks the user to enter a series of names from 2 - 6, the number of names is random and could change everytime the script is used.
After that form information is submitted I am storing the names in an array $Names[5]
I then present another form that has options on it. On the options page there are 4 sets of radio buttons where each will represent a single value to be stored. One set of checkboxes that will result in a single value to be stored.

The options that are checked will be individual to each of the users set in the first form.

My thought was that an array that is 6x5 would be perfect for this as I would have a single array that would hold the user name and the options selected per user.

Hope that helps.

The cube analogy is helping. I will be drawing it out on paper to make sure that I am getting it. To this point in all of my scripts I have alway's used a flat array (1 dimension).
_________________________
Today is the tomorrow you worried about yesterday.

Top
#149940 - 2005-10-28 05:07 PM Re: Knowledge request
Sealeopard Offline
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 Offline
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 Offline
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
#149943 - 2005-10-28 08:57 PM Re: Knowledge request
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Thank you. I think the problem was my mixing up Array of Array's and MultiDim.

Once I looked at MultiDim like a database record it all made sense.

I really appreciate everyones understanding in this.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#149944 - 2005-10-29 09:19 PM Re: Knowledge request
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
A database table is still two-dimensional, In my book, multi-dimensional starts when you go boyond two dimensions.

Now, an OLAP cube in the data warehouse world, that's where the fun starts
_________________________
There are two types of vessels, submarines and targets.

Top
#149945 - 2005-10-29 11:38 PM Re: Knowledge request
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
two dimensional is a multi-dimensional as in my book multi counts for everything else than single.
_________________________
!

download KiXnet

Top
#149946 - 2005-10-30 01:06 PM Re: Knowledge request
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Quote from http://www.yourdictionary.com/ahd/m/m0473300.html

Quote:


mul·ti·di·men·sion·al

Of, relating to, or having several dimensions.





Two is several so imho two dimensions is also multidimensional.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#149947 - 2005-10-30 02:24 PM Re: Knowledge request
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You obviously did not look up "several".
Quote:

Being of a number more than two or three but not many




http://www.yourdictionary.com/ahd/s/s0296200.html
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#149948 - 2005-10-30 05:36 PM Re: Knowledge request
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
And to go back to the topic for just a second....

When using an array ex: [3,5], if you do a Ubound($array) What value would be returned.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#149949 - 2005-10-30 07:52 PM Re: Knowledge request
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
I think manual says it...
it was the right most, or was it left most... hard to remember.
_________________________
!

download KiXnet

Top
#149950 - 2005-10-30 11:02 PM Re: Knowledge request
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Again you are correct

Quote:

UBOUND(array,dimension)
....
Dimesion
Optional parameter indicating the dimension of the array you want to know the upper boundray of. The default is 1.




So I geuss I would need to ask is it 0 based? With the default being 1 I would say not, but never hurts to ask.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#149951 - 2005-10-30 11:59 PM Re: Knowledge request
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
try it out

logic indeed dictates that it would be from 1 up.
first dimension and so on, right?

on the other hand, with that logic array element 0 wouldn't exist.
_________________________
!

download KiXnet

Top
#149952 - 2005-10-31 04:26 AM Re: Knowledge request
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
I have coded it that way (with a 1 for the first dimension) but have not completed enough code to test it really.

Maybe by tomorrow.
_________________________
Today is the tomorrow you worried about yesterday.

Top
Page 2 of 2 <12


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

Who's Online
1 registered (Allen) and 466 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.065 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org