The best way to store arrays as text file?
David Bovill
david at openpartnership.net
Thu Jan 11 07:28:14 EST 2007
Thanks.
I know what you suggest is faster - but it would not work for complex data
containing tabs for instance. I don't want this to break when a user tries
to store something odd in the future, and as i use arrays for all sorts of
things including htmlText and possible unicode....
In general no delimiter is completely safe - safest would be XML is my guess
- all though I was wandering about JSON as it is simpler. So how about a
completely general function to store any arbitrary array?
On 11/01/07, Jim Ault <JimAultWins at yahoo.com> wrote:
>
> One handy, and very fast custom prop technique I use is ...
> Start with the concept that a custom property set *is* an array.
>
> on packCustomProps
> put the customproperties of this stack into tempArr
> combine tempArr using cr and tab --now tab delim
> put tempArr into url ("file:"& pathToFile & filename &".txt")
> --the current property set is now saved
> end packCustomProps
>
>
> --the reverse direction to use the data
> on openstack
> put url ("file:"& pathToFile & filename &".txt") into tempArr
> split tempArr using cr and tab --now an array
> set the customproperties of this stack into tempArr
> --the current property set is now restored
> end openstack
> --and the variable tempArr is purged by Rev when the handler ends
> returns in data and returns for records unless you use XML.
> There are more options for storage if you consider Applescript for the Mac
> or VBA for Windows, but that gets into exchanging data with companion apps
> (which I do everyday), but definitely not simple.
Any links to these options?
Stephen barncard wrote:
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 am a bit shaky on this cross platform text file stuff - does anyone have
any code / demo for using text files. I guess XML works as it inores the
white space" right?
More information about the use-livecode
mailing list