Suggestion: Arrays in Rev3 beta
David Bovill
david at openpartnership.net
Thu Aug 28 06:25:25 EDT 2008
2008/8/28 Bernard Devlin <bdrunrev at gmail.com>
>
> Personally the returned keys being unordered has never been an issue for
> me.
> Can you illustrate some situations where this is a problem?
In parsing data in order to layout in Rev I often use arrays. However the
order of the original data is often important. Take a recent example - I am
working on updating some scripts that parse wiki formatted text. I want to
extract all the headers (like html headers they can be of different levels)
and store the paragraph of html that goes with each section. Then I want to
lay out the data in a Rev interface. I create an outline from the wiki
headers and when the user clicks on the header the corresponding text is
displayed.
There are a number of ways of doing this - and if anyone has any suggestions
about the best way please chip in - you can use list and Rev based indexes,
you can use XML, or you can use arrays. XML is natural for these
hierarchical tree style data structures, but franksly a bit of a pain and
overkill. So I tend to use arrays, and looking very much forward to the
nested arrays in beta 3 for this.
However in order to "reconstruct" the original order of the document I
cannot simply loop through the keys of the array as the headers will be all
out of order. So I have to go to the effort of storing both the array and an
ordered index of the array. Then if I need to store this data and have two
things and two places to store it.
In general about 1/3 of the time I use arrays I also have to store an
ordered index.
More information about the use-livecode
mailing list