Temporary custom properties
Chipp Walters
chipp at chipp.com
Thu Feb 14 18:02:38 EST 2008
Hi Russell,
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:
local lFred
on doThis
put "hello" into lFred"
end doThis
on doThat
put lFred into me
--> PUTS FRED INTO THIS FIELD IF doThis HAS BEEN CALLED
end doThat
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:
on mouseUp
put "jack ran up the hill" into tData
setFred tData
end mouseUp
and in the card script you add:
on setlFred pData
do ("put pData into " & pLocalName)
--> THIS SETS THE LOCAL VAR lFred TO pData
end setLocal
And if you want to retrieve the local, put this in the card script:
function getFred
return lFred
end getFred
and your script to retrieve the local is now:
on mouseUp
put getFred() into tData
end mouseUp
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.
HTH,
Chipp
More information about the use-livecode
mailing list