Get a handler from a script

Jim Ault JimAultWins at yahoo.com
Fri Mar 17 12:37:52 EST 2006


Also consider there is more than one way to legally comment out lines of
code.  The author should choose and be consistent.

I used to have a routine in HCard that would find all the
"on,  function,  --on , --function" handlers & "global" declaration lines in
a stack script container and build a directory at the top of that script
container for all stacksinuse.  This way I could print the first page and
have them documented.

As you may recall, HCard had a 32K script container limit and the workaround
was to do several 'stacksinuse' to build a working library.

-- comment
# comment

/*
... block of comments
on thisFunction val

end thisFunction val

on thisOther val

end thisOther val
*/

If I were to do this on a consistent basis, I would copy each of my stacks
into 'mysearchscript' folder, then use BBEdit file search and RegEx to Find
All in that folder of stacks, then scan the search result, double clicking
the hit line to go to that code.  This works because the scripts in a stack
are visible.  What you do not get is what object has the code, and you do
get a few false or ghost hits.

Jim Ault
Las Vegas

On 3/17/06 9:09 AM, "Mark Smith" <mark at maseurope.net> 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