Get a handler from a script
rjb at robelko.com
Thu Mar 16 22:13:39 EST 2006
>The reason I think Roberts is more the ticket is that it deals with
>the case where you have a handler 'jumpHigh' as well as a handler
>'jump' later in the script -- this means we need to check for the end
>of the handler name - which could be a space if there are parameters,
>or cr if not.
>We can avoid checking that for the 'end' line by using the third
>parameter to lineOffset -- lines to skip, so a revised version might
>function extractHandlerFromScript pScript,pHandlerName
> put lineOffset("on" && pHandlerName & space, pScript) into tHandlerBegin
> if tHandlerBegin is 0 then put lineOffset("on" && pHandlerName & cr,
>pScript) into tFooBar1
>-- this deals with either space or cr at the end of the handler name
>-- and we don't need to check for 'function' since it contains 'on'
> if tHandlerBegin is 0 then return empty
> put lineOffset("end" && pHandlerName,pScript,tHandlerBegin) into tHandlerEnd
> if pHandlerEnd is 0 then return empty
> return line tHandlerBegin to tHandlerEnd of pScript
Great improvements, Mark.
More information about the Use-livecode