[gforth] / gforth / kernel / io.fs  

gforth: gforth/kernel/io.fs

Diff for /gforth/kernel/io.fs between version 1.1 and 1.9

version 1.1, Wed May 21 20:40:15 1997 UTC version 1.9, Tue Mar 23 20:24:25 1999 UTC
Line 1 
Line 1 
 \ input output basics                           (extra since)   02mar97jaw  \ input output basics                           (extra since)   02mar97jaw
   
 \ Copyright (C) 1995-1997 Free Software Foundation, Inc.  \ Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
   
 \ This file is part of Gforth.  \ This file is part of Gforth.
   
Line 18 
Line 18 
 \ 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., 675 Mass Ave, Cambridge, MA 02139, USA.
   
   \ Output                                               13feb93py
   
   has? os [IF]
   0 Value outfile-id ( -- file-id ) \ gforth
   0 Value infile-id ( -- file-id ) \ gforth
   
   : (type) ( c-addr u -- ) \ gforth
       outfile-id write-file drop \ !! use ?DUP-IF THROW ENDIF instead of DROP ?
   ;
   
   : (emit) ( c -- ) \ gforth
       outfile-id emit-file drop \ !! use ?DUP-IF THROW ENDIF instead of DROP ?
   ;
   
   : (key) ( -- c ) \ gforth
       infile-id key-file ;
   
   : (key?) ( -- flag ) \ gforth
       infile-id key?-file ;
   [THEN]
   
   undef-words
   
   Defer type ( c-addr u -- ) \ core
     \G If @var{u}>0, display @var{u} characters from a string starting
     \G with the character stored at @var{c-addr}.
   : (type) BEGIN dup WHILE
       >r dup c@ (emit) 1+ r> 1- REPEAT 2drop ;
   
   [IFDEF] (type) ' (type) IS Type [THEN]
   
   Defer emit ( c -- ) \ core
     \G Display the character associated with character value c.
   : (emit) ( c -- ) \ gforth
       0 emit-file drop \ !! use ?DUP-IF THROW ENDIF instead of DROP ?
   ;
   
   [IFDEF] (emit) ' (emit) IS emit [THEN]
   
   Defer key ( -- c ) \ core
   : (key) ( -- c ) \ gforth
       0 key-file ;
   
   [IFDEF] (key) ' (key) IS key [THEN]
   
   Defer key? ( -- flag ) \ core
   : (key?) ( -- flag ) \ gforth
       0 key?-file ;
   
   [IFDEF] (key?) ' (key?) IS key? [THEN]
   
   all-words
   
   : (.")     "lit count type ;
   : (S")     "lit count ;
   
 \ Input                                                13feb93py  \ Input                                                13feb93py
   
 07 constant #bell ( -- c ) \ gforth  07 constant #bell ( -- c ) \ gforth
Line 29 
Line 85 
 0C constant #ff ( -- c ) \ gforth  0C constant #ff ( -- c ) \ gforth
 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
     \ emit a newline    \G Output a carriage-return and (if appropriate for the host operating system)
 [ ?? has-crlf [IF] ]    #cr emit #lf emit    \G a line feed.
   [ has? crlf [IF] ]      #cr emit #lf emit
 [ [ELSE] ]              #lf emit  [ [ELSE] ]              #lf emit
 [ [THEN] ]  [ [THEN] ]
     ;      ;
   
 1 [IF]  : space ( -- ) \ core
     \G Display one space.
     bl emit ;
   
   has? ec [IF]
   : spaces ( n -- ) \ core
     \G If n > 0, display n spaces.
     0 max 0 ?DO space LOOP ;
   : backspaces  0 max 0 ?DO  #bs emit  LOOP ;
   [ELSE]
 \ space spaces                                          21mar93py  \ space spaces                                          21mar93py
 decimal  decimal
 Create spaces ( u -- ) \ core  Create spaces ( u -- ) \ core
     \G If @var{n} > 0, 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
Line 51 
Line 118 
    swap     swap
    0 max 0 ?DO  I' I - &80 min 2dup type  +LOOP  drop ;     0 max 0 ?DO  I' I - &80 min 2dup type  +LOOP  drop ;
 hex  hex
 : space ( -- ) \ core  
     1 spaces ;  
 [ELSE]  
 : space bl emit ;  
 : spaces 0 max 0 ?DO space LOOP ;  
   
 [THEN]  
   
 \ Output                                               13feb93py  
   
 has-os [IF]  
 0 Value outfile-id ( -- file-id ) \ gforth  
   
 : (type) ( c-addr u -- ) \ gforth  
     outfile-id write-file drop \ !! use ?DUP-IF THROW ENDIF instead of DROP ?  
 ;  
   
 : (emit) ( c -- ) \ gforth  
     outfile-id emit-file drop \ !! use ?DUP-IF THROW ENDIF instead of DROP ?  
 ;  
 [THEN]  [THEN]
   
 Defer type ( c-addr u -- ) \ core  
 ' (type) IS Type  
   
 Defer emit ( c -- ) \ core  
 ' (Emit) IS Emit  
   
 Defer key ( -- c ) \ core  
 ' (key) IS key  
   
 : (.")     "lit count type ;  
 : (S")     "lit count ;  
   


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

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help