Multidimensional Array


Posted by Gary on November 09, 2001 11:17 AM

I've got a sub (called "Turn") written to manipulate a single-dimensional array. Calling the sub is simply a matter of passing the array over to the sub. For example, if my array is called "Numbers", all I have to do is call it with a line that says:
Turn(Numbers)

So far, so good. The problem now is that I've got a 2-dimensional array, and I want to run it through the sub, 1 dimension at a time. For example, if the array is dimensioned as "Dim Numbers(1 to 3,1 to 25) as single", I then want to treat it as 3 one-dimensional arrays, each of which I want to run through my sub.

I thought that the following code would work:

For i=1 to 3
turn (Numbers(1,))
next i

Of course, it doesn't work -- apparently there's something wrong with my syntax. I've tried various alternatives, without luck.

Any help would be greatly appreciated. Thanks!

Posted by Barrie Davidson on November 09, 2001 11:41 AM

How about something like this:

For i=1 to 3
Numbers(i,1)
next i

Does this work for you?

Barrie
Barrie Davidson

Posted by Gary on November 09, 2001 11:48 AM

Thanks for the suggestion, but, no, I'm afraid that doesn't work. I assume it's treating "Numbers (i,1)" as a number, not an array, and the sub requires an array to be passed to it.

Do you have any other ideas?

Gary

Posted by Rick on November 09, 2001 12:02 PM

Why not make another array that holds the 3 arrays till the function is done, examlpe

Dim Numbers(1 to 3,1 to 25) as single
Dim tempNum(1 to 25) as single

For i = 1 to 3
for j = 1 to 25
tempNum(j) = Numbers(i, j)
next j
turn(tempNum)
for j = 1 to 25
numbers(i, j) = tempNum(j)
next j
next i



Posted by Barrie Davidson on November 09, 2001 12:14 PM

Sorry, I didn't interpret your message properly. How about this?

For i2=1 to 25
For i=1 to 3
turn (Numbers(i,i2))
next i
next i2


Regards,
BarrieBarrie Davidson