Get a handler from a script

Geoff Canyon gcanyon at inspiredlogic.com
Sat Mar 18 00:18:34 EST 2006


Do you want them even though they are commented, or do you not want  
them?

For Navigator I don't care about commented handlers although I  
suppose maybe I should.

Since a comment relieves you of syntax requirements, this line is  
perfectly legitimate:

-- I've commented out this handler: on doSomething

I'm going to ignore such handlers, since they're just annoying. ;-)

That leaves two possibilities:

  -- on doSomething
  --on doSomething

So change the statement below to:

   if (word 1 of L is among the items of \
   "on,function,getprop,setprop,--on,--function,--getprop,--setprop"  
and...etc.) \
   or (word 1 of L is "--" and \
   word 2 of L is among the items of "on,function,getprop,setprop"  
and...etc.)

regards,

Geoff


On Mar 17, 2006, at 9:09 AM, Mark Smith wrote:

> 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
>
> _______________________________________________
> 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