The best way to store arrays as text file?

Stephen Barncard stephenREVOLUTION at barncard.com
Wed Jan 10 14:00:43 EST 2007


Well I use two ways to store arrays...

Does the data need to be read outside of rev or not?
If they're going to be read by a revolution app, then

they can be stored and recovered intact as a custom property set in 
an external stack.

I also pack them into a single custom property using tabbed fields 
for each record. One record on each line. First item is the key. If 
returns and other special characters are in the array then 
URLEncoding/Decoding can be used for certain data.

If text files are needed to move that data to anywhere else, you're 
probably limited to tab delimited fields with linefeeds subbed for 
returns in data and returns for records unless you use XML.

I would use <XML> like methods, but they all seem cumbersome compared 
to just rigidly formatting the data and using properties, at least 
for state and prefs purposes.



>Like a lot of people I use arrays a lot, and as it is generally good
>practice to store data external to the application it is usefull to be able
>to save array data to disk as a some sort of file. So my question is what is
>the best way of storing arbitrary array data in a cross platform way?
>
>You could do it using a stack - which works and while I cannot think of
>anything directly against it - well lets say we don't do that :)
>How about those annoying Apple pLists? While they are an ugly looking
>structure they do seem to have the right sort of structure to store
>arbitrary array data. The array keys can are not used as tags but tag
>contents of a "<key> element, and I think it should be possible to create
>two general functions:
>
>  - arrayToXML and xmlToArray for storing anything you have in
>(multidimensional) arrays to disk and back.
>
>One advantage of using pLists is that you get access to all sorts of other
>usefull data stored in that format - but is there a better format / option?

-- 


stephen barncard
s a n  f r a n c i s c o
- - -  - - - - - - - - -






More information about the use-livecode mailing list