• Subject: Re: Printer file usage question
  • From: "Simon Coulter" <shc@xxxxxxxxxxxxxxxxx>
  • Date: Sun, 29 Apr 01 11:56:13 +1000

Hello Jevgeni,

You wrote:
>May be this question is as easy as most things in this 400 world -
>when you know an answer.

Yes, it is easy.  But it is more a matter of knowing where to look.  It's 
just another case of RTFM.  Read on ...

>But still:
>I'm writing a program, that must generate a report. It has a header
>and plenty of rows. All these rows probably will not fit into the
>page, I defined while creating a print file via STRRLU.
>So I thought, that it will be nice to place a header on each new
>page. Isn't it obvious?

Yes.  Obvious and standard practice.

>But how does the program, that makes _Rwrite to print file, knows,
>when new page should start.

_Rwrite updates the I/O feedback area which returns information about the 
write operation.  There are C functions that will return addressability to 
the feedback areas.  See below.

>I now know only one stupid way - place a counter and increment it
>each time I make _Rwrite, then compare it to page size in rows. If
>equal (or something like that), reset it, place header and go on.
>Seems ugly :-(((.

Yes. It is ugly and doesn't allow for the overflow line which is generally 
not the same as the number of lines per page.

>May be there is some sort of feedback from _Rwrite, that shows, that
>last row is placed on the page?

You are on the right track.  The ILE C Programmers Guide discusses both the 
Open Feedback Area and the I/O Feedback Area in sections 4.19 and 4.29.  
These sections even tell you where to find the include that maps the various 

<=================== Excerpt from ILE C Programmer's Guide (c) IBM =======>
4.19  Open Feedback Area

 The open feedback area is part of the open data path that contains
 information about the open file that is associated with that open data
 path. You can assign a pointer to this information by using the _Ropnfbk()
 function. See the Data Management manual for more information on the
 fields contained in the open feedback area. The structure that maps to the
 open feedback area can be that is found in the xxfdbk.h header file.

4.20  I/O Feedback Area

 The I/O feedback area is a part of the open data path for the file that is
 updated after each successful non-blocked I/O operation. If record
 blocking is taking place, the I/O feedback is updated after each block of
 records is transferred between your program and the Data Management

 The I/O feedback consists of two parts: one part that is common to all
 file types, and one part that is specific to the type of file.

 To assign a pointer to the common part of the I/O feedback area, use the
 _Riofbk() function. To assign a pointer to the part of the I/O feedback
 area that is specific to the type of file, add the offset contained in the
 file_dep_fb_offset field of the common part to a pointer to the common

 Note:  The offset is in bytes, so you need to cast the pointer (char *) to
        the common part to a pointer to character when performing the
        pointer arithmetic. See the Data Management manual for information
        on the I/O feedback areas. The structures that map to the I/O
        feedback areas are that are contained in the xxfdbk.h header file.
<=================== End of Excerpt =====================>

The Open Feedback Area will tell you how many lines are available on the 
page  (in a field called rows) and the overflow line (in a field called 
overflow_line_num).  The overflow line is generally not the same as the 
number of lines on the page and this value can be overridden via OVRPRTF.

The printer I/O Feedback Area will tell you the current line number (in a 
field called cur_page_line_num) and the page count (in a field called 

It is a trivial matter to check whether the cur_page_line_num is >= to the 
overflow_line_num and write the header record thus causing a new page.

A description of the Open Feedback Area and the I/O Feedback Area can be 
found in Appendix A of the Data Management Guide (now mved to the 
disInformation Centre).

The ILE C Programmer's Guide and the ILE C Reference Manual have examples of 
using the feedback area in the database section.  Using the feedback area 
with a printer file is identical.

Simon Coulter.

 FlyByNight Software         AS/400 Technical Specialists       
 Eclipse the competition - run your business on an IBM AS/400.  
 Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\   
 Fax:   +61 3 9419 0175   mailto: shc@flybynight.com.au   \ /   
               ASCII Ribbon campaign against HTML E-Mail  / \   

| This is the C/400 Mailing List!
| To submit a new message, send your mail to C400-L@midrange.com.
| To subscribe to this list send email to C400-L-SUB@midrange.com.
| To unsubscribe from this list send email to C400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: bob@cstoneindy.com

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2021 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.