Start Using
Rob Cozens
rcozens at pon.net
Sun Dec 12 12:17:11 EST 2004
Gordon,
>
>Could you elaborate on the "gotcha" thing. I changed
>my function from
>
> "function setGlobal <params>"
>
>to
>
> "on setGlobal <params>"
>
>and now I don't get the error message, but instead of
>setting the cutom property "myVar" of the button to
>23.6, it creates a cutom property called "myVar,23.6"!
>
>What's the difference between a command and a
>function- I even tried setting "setGlobal" back to a
>function and returning something, but then I got the
>old "handler not found" error again. I am confused
>about commands and functions - why are my functions
>not seen and which should I use and when?
A command starts with "on"; a function starts with "function"
When calling a function, the arguments to be passed are enclosed in
parens (); when calling a command they are not--though individual
arguments may contain ()..
A function must return a value; a command may return a value.
The Rev script parser looks for the "(" in a handler call to
determine whether it is a function or command. If it sees "setGlobal
params" it generates a "command message"; if it sees
"setGlobal(params)" it generates a "function message".
So if one had a command "setGlobals" and scripted "setGlobals (the
short name of the target)", one would get a "handler not found"
[expecting a function]; whereas scripting.
"get the short name of the target
setGlobals it"
will work.
>Here are the "setGlobal" and getGlobal functions
>
>on setGlobal tname, tvalue
> set the tname of button "Button" of stack
>"EZGlobals" to tvalue
>end setGlobal
>
>function getGlobal tname
> return the tname of button "Button" of stack
>"EZGlobals"
>end getGlobal
I don't see any obvious error. How are tname & tvalue set before the
setGlobal command is called.
--
Rob
More information about the use-livecode
mailing list