home .. forth .. colorforth mail list archive ..

[colorforth] Hello World revisited.


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 

---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
Main web page - http://www.colorforth.com