Can Handler Know What Params It Should Have

Mark Wieder mwieder at ahsoftware.net
Thu Feb 4 18:10:15 EST 2016


On 02/03/2016 03:38 AM, Mark Waddingham wrote:
> On 2016-02-02 17:05, Bernard Devlin 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.
>
> There isn't currently a way to get this information, no.
>
> We currently have 'the params' which returns a string form of the
> handlers invocation (which, is somewhat flawed as you can have array
> valued parameters, and strings containing quote), paramCount() which
> returns the number of parameters actually passed, and param(i) which
> returns the value (not converted to a string) of the i'th parameter
> passed to the current call.
>
> Perhaps something like a 'paramName(i)' function?
>
> Can you give more information about your use-case?
>
> Warmest Regards,
>
> Mark.
>

Bernard-

If I'm understanding what you want to do (and like Mark says, a use-case 
would be useful here), then here's what I do in glx2 to get the 
declaration context:

at the start of an editing session, get the list of scripts in the path: 
frontscripts, backscripts, object, card, stack, group, behaviors.
For each script in that list, filter with "end *". Stash those away 
somewhere with the type of script ("frontscript", "behavior", etc) and 
the location of the script object.

Then when I need the declaration for clairvoyance type-ahead, I match 
the handler I'm looking for with the lists I have previously stored, 
working my way down the path the way the engine would. If I find a 
match, I grab the specified script and find the declaration line.

It sounds like a lot of work, but the filter function makes it very 
responsive.

-- 
  Mark Wieder
  ahsoftware at gmail.com




More information about the use-livecode mailing list