Creating variables
François Chaplais
francois.chaplais at mines-paristech.fr
Wed Aug 6 07:25:03 EDT 2008
Le 5 août 08 à 16:12, Eric Chatonet a écrit :
> Bonjour Eric,
>
> Le 6 juil. 08 à 22:38, Éric Miclo a écrit :
>
>> repeat for each line lineListOne in listOne
>> repeat for each line lineListTwo in listTwo
>> put (lineListOne & lineListTwo) into varName
>> put "test" into varName
>> end repeat
>> end repeat
>
> put <whatever> into tContents
> do "put tContents into" && varName
>
> Best regards from Paris,
> Eric Chatonet.
>
a more general digression on manipulating rev object by names and not
by value:
as far as I am concerned, it seems to me that, for instance, if
<name> is the long name of a filed, if you want to put empty into the
field with name <name>, then you have to script
do "put empty into" && <name>
and then probably have to deal with the quotes in the long name (it
seems I have had to do this countless times when executing a loop on
object names in a group/card/whatever)
The OP was concerned to setting a variable value when knowing only
its name, and Eric's answer was to use the "do" command. This is
something I have used quite frequently in my HC days, but
unfortunately use of the "do" command is severely restricted in
standalones (with reasons I can understand).
I was hoping that the reference operator @ would do the trick, i.e.
passing the name of the variable instead of the variable itself. The
following button handler works:
---------------
on mouseUp
put 1 into myVar
doput "hello",myVar
answer myVar
end mouseUp
on doput theText, at theVarName
put theText into theVarName
end doput
------------------
the following causes an execution error when trying to execute the
doput handler
----------
on mouseUp
put 1 into myVar
doput "hello","myVar"
answer myVar
end mouseUp
on doput theText, at theVarName
put theText into theVarName
end doput
----------
If something similar could be done without using the "do" command,
for instance by passing arguments by name (i.e. a string), I would be
very happy to hear about it.
More information about the use-livecode
mailing list