Hello World revisited.

John Drake <[email protected]>
Newsgroups gmane.comp.lang.forth.colorforth
Message-ID <[email protected]>
Hello all.  I recall a while back when there was
discussion of how to do "hello world" in ColorForth,
Chuck mentioned the possibility of "unpacking" and
typing text from a block.  I saw in one of the
#c4th logs that someone has done this, but I
didn't find his code.  So here's mine.

( hello world )
: type unpack if emit type ; then drop drop ;
: space 0 emit ;
: greet 22 block dup @ type space 1 + @ type ;
: hello show black screen text greet keyboard ; 

Slight problem.  The results I get are:

hellort worldrt

It's obvious that I'm not 100% sure how
unpack works.  I'm guessing that I'm 
running into a problem with the terminating
condition?  

My understanding of "unpack" is as follows:

unpack x-yc

Where "x" is the packed data on the stack.
"y" is the rest of the data after the
charecter "c" is unpacked.  I'm acting on
the assumption that "c" = 0 is the "end
of word" condition.  Is that not correct?
If it is, why am I getting "rt" at the
end of the typed words?

Regards,

John M. Drake

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.