parsing comments in scripts

Dar Scott dsc at swcp.com
Mon Dec 13 11:15:39 EST 2004


On Dec 13, 2004, at 7:12 AM, Ken Ray wrote:

> perhaps commenting out the first line automatically
> comments out the whole handler? That is, when you close and reopen the
> script the handler is fully commented?

Like this?

--  I wrote this
--  on Christmas day
--  when others were at play.
local a
on work
    local moss
    put a
end work
local b

==>

--  I wrote this
-- --  on Christmas day
-- --  when others were at play.
-- local a
-- on work
--    local moss
--    put a
-- end work
local b

A script local and a handler is lost by an inadvertent trigger in a 
comment.


It currently works like this:  This script with the first line 
commented...

-- on work
    local moss
    put a
end work

... is virtually compiled as though it like this...

-- on work
    local moss
--   put a
-- end work

... inserting a script local variable.

The technique of commenting out the first line to disable the handler 
does not work in Transcript.

If this is fixed so '-- on xxx' patterns are recognized by the 
compiler, then the "on Christmas day" problem comes back.

As a newbie, I was confused by some commands at the top of a script in 
an example stack.  I thought maybe it was initialization.  It turned 
out to be ignored by the compiler, left there for some reason by the 
script writer, perhaps long forgotten.  Maybe it even had a commented 
out 'on' line, I don't remember.

I would guess that HyperTalk did not have local, global or constant at 
the script level (outside of handlers), so there may not have been an 
issue.

Dar Scott
DSC





More information about the use-livecode mailing list