[gforth] / gforth / kernel / io.fs  

gforth: gforth/kernel/io.fs

Diff for /gforth/kernel/io.fs between version 1.21 and 1.31

version 1.21, Sat Sep 23 15:47:10 2000 UTC version 1.31, Fri Jul 27 23:28:10 2012 UTC
Line 1 
Line 1 
 \ input output basics                           (extra since)   02mar97jaw  \ input output basics                           (extra since)   02mar97jaw
   
 \ Copyright (C) 1995,1996,1997,1998,2000 Free Software Foundation, Inc.  \ Copyright (C) 1995,1996,1997,1998,2000,2003,2006,2007 Free Software Foundation, Inc.
   
 \ This file is part of Gforth.  \ This file is part of Gforth.
   
 \ Gforth is free software; you can redistribute it and/or  \ Gforth is free software; you can redistribute it and/or
 \ modify it under the terms of the GNU General Public License  \ modify it under the terms of the GNU General Public License
 \ as published by the Free Software Foundation; either version 2  \ as published by the Free Software Foundation, either version 3
 \ of the License, or (at your option) any later version.  \ of the License, or (at your option) any later version.
   
 \ This program is distributed in the hope that it will be useful,  \ This program is distributed in the hope that it will be useful,
Line 15 
Line 15 
 \ GNU General Public License for more details.  \ GNU General Public License for more details.
   
 \ 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, see http://www.gnu.org/licenses/.
 \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.  
   
 require ./basics.fs  require ./basics.fs
   
 \ Output                                               13feb93py  \ Output                                               13feb93py
   
 has? os [IF]  has? os [IF]
 0 Value outfile-id ( -- file-id ) \ gforth  
 0 Value infile-id ( -- file-id ) \ gforth  0 Value infile-id ( -- file-id ) \ gforth
   0 Value outfile-id ( -- file-id ) \ gforth
   0 Value errfile-id ( -- file-id ) \ gforth
   
 : (type) ( c-addr u -- ) \ gforth  : (type) ( c-addr u -- ) \ gforth
     outfile-id write-file drop \ !! use ?DUP-IF THROW ENDIF instead of DROP ?      outfile-id write-file drop \ !! use ?DUP-IF THROW ENDIF instead of DROP ?
Line 65 
Line 65 
   
 Defer key ( -- char ) \ core  Defer key ( -- char ) \ core
 \G Receive (but do not display) one character, @var{char}.  \G Receive (but do not display) one character, @var{char}.
   : (key) ( -- c ) \ gforth
       infile-id key-file ;
   : infile-id  stdin ;
   
 [IFDEF] (key) ' (key) IS key [THEN]  [IFDEF] (key) ' (key) IS key [THEN]
   
Line 74 
Line 77 
 \G yield the character. Once @code{key?} returns true, subsequent  \G yield the character. Once @code{key?} returns true, subsequent
 \G calls to @code{key?} before calling @code{key} or @code{ekey} will  \G calls to @code{key?} before calling @code{key} or @code{ekey} will
 \G also return true.  \G also return true.
   : (key?) ( -- flag ) \ gforth
       infile-id key?-file ;
   : infile-id  stdin ;
   
 [IFDEF] (key?) ' (key?) IS key? [THEN]  [IFDEF] (key?) ' (key?) IS key? [THEN]
   
Line 84 
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 94 
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 c-r  Defer cr ( -- ) \ core c-r
     \G Output a newline (of the favourite kind of the host OS).  Note      \G Output a newline (of the favourite kind of the host OS).  Note
     \G that due to the way the Forth command line interpreter inserts      \G that due to the way the Forth command line interpreter inserts
     \G newlines, the preferred way to use @code{cr} is at the start      \G newlines, the preferred way to use @code{cr} is at the start
     \G of a piece of text; e.g., @code{cr ." hello, world"}.      \G of a piece of text; e.g., @code{cr ." hello, world"}.
   : (cr) ( -- )
     newline type ;      newline type ;
   ' (cr) IS cr
   
 : 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 ;


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

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help