uses StartUp uses Ext.comment /* From: Mitch.Bradley@ENG.SUN.COM (Mitch Bradley) Subject: Re: CHAR vs. ASCII Reply-To: Mitch Bradley Organization: The Internet > Pardon me for asking, but won't your CHAR actually eat an entire word > and merely use the first character? Yes, that's the way it is intended to work, and the way that most existing implementations of the word ASCII work. > If one wants to use CHAR to read only one > character ahead into the input stream.... or if one wants to read a > space..????? That is not what CHAR is for. To read one charcter from the input stream (not a very common operation), you need to do something like: */ : CHARS_SOURCE ( -- adr len ) BLK @ ?DUP IF ( blk# ) BLOCK 1024 ( adr maxlen ) ELSE ( ) TIB #TIB @ ( adr maxlen ) THEN ( adr maxlen ) >IN @ - ( adr len ) ; \ Returns -1 at end of input stream : NEXTCHAR ( -- char | -1 ) CHARS_SOURCE 1 >= IF ( adr ) C@ 1 >IN +! ( char ) ELSE ( adr ) DROP -1 ( -1 ) THEN ( char | -1 ) ; /* Mitch */
Make your own free website on Tripod.com