[comp.sys.mac.hypercard] Null lines at end of containers

EGNILGES@pucc.Princeton.EDU (Ed Nilges) (05/26/89)

Bug in HyperTalk?

I'm gradually building a library of standard techniques expressed as
functions in Hypertalk.  This library includes nl2char and char2nl,
two functions which respectively convert newlines to symbols (the function
default of <nl> can be user-overridden) and symbols back to newlines.

Thus:

     put "a" into line 1 of container
     put "b" into line 2 of container
     put nl2char(container)

will yield "a<nl>b".  "put nl2char(container,"/")" will yield "a/b",
and "put char2nl(nl2char(container))" should yield the original string.

However, a bug/feature of HyperTalk is making it difficult for these
two functions to be truly inverse.  Hypertalk won't append null lines
to the end of a container:

     put "a" into container
     put "" into line 2 of container
     put number of lines of container

will type 1...not 2 (try it; I've tested this uner 1.2.1 and 1.2.2)
This entails that

     put number of lines of char2nl("a<nl>")

will yield 1 in the message box, not 2, and worse

     nl2char(char2nl(...<nl>)) won't equal ...<nl>

Any ideas?  I'd observe at this point that improper handling of nulls
can be a serious flaw in an interpretive language.

Edward Nilges

"If the universe were perfect, it wouldn't exist" - Yogi Berra