Creating variables
Eric Chatonet
eric.chatonet at sosmartsoftware.com
Wed Aug 6 10:53:39 EDT 2008
To be frank, I don't understand:
Below is your code snippet simplified.
What it does?
It stores a variable into a custom property: so far so good ;-)
But what more?
Please, enlighten me :-)
on mouseUp
ask "Name of pseudo variable:" with "anExample"
if it is empty then exit mouseUp
put it into varName
ask "value of variable" && varName
if it is empty then exit mouseUp
put it into varValue
set the myProps[varName] of me to varValue
answer "Do you want to retrieve the value of your variable?" with
"Cancel" or "OK"
if it is "OK" then
answer "This is the value of variable" && varName & ":" && the
myProps[varName] of me
end if
end mouseUp
Le 6 août 08 à 15:41, François Chaplais a écrit :
> I think I have found a workaround for working with "variables"
> referenced by names. It involves custom property sets. These can be
> referenced by name. Here is an button script example:
>
> on mouseUp
> ask "Custom property set?" with "example"
> if it is empty then
> exit mouseup
> end if
> put it into theName
> set the customPropertySet of me to theName
> put the customproperties[thename] of me into myProps
> -- creation of variable by asking name; can be replaced by
> anything that returns a string
> ask "Name of pseudo variable:" with "anExample"
> put it into varName
> if varName is empty then
> exit mouseup
> end if
> -- assigning value of "variable" anything will do, I think, since
> this is a custom property
> ask "value of variable" && varName -- put your code here
> if it is empty then
> exit mouseup
> end if
> put it into myProps[varName]
> set customproperties[thename] of me to myProps -- value is set
> answer "Do you want to retrieve the value of your variable?" with
> "Cancel" or "OK"
> if it is "OK" then -- retrieve variable value
> put the customproperties[thename] of me into myProps
> get myProps[varName]
> answer "This is the value of variable" && varName & ":" && it
> end if
> end mouseUp
>
> I think this can be made pretty generic and split into several
> independent handlers/functions. Moreover the variables can be
> accessed globally and are stored in the stack file upon save.
> haven't tried in in a standalone for the moment, though.
>
> Best regards,
> François
Best regards from Paris,
Eric Chatonet.
----------------------------------------------------------------
Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/
Email: eric.chatonet at sosmartsoftware.com/
----------------------------------------------------------------
More information about the use-livecode
mailing list