Set print or export file name

Command group Flag affected Reversible Execute on client Platform(s)
Report destinations YES YES NO All

Syntax

Set print or export file name {file-name}

Description

This command specifies the print file name to which printed output is to be directed. The flag is set if the print file is successfully selected. If you use Set print or export file name in a reversible block, the print file is closed when the method containing the reversible block terminates.

Set print or export file name closes the current print or export file, if any, and then opens the specified file. The property $root.$prefs.$appendfile determines how the file is opened. Either new data is appended to the current content, or the file is truncated to zero length.

Once the file name has been specified, Send to file directs the report output to the file. As each report is printed, its output is added to the end of the last report in the file.

If an error occurs, then this command sometimes generates a fatal error. You can use an error handler to intercept the fatal error; see Load error handler for details.

Example

If platform()='X'
Set print or export file name {/Work/Output file2} ;; macOS
Else
Set port name {C:\work\output2.prn} ;; Windows & Linux
End If
Send to file
Set report name rMyReport
Print report
Close print or export file