Handlers and Scope
Mark Smith
mark at maseurope.net
Wed Dec 7 10:06:02 EST 2005
Adam, a handler will be in the form:
on myHandler param1,param2,etc
doStuff
end myHandler
a function will be:
function myFunction param1,param2,etc.
do stuff
return something
end myFunction
the calling of these will be someting like
myHandler param1,param2
or:
put myFunction(param1,param2) into myVariable
Functions have their parameters enclosed in brackets, while handlers
don't.
Functions return a value, while handlers simply carry out actions.
In this case, because you have simply typed fMyFunction, without a
preceding "put" or "get", Rev tries to find a handler named
fMyFunction, which doesn't exist, instead of a function called
fMyFunction, which does.
So you either need to redefine fMyFunction as a handler (if it
doesn't return a value), or make sure that you are calling it with
the necessary code to accept a returned value.
Cheers,
Mark
On 7 Dec 2005, at 14:47, Adam wrote:
> Hi all:
>
> Being a Revolution newbie and I all, I really appreciate this list
> and everyone on it. I'd like to thank Trevor DeVore for responding
> to my first post. Trevor you've made it look easy, thanks. ;)
>
> I have put to work Trevor's suggestions in a function. That
> function resides in the script of the first card on my stack.
>
> I am then trying to call that function from the script of a button
> on the card in the following way:
>
> on mouseUp
> put field "fldItemsToFind" into lItemsToFind
> put field "fldNumItemsAllowed" into lNumItemsAllowed
> fMyFunction(lItemsToFind,lNumItemsAllowed)
> end mouseUp
>
> When put it into browse mode and click the button, I get Rev
> telling me it can't find the handler fMyFunction.
>
> What is the scope of handlers in relation to the stack, cards in
> the stack, and the elements of each card?
>
> It's probably a very simple fix, but really appreciate the help. ;)
>
> Thanks very kindly in advance.
>
> Adam
> --
> "Each day is an opportunity to learn something new." - Me
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list