Arrays: new and old keys, i

Mark Wieder mwieder at ahsoftware.net
Sat Sep 13 00:54:42 EDT 2008


David-

Friday, September 12, 2008, 2:23:23 PM, you wrote:

> Mark I often need the chronological order. Examples of the top I my head
> include routines to parse, scripts and create outlines for handlers, or wiki
> text and construct outlines for titles, or tree structures where i want to
> store the titles and their order matters - based on an outline... in fact
> any example where you want to store data in an array for fast retrieval of
> that data associated with a line of text, and the order of the titles is not
> simply alphabetical but dependent on the orginal order in the document
> parsed. I'd probably find it harder to think of examples in which i don't
> need the chronological order of array keys.

Still not getting it here. I often do that with arrays, but I just use
a multipart key (and now I can use multidimensional array keys). I've
never needed to retrieve elements in the order added and still can't
see the utility of it. The following not only preserves title order,
but frees you from having to add them in order...

put firstTitle into tArray[1,"title"]
put secondTitle into tArray[2,"title"]
put fourthTitle into tArray[4,"title"]
put thirdTitle into tArray[3,"title"]

put the keys of tArray into tKeys
filter tKeys with "*,title"
sort tKeys

-- 
-Mark Wieder
 mwieder at ahsoftware.net




More information about the use-livecode mailing list