In chapter 1, we used the print phrase
to convert internal values to external characters. We ought to say
what print
is and how it works, but we don't yet know
enough about the language. Just use it for the moment, and we shall
learn more about it later.
Besides being able to convert internal values to external
characters, print
can take two
parameters (see chapter 6 for the low-down on
parameters) which can be used to format your output.
newline will cause following output to be
displayed on a new line, and newpage will
emit a form-feed character (REPR 12
).
newline
and newpage
will be described in
detail in section 13.7.11.
If you want to print the characters emitted by your Algol 68
programs you can use file redirection to redirect
your output to a file, which you can later copy to the printer. For
example, suppose you have compiled a program called tt
.
To redirect its output to a file called tt.res
, which you
can later copy to the printer, you issue the command
tt > tt.res
at the command line. Alternatively, you send the output directly to the printer using the command
tt | lpr
at the command line. Try compiling and running the following program:
PROGRAM tt CONTEXT VOID USE standard BEGIN print(newpage); INT a = ENTIER (3.6**5); REAL p = 4.3 / 2.7; print(a); print(newline); print(b); print(newline) END FINISHSian Mountbatten 2012-01-19