Get a handler from a script
Geoff Canyon
gcanyon at inspiredlogic.com
Sun Mar 19 10:55:07 EST 2006
On Mar 19, 2006, at 5:18 AM, David Burgun wrote:
> The problem is that if you are doing something like this:
>
> if the script of myObject contains "on HandlerName" then
> send HandlerName to myObject
> end if
The code I posted earlier guarantees that
on handlername
exists in the script, not commented, at the beginning of a line. I
believe that guarantees that it is a valid handler.
Here it is:
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
More information about the use-livecode
mailing list