REDUCE

12.3 OUT Command

This command takes a single file name as argument, and directs output to that file from then on, until another out changes the output file, or shut closes it. Output can go to only one file at a time, although many can be open. If the file has previously been used for output during the current job, and not shut, the new output is appended to the end of the file. Any existing file is erased before its first use for output in a job, or if it had been shut before the new out.

To output on the terminal without closing the output file, the reserved file name t (for terminal) may be used. For example, out ofile; will direct output to the file ofile and out t; will direct output to the user’s terminal.

The output sent to the file will be in the same form that it would have on the terminal. In particular x^2 would appear on two lines, an x on the lower line and a 2 on the line above. If the purpose of the output file is to save results to be read in later, this is not an appropriate form. We first must turn off the nat switch that specifies that output should be in standard mathematical notation.

Example: To create a file abcd from which it will be possible to read – using in – the value of the expression xyz:

 off echo$      % needed if your input is from a file.
 off nat$       % output in IN-readable form. Each
                % expression printed will end with a $ .
 out abcd$      % output to new file
 linelength 72$ % for systems with fixed input
                % line length.
 xyz:=xyz;      % will output "xyz := " followed by
                % the value of xyz
 write ";end"$  % standard for ending files for in
 shut abcd$     % save abcd, return to terminal output
 on nat$                % restore usual output form


Hosted by Download REDUCE Powered by MathJax