Get a handler from a script

Geoff Canyon gcanyon at inspiredlogic.com
Sun Mar 19 20:12:04 EST 2006


I feel like the harbinger of doom here (with Alex as my able partner  
in doomsaying) but:

This would still be subject to failure if, anywhere in the script, /*  
or */ appeared _not_ as block comment delimiters, but as part of a  
string.

gc

On Mar 19, 2006, at 4:22 PM, Dick Kriesel wrote:

> 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
>
>
> _______________________________________________
> 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