Get a handler from a script

Mark Smith mark at maseurope.net
Fri Mar 17 12:09:57 EST 2006


Lucid and thorough, as usual. And we'd all forgotten about 'Prop'  
handlers.
However, to nitpick, and raise a question from earlier in the thread,  
what about handlers that are commented out?

hmmm..not as simple as it might seem...

Mark

On 17 Mar 2006, at 16:16, Geoff Canyon wrote:

>
> On Mar 16, 2006, at 5:25 PM, Thomas McGrath III wrote:
>
>> But, I would like to get just one of the handlers from a script  
>> via script:    put handler "FooBar" of the script of card "Foo"  
>> into tBar
>
> Most of the solutions presented so far make assumptions. For  
> example, there can be more than one space between "on" and the  
> handler name.
>
> In Navigator I use this to retrieve a list of the handler names:
>
> repeat for each line L in tText -- tText is the script
>   if word 1 of L is among the items of  
> "on,function,getprop,setprop" then
>     put L & cr after tMenuText
>   end if
> end repeat
>
> So to get the handler you would be doing something like:
>
> put 0 into tLineNumber
> put false into tEnteredHandler
> repeat for each line L in tText -- tText is the script
>   add 1 to tLineNumber
>   if word 1 of L is among the items of  
> "on,function,getprop,setprop" and \
>     word 2 of L is tHandlerName then
>     put tLineNumber into tStartLineNumber
>     put true into tEnteredHandler
>   end if
>   if tEnteredHandler and \
>     word 1 of L is "end" and \
>     word 2 of L is tHandlerName then
>     put tLineNumber into tEndLineNumber
>     exit repeat
>   end if
> end repeat
>
> -- if tEnteredHandler is false, we didn't find the handler
> -- if tEnteredHandler is true, tStartLineNumber is where it starts,
> -- tEndLineNumber is where it ends
>
> regards,
>
> Geoff
> _______________________________________________
> 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