Get a handler from a script

Mark Smith mark at maseurope.net
Thu Mar 16 21:46:06 EST 2006


This is more the ticket - except I don't think we need to deal with  
'on' and 'function' separately, lineOffset picks up  the 'on' in  
'function'.

Cheers,

Mark

>
> something like (not tested; watch line wraps)
>
> put extractHandlerFromScript(the script of cd "Foo","FooBar") into  
> tBar
>
> 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
>   if tHandlerBegin is 0 then put lineOffset("function" &&  
> pHandlerName & space, pScript) into tFooBar1
>   if tHandlerBegin is 0 then put lineOffset("function" &&  
> pHandlerName & cr, pScript) into tFooBar1
>   if tHandlerBegin is 0 then return empty
>   put lineOffset("end" && pHandlerName & cr, pScript) into tHandlerEnd
>   if tHandlerEnd is 0 then put lineOffset("end" && pHandlerName &  
> space, pScript) into tHandlerEnd
>   if tHandlerEnd is 0 then return empty
>   return line tHandlerBegin to tHandlerEnd of pScript
> end extractHandlerFromScript
>
> If formatting is not so regular, you may need to account for  
> multiple spaces between on/function/end and handler name.
>
> Robert
> _______________________________________________
> 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