Node:Input Sources, Next:Number Conversion, Previous:The Text Interpreter, Up:The Text Interpreter
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:
A program can identify the current input device from the values of
Return 0 (the input source is the user input device), -1 (the input source is a string being processed by
source-id-- 0 | -1 | fileid core-ext,file ``source-i-d''
evaluate) or a fileid (the input source is the file specified by fileid).
input-varvariable - This cell contains the current block number
The n entries xn - x1 describe the current state of the input source specification, in some platform-dependent way that can be used by
save-input-- x1 .. xn n core-ext ``save-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 Gforth with the new input code, it fails only with a flag that can be used to throw again; it is also 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 in between everything is allowed.
restore-inputx1 .. xn n -- flag core-ext ``restore-input''
Save the current input source specification. Store
evaluate... addr u -- ... core,block ``evaluate''
0and make the string c-addr u the input source and input buffer. Interpret. When the parse area is empty, restore the input source specification.
Make the user input device the input source. Receive input into the Terminal Input Buffer. Set
query-- core-ext ``query''
>INto zero. OBSOLESCENT: superceeded by