since hours today, I'm fighting with what normally seems a simple task: Open file, read, print to stdout, next, until EOF. End program.
Before bothering anyone with multiple questions, I'm asking if there is an example C program source for IBM i in existence. I'm also fine with some online source I overlooked.
My goal is very simple. A bit like filling a load-all subfile in RPG.
- Open an external described database file for reading (done, _Ropen, _Rformat, works)
- Set the file pointer to the first record, the equivalent to SETLL *LOVAL in RPG (just to be sure to not have interesting effects because of activation group hassles) — I added an extra call to _Rreadf, but his seems ugly
- Loop over the file with _Rreadn until EOF; then jump out of the loop (partly done; is num_bytes in _RIOFB_T being 0 really the only way to deduct EOF?)
- The record is now in the buffer being derived by #pragma mapinc to a struct and in turn defining a variable of that struct's type. This basically works, but I still have more data than just one field being output, thus: Any special handling for fixed-length strings vs. zero-terminated strings necessary?
- Any special handling for numerics? I have a field designated "4S 0" for a year in my PF.
- Any special handling for conversion of EBCDIC vs. ASCII? I guess the http server does this.
If desired, I can publish what I've done so far with all the compilation steps, and the PF DDS, if this would help explanations.
With what I have currently, only one line is read, and the raw output from the static buffer shows the record with some extra bytes.
My problem is again how IBM organizes documentation. Either it's very broad, describing just an overview, or very precise, showing how a step is to be done. The in-between is missing: How to arrange these steps (and, also important, which steps to take!) to achieve something.
Ah, if this is in any way important: I'm a hobbyist, trying this deliberately on an old system (a 150) with V4R5. So far, the current documentation on the IBM website in regard to the functions shown above seems to be still valid.
Thank you very much!
As an Amazon Associate we earn from qualifying purchases.
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
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.