Raven Manual - Standard IO
You may have picked up on print ( item -- ) already, to print data to screen, or wherever standard output happens to go. To read from standard input, be it keyboard or whatever, use expect ( -- string ) to read one line.
# read one line expect as $line # read many lines and echo them to screen repeat expect trim as $line $line empty until $line print
To make life easy for scripts that regularly read everything from STDIN and prevent excess repeat-expect loops, input ( -- string ) will read until EOF or an error is encountered.
input as $text
The Standard IO file handles are also exposed as file resources. Thus the functionality of expect is the same as:
STDIN line
input can be emulated using:
STDIN read
print becomes:
STDOUT write
And standard error is available:
"aaarrgh!\n" STDERR write
There is no real difference between using the words or the resources to handle Standard IO. It is entirely a matter of choice. |