parsing comments in scripts
Alex Tweedly
alex at tweedly.net
Mon Dec 13 17:25:02 EST 2004
At 14:38 13/12/2004 -0700, Dar Scott wrote:
>On Dec 13, 2004, at 1:30 PM, Cubist at aol.com wrote:
>
>>>It may be that us old-timers have to evolve.
>> I think I see a possible solution.
>
>The editor seems to know the limits of the handler (tab for formatting and
>handler oriented editing), so it should be able to comment out a handler.
It does - in a fairly trivial way;
--just do the current handler
put word 2 of the selectedLine into tCurrentLine
repeat with i = tCurrentLine down to 1
if word 1 of line i of fld "script" is among the items of
"on,setProp,getProp,function" then exit repeat
end repeat
> Maybe under the Script menu could be an item named Comment Handler. If
> a right click is added to the editor, then it could be there, too.
I think it could. The problem would be in commenting it back in again.
Of course, you could simply bail on that problem, and require the user to
select the entire (commented) handler and select "un-comment" - but that
requires the effort we said was undesirable (unacceptable) to comment it in
the first place.
If you want the editor to have an "uncomment the entire handler" command,
then it's going to need to look into comments, to see whether or not
removing the leading comment indicator would leave a line which could then
be a start / finish of a handler. Doesn't seem too bad to me - but I know
there were concerns about the interpreter (now the editor) looking at
comments and guessing about their meaning.
I think the failure modes here (at least, the ones I can think of) are
fairly pathological; user comments out entire handler, then within that
block partially removes a comment indicator such that the "uncomment"
command selects the wrong start (or finish) line.
-- Alex.
More information about the use-livecode
mailing list