45 pts.
 Writing in a specific output queue in C/400
Dear all, I need one more time your help... Well, I'm starting to learn C/400 programmation and I would like in my program to log all my traces in a specific output queue (not in the standard QPRINT output queue). I found a solution by changing the default output queue and using the simple printf... But I don't want to change the standard output queue... I made some test trying to open the output queue file and using fprintf... but it was not working. I hope you'll be able to help me and perhaps give me an example. Thanks in advance, Pierre

Software/Hardware used:
ASKED: June 20, 2006  6:19 AM
UPDATED: June 21, 2006  7:31 AM

Answer Wiki:
Pierre, there is no OUTQ file on OS/400, there is only a print file which is attached to an OUTQ. By default OS/400 identifies the C streams STDOUT and STDERR with file QPRINT. Unless you have changed it, this will point at output queue QPRINT as well. To use a different file or output queue you will have to issue and OVRPRTF for the file STDOUT and/or STDERR. You then have the option of using the system defined QPRINT file or some other one and placing it on a different queue. Specify OVRPRTF (STDOUT) OUTQ(lirary/queue) where 'queue' is the name of the OUTQ you want to send output to and 'library' is the library containing it. You might need to put this in a CL program before your C program runs or you may get away with using the 'system' function to execute the command as the first thing your C program does - I haven't tried it myself so don't know. Hope this helps
Last Wiki Answer Submitted:  June 20, 2006  7:15 am  by  Alasdair727   0 pts.
All Answer Wiki Contributors:  Alasdair727   0 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Ok, thanks for the information… Now I understand a little bit more how it’s working.
As I don’t want to change the standard output queue for the other programs running on the AS/400, I don’t think your solution should be used.
What I’m looking for is a way in C/400 to open a printer file (of the type *OUTQ) in a specific directory and be able to read and write logs.
Thanks one more time for your support.

Pierre.

 45 pts.

 

Hi Pierre,
I don’t think you understood alasdair727 recommendation.
The OVRPRTF command does not change the system supplied QPRINT file.
It only says: for this job, whenever you write data to printer file QPRINT, route it to a new OUTQ.
While doing so, all your STDOUT (printf calls) will be printed into a spooled file that is attached to the new OUTQ.
In the OVRPRTF, you can also rename the spooled file name so it will not be called QPRINT:
OVRPRTF FILE(QPRINT) OUTQ(library/queue) SPLFNAME(newname)

If you do not want to use QPRINT at all, you can create your own printer file (using the CRTPRTF command with similar parameters to the OVRPRTF).
In your C program, you can open the file you created using the fopen(“*LIBL/myfile”) and perform write operation to your open file descriptor.
Because this printer file is on the QSYS file system and not IFS file, you must compile your C module (CRTCMOD) with the following option: SYSIFCOPT(*NOIFSIO)

Hope this helps

 0 pts.

 

Hi Pierre,
I don’t think you understood alasdair727 recommendation.
The OVRPRTF command does not change the system supplied QPRINT file.
It only says: for this job, whenever you write data to printer file QPRINT, route it to a new OUTQ.
While doing so, all your STDOUT (printf calls) will be printed into a spooled file that is attached to the new OUTQ.
In the OVRPRTF, you can also rename the spooled file name so it will not be called QPRINT:
OVRPRTF FILE(QPRINT) OUTQ(library/queue) SPLFNAME(newname)

If you do not want to use QPRINT at all, you can create your own printer file (using the CRTPRTF command with similar parameters to the OVRPRTF).
In your C program, you can open the file you created using the fopen(“*LIBL/myfile”) and perform write operation to your open file descriptor.
Because this printer file is on the QSYS file system and not IFS file, you must compile your C module (CRTCMOD) with the following option: SYSIFCOPT(*NOIFSIO)

Hope this helps

 0 pts.