This command makes it possible to direct the output of print statements to two different places simultaneously. One output device is always the window or standard output. The other can be selected by the user to be any disk file or other suitable output device such as a printer.
output file=filename; output file=filename [on|off|reset];
(literal or ^string)
file=filenamesubcommand selects the file or device to which output is to be sent.
If the name of the file is to be taken from a string variable, the name of the string must be preceded by the
The default file name is
- on, off, reset:
(literal) mode flag:
opens the auxiliary output file or device and causes the results of all print statements to be sent to that file or device. If the file already exists, it will be opened for appending. If the file does not already exist, it will be created.
closes the auxiliary output file and turns off the auxiliary output.
similar to the on subcommand, except that it always creates a new file. If the file already exists, it will be destroyed and a new file by that name will be created. If it does not exist, it will be created.
output file = out1.out on;
This statement will open the file
out1.out and will cause the
results of all subsequent print statements to be sent to that
out1.out already exists, the new output will be appended.
output file = out2.out; output on;
This is equivalent to the previous example, with the exception that the file opened is named
This statement will create a new output file using the current filename. If the file already exists, any data in it will be lost.
output file = mydata.asc reset; screen off; format /m1/rz 1,8; open fp = mydata; do until eof(fp); print readr(fp, 200);; endo; fp = close(fp); end;
The program above will write the contents of the
mydata.dat into an ASCII file called
mydata.asc. If there had been an existing file by
the name of
mydata.asc, it would have been overwritten.
/m1 parameter in the format(keyword) statement in
combination with the
;; at the end of the print
statement will cause one carriage return/line feed
pair to be written at the beginning of each row of
the output file. There will not be an extra line
feed added at the end of each 200 row block.
The end statement above will automatically perform
output off and
After you have written to an output file you have to close the file before you can print it or edit it with the GAUSS editor. Use
The selection of the auxiliary output file or device remains in effect
until a new selection is made, or until you get out of GAUSS. Thus, if a
file is named as the output device in one program, it will remain the
output device in subsequent programs until a new
subcommand is encountered.
will select the file or device but will not open it. A subsequent
output reset will open it and turn on the auxiliary output.
output off will close the file and turn off the auxiliary
output. The filename will remain the same. A subsequent
output on will
cause the file to be opened again for appending. A subsequent
will cause the existing file to be destroyed and then recreated
and will turn on the auxiliary output.
output by itself will cause the name and status (i.e., open
or closed) of the current auxiliary output file to be printed to the
The output to the console can be turned off and on using the
screen on commands. Output to the auxiliary file or device can be
turned off or on using the
output off or
output on command. The defaults
screen on and
The auxiliary file or device can be closed by an explicit
statement, by an end statement, or by an interactive new statement.
However, a new statement at the beginning of a program will not close
the file. This allows programs with new statements in them to be run
without reopening the auxiliary output file.
If a program sends data to a disk file, it will execute much faster if the window is off.
The outwidth command will set the line width of the output file. The default is 80.