[gforth] / gforth / kernel / io.fs  

gforth: gforth/kernel/io.fs

Diff for /gforth/kernel/io.fs between version 1.8 and 1.28

version 1.8, Wed Feb 3 00:10:25 1999 UTC version 1.28, Sun Mar 25 21:30:59 2007 UTC
Line 1 
Line 1 
 \ input output basics                           (extra since)   02mar97jaw  \ input output basics                           (extra since)   02mar97jaw
   
 \ Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.  \ Copyright (C) 1995,1996,1997,1998,2000,2003,2006 Free Software Foundation, Inc.
   
 \ This file is part of Gforth.  \ This file is part of Gforth.
   
Line 16 
Line 16 
   
 \ You should have received a copy of the GNU General Public License  \ You should have received a copy of the GNU General Public License
 \ along with this program; if not, write to the Free Software  \ along with this program; if not, write to the Free Software
 \ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
   
   require ./basics.fs
   
 \ Output                                               13feb93py  \ Output                                               13feb93py
   
Line 42 
Line 44 
 undef-words  undef-words
   
 Defer type ( c-addr u -- ) \ core  Defer type ( c-addr u -- ) \ core
   \G If u>0, display u characters from a string starting with the character    \G If @var{u}>0, display @var{u} characters from a string starting
   \G stored at c-addr.    \G with the character stored at @var{c-addr}.
   [IFDEF] write-file
   : (type) 0 write-file drop ;
   [ELSE]
 : (type)  BEGIN  dup  WHILE  : (type)  BEGIN  dup  WHILE
     >r dup c@ (emit) 1+ r> 1-  REPEAT  2drop ;      >r dup c@ (emit) 1+ r> 1-  REPEAT  2drop ;
   [THEN]
   
 [IFDEF] (type) ' (type) IS Type [THEN]  [IFDEF] (type) ' (type) IS Type [THEN]
   
Line 57 
Line 63 
   
 [IFDEF] (emit) ' (emit) IS emit [THEN]  [IFDEF] (emit) ' (emit) IS emit [THEN]
   
 Defer key ( -- c ) \ core  Defer key ( -- char ) \ core
   \G Receive (but do not display) one character, @var{char}.
 : (key) ( -- c ) \ gforth  : (key) ( -- c ) \ gforth
     0 key-file ;      infile-id key-file ;
   : infile-id  stdin ;
   
 [IFDEF] (key) ' (key) IS key [THEN]  [IFDEF] (key) ' (key) IS key [THEN]
   
 Defer key? ( -- flag ) \ core  Defer key? ( -- flag ) \ facility key-question
   \G Determine whether a character is available. If a character is
   \G available, @var{flag} is true; the next call to @code{key} will
   \G yield the character. Once @code{key?} returns true, subsequent
   \G calls to @code{key?} before calling @code{key} or @code{ekey} will
   \G also return true.
 : (key?) ( -- flag ) \ gforth  : (key?) ( -- flag ) \ gforth
     0 key?-file ;      infile-id key?-file ;
   : infile-id  stdin ;
   
 [IFDEF] (key?) ' (key?) IS key? [THEN]  [IFDEF] (key?) ' (key?) IS key? [THEN]
   
Line 76 
Line 90 
   
 \ Input                                                13feb93py  \ Input                                                13feb93py
   
   04 constant #eof ( -- c ) \ gforth
 07 constant #bell ( -- c ) \ gforth  07 constant #bell ( -- c ) \ gforth
 08 constant #bs ( -- c ) \ gforth  08 constant #bs ( -- c ) \ gforth
 09 constant #tab ( -- c ) \ gforth  09 constant #tab ( -- c ) \ gforth
Line 86 
Line 101 
 0A constant #lf ( -- c ) \ gforth  0A constant #lf ( -- c ) \ gforth
   
 : bell  #bell emit [ has? os [IF] ] outfile-id flush-file drop [ [THEN] ] ;  : bell  #bell emit [ has? os [IF] ] outfile-id flush-file drop [ [THEN] ] ;
 : cr ( -- ) \ core  : cr ( -- ) \ core c-r
   \G Output a carriage-return and (if appropriate for the host operating system)      \G Output a newline (of the favourite kind of the host OS).  Note
   \G a line feed.      \G that due to the way the Forth command line interpreter inserts
 [ has? crlf [IF] ]      #cr emit #lf emit      \G newlines, the preferred way to use @code{cr} is at the start
 [ [ELSE] ]              #lf emit      \G of a piece of text; e.g., @code{cr ." hello, world"}.
 [ [THEN] ]      newline type ;
     ;  
   
 : space ( -- ) \ core  : space ( -- ) \ core
   \G Display one space.    \G Display one space.
   bl emit ;    bl emit ;
   
 has? ec [IF]  has? os 0= [IF]
 : spaces ( n -- ) \ core  : spaces ( n -- ) \ core
   \G If n > 0, display n spaces.    \G If n > 0, display n spaces.
   0 max 0 ?DO space LOOP ;    0 max 0 ?DO space LOOP ;
Line 107 
Line 121 
 \ space spaces                                          21mar93py  \ space spaces                                          21mar93py
 decimal  decimal
 Create spaces ( u -- ) \ core  Create spaces ( u -- ) \ core
   \G If n > 0, display n spaces.    \G Display @var{n} spaces.
   bl 80 times \ times from target compiler! 11may93jaw    bl 80 times \ times from target compiler! 11may93jaw
 DOES>   ( u -- )  DOES>   ( u -- )
   swap    swap


Generate output suitable for use with a patch program
Legend:
Removed from v.1.8  
changed lines
  Added in v.1.28

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help