Can Handler Know What Params It Should Have

-hh hh at livecode.org
Tue Feb 2 15:16:52 EST 2016


Bernard wrote:
> I know the params can be called to find out what parameters were
> passed to the handler when it is called. However, I'm wondering
> if a handler has a way of knowing what parameters it had at the
> time it was defined. I don't think so. Regards Bernard

Yes, that's my opinion too, for user handlers, but not for LC/reserved
handlers. This is the simple explanation I use for myself:

[1] For any *user handler*, the answer is NO, because there are
not "the parameters" in a definition. For example

on handler x1,x2
 put ( x1,x2 )
end handler

is equivalent to

on handler
 put ( param(1),param(2) )
end handler

[2] For a *LC handler* we can see the defined params by calling the 
params in the handler without params. For example

on mouseUp
 put the params
end mouseUp

yields: MouseUp "1" (if left-clicked)
Means: We can use, where b is the 'reserved' LC param, for example

on mouseUp b,x1,x2
 put (x1,x2)
end mouseUp

or equivalently

on mouseUp 
 put (param(2),param(3))
end mouseUp

=======
Hermann




More information about the Use-livecode mailing list