best way to read and write variables?

Dave Cragg dcragg at lacscentre.co.uk
Mon Dec 10 13:20:01 EST 2001


At 6:47 am -0800 7/12/01, Niklas "Almesj–" wrote:
>What is the best way to write and read variables?
>When using Authorware there was a pretty convinient
>way to do it with property lists. Property lists
>looked something like this: "width":50, "height": 30
>then you could just write the list to a textfile, read
>it in and do a List(theText) and you had the list
>again. Anything similar (or even better) in Rev?
>thanks,
>/Niklas

You bet! :)

The equivalent of Authorware's property lists is Rev's associative 
arrays. So you might do something in your app like this:

put 50 into tData["width"]
put 30 into tData["height"]
put "wood" into tData["material"]

In Rev 1.1 (I think) the combine and split commands allow you to 
convert between arrays and text easily, So, using the above data:

combine tData using cr and "="

will convert tData to the following

width=50
height=30
material=wood

To put this into a file:

put tData into url "file:C:/whatever.txt" #(or similar)

To do the reverse:

put url "file:C:/whatever.txt" into tData
split tData using cr and "="

Cheers
Dave Cragg



More information about the use-livecode mailing list