best way to read and write variables?

andu undo at cloud9.net
Mon Dec 10 14:33:00 EST 2001


Dave Cragg wrote:
> 
> At 6:47 am -0800 7/12/01, Niklas "Almesj-" wrote:
> >What is the best way to write and read variables?

Depends on the task. Writing it to a file as Dave suggests is one way,
though I never needed to use a separate file for variables. I use custom
properties for persistent values of properties and variables which are
stored in the stack  or object itself and you can do quite complex
operations on them.
Also you can declare values at the beginning of a script (outside the
script):
constant x=a+b
or
local x=a+b

> >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
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution

-- 
__________________________
 Regards, Andu



More information about the use-livecode mailing list