Referencing a variable?

Alex Tweedly alex at tweedly.net
Sun Nov 27 20:19:20 EST 2005


Ian Leigh wrote:

> Hello all,
>
> I would like to do the following:
>
> Put a variable name into another buffer variable.
> Reference the actual variable but using the buffer variable.
>
> So I only have the name of the variable in the buffer but I want to  
> put a value into the actual variable only by using the variable name  
> which is stored in the buffer.
>
> Does this make sense and can it be done? I thought simply :
>
> put 123 into "buffer"
>
> might work but it doesn't work that way. I have also tried various  
> adds and used the value command too but I can't seem to figure it  
> out. Any insight would be appreciated.

Here's *an* answer - I think it might be the answer to the question you 
were asking :-)

put 123 into myVariable    -- give it an initial value
put "myVariable" into otherVariable   -- put its name into another variable
do "put 456 into " & otherVariable    -- use that other variable to 
access the original one
put myVariable & cr after msg    -- and output it to check we succeeded

this should put out 456, showing that the 3rd line did indeed do what we 
wanted.

-- 
Alex Tweedly       http://www.tweedly.net



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.8/183 - Release Date: 25/11/2005




More information about the use-livecode mailing list