Temporary custom properties
chipp at chipp.com
Thu Feb 14 17:02:38 CST 2008
I typically use local var arrays to do what you're trying to do. You
can also set them if you like from elsewhere. For instance, say you
have a card with a local variable "lFred"
so your card script looks like this:
put "hello" into lFred"
put lFred into me
--> PUTS FRED INTO THIS FIELD IF doThis HAS BEEN CALLED
So, if you want to set the lFred variable from a button on the card
(treating it like it is a global) then put in the button script:
put "jack ran up the hill" into tData
and in the card script you add:
on setlFred pData
do ("put pData into " & pLocalName)
--> THIS SETS THE LOCAL VAR lFred TO pData
And if you want to retrieve the local, put this in the card script:
and your script to retrieve the local is now:
put getFred() into tData
This has the advantage of not having to worry about global namespace
collisions, or where you've placed globals all over your stack, and
how to replace them. Also, if you need to edit the "global" bizlogic,
you can do it in one place.
I don't think it's always clear to users how locals can act like globals.
More information about the use-livecode