Get a handler from a script

Dick Kriesel dick.kriesel at mail.com
Sun Mar 19 17:37:03 EST 2006


On 3/19/06 2:12 PM, "Geoff Canyon" <gcanyon at inspiredlogic.com> wrote:

> Checking the first word of each line is (I believe) certain, and is
> still reasonably fast (takes less than twice as long as the filter
> command in informal testing).
> 
> Unfortunately for anyone attempting this task, this is a perfectly
> valid script:
> 
> /* this is a comment
> as is this */on mouseUp
>    answer "yes"
> end mouseUp
> 
> I don't know of a good way around that, so I have ignored it thus
> far ;-)

Here's a way:

on mouseUp
  put removeBlockComments(the script of me)
end mouseUp

/* this is a comment
as is this */function removeBlockComments pText
put pText into tText
put offset("/*",tText) into tOffset
if tOffset > 0 then
  delete char tOffset to tOffset + offset("*/",tText,tOffset) + 1 of tText
  put removeBlockComments(tText) into tText
end if
return tText
end removeBlockComments

-- Dick





More information about the use-livecode mailing list