Have a Question?
Print

00060: Alias line for printing to a file

Title:

Alias line example for printing to a file

Description:

To direct printer output to a file, use the following type of alias: 
alias PFIL $FILE "Output to File" CR,SPCOLS=255,CPCOLS=255,O_CREATE The O_CREATE ensures that the file is created if it doesn't exist.
Using this alias, open the printer as follows: 
open (99,mode="FILE=/tmp/prt/"+info(3,2))"PFIL"
Note that you can specify a default file on the alias line like so: 
alias PFIL $FILE "Output to File" CR,SPCOLS=255,CPCOLS=255,O_CREATE,FILE=C:/print.out

Adding the O_TRUNC mode on the alias line will cause any previous data in the file to be truncated when reusing a file. However, the O_CREATE and O_TRUNC modes are Operating System specific, and may not work under certain Operating Systems. Therefore, because portability is always a concern, this may not be the best method for your specific operating system.
Your application can define the file prior to opening the printer alias to ensure the file exists. You can create and truncate a file via a program similar to:

        10 filename$="/tmp/prt/"+info(3,2) 
        20 erase filename$,err=30 
        30 string filename$ 


Last Modified: 09/17/2024 Product: All Operating System: All platforms

BASIS structures five components of their technology into the BBx Generations.

Table of Contents
Scroll to Top