Re: Passing multi-dimensional arrays to functions



I think the problem is solved.

An "unset" command was in the wrong place - in the loop I had. That was
clearing the first dimension.




-----
Otie




"Otie" <otie_nospam@xxxxxxxxxxxx> wrote in message
news:1-adnTgcRM2XWrrZRVn-gA@xxxxxxxxxxxxxxx
Please help, someone.

I have a multi-dimensional array called $longitude. It is 2 x 5 elements
defined as:

$longitude[0][0] = "1";
$longitude[0][1] = "2";
$longitude[0][2] = "3";
$longitude[0][3] = "4";
$longitude[0][4] = "5";
$longitude[1][0] = "6";
$longitude[1][1] = "7";
$longitude[1][2] = "8";
$longitude[1][3] = "9";
$longitude[1][4] = "10";

Why does the following function call only pass the values for the second
element to the function - in other words, 6, 7, 8, 9, or 10?

When I try to read $longitude[0][1] or anything in that first dimension, I
get nothing.


function call:
$num = GetCoordinates($longitude);


Function GetCoordinates($longitude)
{
$nums = 0;

for ($y = 0; $y <= 4; $y++)
{

$sy = $longitude[0][$y]; //$longitude[0][$y] always reads
nothing

for ($x = 0; $x <= 4; $x++)
{
$sx = $longitude[1][$x] //$longitude[1][$x] always pulls the
right value

$nums++;
}
}

return $nums;
}



Thank you.


Otis



.



Relevant Pages

  • Re: count occurences of font color
    ... Dim num As Long, res As Long ... Debug.Print Timer - s ... ' using isnull and not using characters ... as the loop will exit on the first character. ...
    (microsoft.public.excel.programming)
  • Interesting behaviour with lexical variable
    ... use warnings; ... I found out that once the loop get executed for the second ... sub main { ... Variable "$num" will not stay shared at x.pl line 11. ...
    (comp.lang.perl.misc)
  • Re: count occurences of font color
    ... Dim num As Long, res As Long ... Debug.Print Timer - s ... ' using isnull and not using characters ... as the loop will exit on the first character. ...
    (microsoft.public.excel.programming)
  • Re: WHILE LOOP NOT WORKING IN INCLUDE ASP FILE - LOOPING FOREVER
    ... I have an issue with the while loop in include file. ... I see that the ONLY field you are using is the NUM ... Change the query ... provided by the recordset, Bottom line: you do not need a cursor. ...
    (microsoft.public.data.ado)
  • Re: threads question
    ... loop) before process 2 ever gets started. ... i is already equal to 5 so the while loop never executes and num ... time slice is up and process 1 runs again. ... Mr. Bazarov points out, C++ has no help for you. ...
    (comp.lang.cpp)