getting count of array with non-integer index

Jan Schenkel janschenkel at yahoo.com
Sat Aug 10 03:03:01 EDT 2002


Hi Trevor,

As you haven't gotten a reply yet on the list, I
figured I'd have a stab at it :-)

First of all, you are setting up the arrays correctly,
so no worries there.

To answer your second question, you have a few
options, depending on the circumstances.

1) If the second dimension is fixed (always NN
elements), you can suffice by saying:
  put (the number of lines of the keys of tArray / NN)

2) If however NN is variable, you can get it with the
following trick:
  put the keys of tArray into tKeys
  split tKeys using return and comma
  put the number of lines of the keys of tKeys

I know it looks convoluted, but it works, even if the
second dimension varies.

Best regards,

Jan Schenkel.

"As we grow older, we grow both wiser and more foolish
at the same time."  (De Rochefoucald)

--- Trevor DeVore <trevor at mangomultimedia.com> wrote:
> Hi,
> 
> I have an array created from a db query that looks
> similar to this:
> 
> array[1,"RecID"]
> array[1,"Name"]
> array[2,"RecID"]
> array[2,"Name"]
> array[3,"RecID"]
> array[3,"Name"]
> 
> I want to loop through these results but have been
> unable to find a way to determine how many elements
> are in the first dimension of the array.  I saw the
> extents function but that only works with numeric
> keys.  I would like to keep the non-numeric keys if
> possible in order to make my code more readable.
> 
> So my questions are 1) Am I setting up arrays
> correctly in transcript and 2) If so, how do I get
> the count of the first dimension for looping
> purposes?
> 
> Thanks,
> 
> Trevor DeVore
> Blue Mango Multimedia
> trevor at mangomultimedia.com
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
>
http://lists.runrev.com/mailman/listinfo/use-revolution


__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com



More information about the use-livecode mailing list