Get a handler from a script

Dick Kriesel dick.kriesel at mail.com
Sun Mar 19 19:22:10 EST 2006


On 3/19/06 3:41 PM, "Alex Tweedly" <alex at tweedly.net> wrote:

> You should try that script on itself :-)
> The "/*" in the first 'offset' line, and the "*/" in the second 'offset'
> line are (incorrectly) recognized as a block comment, with fairly
> disastrous results.

I did, and verified that it removed the comment.  I didn't notice that it
also eviscerated the function!  A trivial fix avoids that problem:

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

> I suspect that proper recognition of block comments
> isn't as easy as it might seem - need to handle all forms of string
> delimiter, which themselves may be inside comments.

Since I don't recognize that need, would you elaborate on it, please?

Thanks for catching my oversight, Alex.

-- Dick





More information about the use-livecode mailing list