By default, the text interpreter processes input from the user input device (the keyboard) when Forth starts up. The text interpreter can process input from any of these sources:
evaluate
; a variant of this is when Gforth
processes an OS command line argument of the form ‘-e string’.
A program can identify the current input device from the values of
source-id
and blk
.
Save the current input source specification. Store -1
in
source-id
and 0
in blk
. Set >IN
to
0
and make the string c-addr u the input source and
input buffer. Interpret. When the parse area is empty, restore the
input source specification.
Return 0 (the input source is the user input device), -1 (the
input source is a string being processed by evaluate
) or
a fileid (the input source is the file specified by
fileid).
addr contains the current block number (or 0 if the current input source is not a block).
The n entries xn - x1 describe the current state of the
input source specification, in some platform-dependent way that can
be used by restore-input
.
Attempt to restore the input source specification to the state
described by the n entries xn - x1. flag is true if
the restore fails. In recent (how recent?) Gforth, it is
possible to save and restore between different active input
streams. Note that closing the input streams must happen in the
reverse order as they have been opened, but as long as they are
both active, everything is allowed. These Gforth versions only
produce non-zero flags as results of catch
ing some
exception, and the flag itself is the throw
n ball
and can be rethrow
n.
Make the user input device the input source. Receive input into
the Terminal Input Buffer. Set >IN
to zero. OBSOLETE:
This Forth-94 word has been de-standardized in Forth-2012. It
is superceeded by accept
.