some pseudo code to follow:
an out line would be:

if the code is not compiled the following will work, if it is (or is 
going to be) then you need to create the arrays before hand. For the 
example all arrays are text.

Array pointer($New_Array_Handles;0)

For ($i;1;$Number_Of_Arrays)
  $Array_Name:= "Array_"+String($i;"00) 
  $Array_Pointer := Get Pointer($Array_Name) `gives a pointer to 
Array_01, Array_02 ...

    ` assume all arrays are text
  Array Text($Array_Pointer->;0)

            ` depending on what you are doing you can add data here
  Insert in array($Array_Pointer->;$Where;$How_Many)
  for($ii;1;$data_size)
    Array_Pointer->{$ii}:=$New_Data
  end for
            ` or
  Append to array($Array_Pointer->;$Data)
  
            ` or you can add the array pointer to another array to 
reference later
  Append to array($New_Array_Handles;$Array_Pointer) `adds pointer to 
new array
end for

To reference the specific element of an array through a pointer
$Array_Pointer->{$Element_Number}

To reference from the pointer array
$New_Array_Handles->{$Which_array}->{$Element_Number}

in some instances, you will find 4D chokes on second reference (context 
dependent) so you can use either of the following as well:
($New_Array_Handles->{$Which_array})->{$Element_Number}
      ` or in 2 steps
$Pointer_To_Array:=$New_Array_Handles->{$Which_array}
$Pointer_To_Array->{$Element_Number}

On Tue, 31 Oct 2017 19:29:18 +0000, Peter Mew via 4D_Tech wrote:
> Hi
> I want to achieve the following:
> To Loop through a block of code (the number of times will be determined
> elsewhere, but may well be different each time).
> Create a set of arrays that will have the same name + the loop counter, for
> each pass through the loop
> So pass 1 might create 3 arrays called Array101 Array201 Array301
> pass 2 would create arrays called Array102 Array202 Array302
> and so on
> the arrays would be filled with data by the code in the loop
> 
> I then want to be able to reference these arrays, to retreive the data in
> the arrays according the loop number that created them
> So I might want to get the data for pass 2, from Array102 Array202
> Array302, and display it elsewhere.
> 
> Im pretty sure I need to use pointers to accomplish this, but I dont know
> how.
> Could someone point (sic) me in the right direction
> 
> Thanks
> -pm
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[email protected]
> **********************************************************************
---------------
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to