Click to See Complete Forum and Search --> : Array of Arrays - Detrmining the second dimensions size


Keitho
September 13th, 2001, 11:58 AM
Hi
Does any one know of a method to count the second dimesion of an 'Array of Arrays' given that its created at run time and each 2nd dimension is different; I have got some functions that determine array sizes etc but dont work with an 'Array of Arrays'. This is brief outline of what im up to

1. The function I have written returns one array - a variant array storing longs
2. This array may have 1-200 sub arrays inside it; determined at run time
3. Each sub array is of a different size, which gives a different second dimension for each element in the array.
4. When the array is returned to the caling function, I need to no the size of the second dimension or in other words the size of the array contained within it, so I can successfully do operations on that data

example
array(1)(X) contains 5 long integer elements -> I need something that says its 5 elements long, without popping
array(2)(X) contains 3 long integer elements -> I need something that says its 3 elements long, without popping
etc....
Bearin in mind that its one array that has many arrays inside it
Any suggestions are very welcome at this stage!!!

Andrew_Fryer
September 13th, 2001, 03:45 PM
This is probably not the best answer but why not have an extra array within your main one which is an array of Integers set to the same size as the number of sub-arrays in your main one. For example:

Main Array has 175 elements
Extra Array within the same one set to size 175

Each time a new sub array is created then an entry could be added to the control one containing an Integer value set to the size of the new sub array, i.e if SubArray(1) had 112 elements then ControlArray(1) would be set to 112.

Once the Control Array had been created then you would be able to find the correct number of elements by referencing the control array.

It's not the most elegant solution I know, but it's the best I could think of at short notice!

Andrew