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

[colorforth] New, Improved "Hello, World!"


I've made an attempt at a better "Hello, world!" program.  But it doesn't work
and I can't figure out why.

It's available in full color at
http://sleepless-night.com/cgi-bin/twiki/view/Main/ColorForthHelloWorld

Here it is in traditional Forth notation:

macro
: 1@ ( a-c ) 8a 2, ;  \ retrieve byte at address
forth
: string ( -a ) pop ; \ 'pop' is equivalent to 'r>' in ANS Forth
: hw ( -a ) string [ hex 0c0c0420 , 0f002e03 , 100c0103 , 2a 1, decimal ] ;
: type ( an-a ) for dup 1@ emit 1 + next ;
: greet  25 dup at white [ hw ] literal 13 type drop ;
: hello  show black screen text greet keyboard ;
hello

The 'string' word, which I copied from some of the other source blocks, is
intended to return the address of the following bytes.  However, if I try "hw
@" I just get zeroes back.

I've stared at this for a long time.  I'm probably doing something stupid.  I'd
appreciate any whacks to the head.

If I can get this working, I'll start some experiments with parsing words so
that we can have S" and/or .".

-- Kris


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
------------------------

To Unsubscribe from this list, send mail to Mdaemon@xxxxxxxxxxxxxxxxxx with:
unsubscribe ColorForth
as the first and only line within the message body
Problems   -   List-Admin@xxxxxxxxxxxxxxxxxx
Main ColorForth site   -   http://www.colorforth.com