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

[ColorForth] hello world again


Hello colorForthers,

I came across colorForth some time ago, and finally finished my
own "Hello World" program. I will post my solution to Kris Johnson's Wiki
pages, but being a newbie to Forth I thought I'd better post this to the list
first for comments. So here's what I did:

macro

: srcptr  [?dup] $c78b 2, ;

forth

: str  srcptr ;
: type  unpack if emit type ; then drop drop ;
: greet  [ str ] ( hello world ) @ $10 negate and type ;
: hello  show black screen text greet keyboard ;

'str' puts the source address of the following word on the stack at compile
time, 'type' is adapted from the internal function used by the editor itself.

This now prints just "hello". Obviously I have to add a word that gets the
next source word, checks wheather it's text, and then types it or terminates.
In the documentation there is a word '@+' that would be very handy for this,
but it looks like it's not implemented. I wonder if it has been removed for a
reason?

Any comments much appreciated!

Cheers,
        Alex

------------------------

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