I think the way I'd approach this is to add numbers to the keys while building the array, something like:

repeat for each parargraph P in tPage -- obviously, I don't know how you're parsing the wiki text!
  add 1 to count
  put extractParagraph(P) into tArray[count & comma & extractHeadng(P)]
end repeat

then:

put keys(tArray) into tKeys
sort lines of tKeys numeric by item 1 of each
repeat for each line K in tKeys
  put item 2 to -1 of K into tHeading
  put tArray[K] into tText
  .....
end repeat

of course, with the new arrays,you could do something like:

repeat for each parargraph P in tPage
  add 1 to count
  put extractHeading(P) into tArray[n]["heading"]
  put extractParagraph(P) into tArray[n]["text"]
end repeat

then:

repeat with n = 1 to the number of lines in keys(tArray)
  get tArray[n]["heading"]
  get tArray[n]["text"]
end repeat

Best,

Mark


On 28 Aug 2008, at 11:25, David Bovill wrote:

2008/8/28 Bernard Devlin <[EMAIL PROTECTED]>


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.
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to