Nested Arrays

Jan Schenkel janschenkel at yahoo.com
Fri Nov 19 12:09:46 EST 2004


--- Gregory Lypny <gregory.lypny at videotron.ca> wrote:
> Hello everyone,
> 
> Is it possible to create nested arrays of the form
> A[X[i]] or deeper?  
> I tried but it doesn't seem to be working.
> 
> 	Greg
> 

Hi Greg,

Though not as convenient, you could try either using
XML trees, or using items and lines to split up your
data.
Another tactic is to save it in a single array, but
use combined keys :
--
  put "Foo" into A["x",5]
  put "Bar" into A["x",7,"y",2,"z"]
--
Then you can extract a subarray using the following
function :
--
function ExtractSubArray pSourceA, pPrefix
  local tKey, tKeys, tResultKey, tResultA
  put the keys of pSourceA into tKeys
  filter tKeys with (pPrefix & comma & "*")
  repeat for each line tKey in tKeys
    put char (length(pPrefix) + 1 to -1 of tKey \
        into tResultKey
    put pSourceA[tKey] into tResultA[tResultKey]
  end repeat
  return tResultA
end ExtractSubArray
--
Not the most elegant solution, but it works well
enough for now, until we get true nested arrays.

Hope this helped,

Jan Schenkel.

=====
Join us at the European Revolution Conference
November 14-16, MALTA. ~ http://TechieTours.com/Rev/

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


		
__________________________________ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.com 
 



More information about the use-livecode mailing list