News flash: I'm going to Australia in February, so this Web site may be switched off at any time.
The ``read()
'' function returns the next input line as
a string, or fails if there are no more input lines. Here is a simple
program that just reads and writes one line:
procedure main() local line # A variable to hold the line if ( line := read ( ) ) then # Try to get the line write ( line ) # Success: write it else # Failure: complain write ( "*** The input was empty! ***" ); endHere is an ``identity filter'' program, which copies its input to its output:
procedure main() while write ( read ( ) ); endThe ``
read()
'' function is called repeatedly. Every time it
succeeds in reading a new line, its result is sent to the
``write()
'' procedure to be written. When there are
no more input lines, ``read()
'' fails, which causes
``write()
'' to fail (because the evaluation of its
argument failed), which terminates the ``while
'' loop.
john@nmt.edu