You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
642 B
23 lines
642 B
0 Value fd-in
|
|
4096 constant line-buffer-size
|
|
create line-buffer line-buffer-size chars allot
|
|
variable line-number
|
|
variable line-len
|
|
|
|
( open the file for reading )
|
|
s" cat.fs" r/o open-file throw Value fd-in
|
|
|
|
: type-input ( -- )
|
|
begin \ essentially "while true"
|
|
1 line-number +! \ increment line number by 1
|
|
line-buffer line-buffer-size fd-in read-line ( len flag err )
|
|
throw \ if errors, throw to top level error handler (?)
|
|
invert if drop exit endif \ false (0x00) flag == eof; exit is a return from the subroutine
|
|
line-len ! \ store length into line-len
|
|
line-buffer line-len @ type cr
|
|
again ;
|
|
|
|
type-input
|
|
|
|
bye
|