Complete subfile in C or C++ for the AS400
Thomas Burrows <[email protected]> Sun, 23 Jul 2023 22:48:52 -0500
| Newsgroups | gmane.comp.lang.as400.c |
|---|---|
| Message-ID | <CANFrdV8NUH5ZGTVeEPgE1+a24QQ-B6C3RAJBgKi9pnO9pTvATA@mail.gmail.com> |
Does anyone have a working example of a complete subfile in C or C++ for the AS400 Meaning: 1. Page down one specific page at a time 2. ADD 3. Change 4. Delete 5. Searchable headers. Below are my example of load to end with none changeable on a subfile in C or C++. Thomas Burrows -- This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list To post a message email: [email protected] To subscribe, unsubscribe, or change list options, visit: https://lists.midrange.com/mailman/listinfo/c400-l or email: [email protected] Before posting, please take a moment to review the archives at https://archive.midrange.com/c400-l.
t1520ddh.txt
(text/plain, 99 B)
R ENTRY
NAME 10A
PHONE 10A
t1520ddg.txt
(text/plain, 836 B)
A DSPSIZ(24 80 *DS3)
A CF03(03 'F3')
A*
A R SFL SFL
A NAME 10A B 10 25
A PHONE 10A B +5
A*
A R SFLCTL SFLCTL(SFL)
A SFLPAG(5)
A SFLSIZ(26)
A SFLDSP
A SFLDSPCTL
A*
A 21 25'<PAGE DOWN> FOR NEXT PAGE'
A*
A 22 25'<PAGE UP> FOR PREVIOUS PAGE'
23 25'F3 - EXIT'
DSPATR(HI)
t1520sub.txt
(text/plain, 2.6 KB)
/* This program uses _Ropen() to open subfile */
/* T1530DDG ad physical file T1520DDH */
/* The subfile is then initialized with records */
/* from the physical file */
/* Subfile records are written to the dispplng */
/* using the _Rwrited() function */
#include <stdio.h>
#include <stdlib.h>
#include <recio.h>
#define LEN 10;
#define NUM_RECS 20;
#define SUBFILENAME "*LIBL/T1520DDG"
#define PFILENAME "*LIBL/T1520DDH"
typedef struct
ä
char name^len!;
char phone^len!;
ü
pf_t;
#define RECLEN sizeof(pf_t)
init_subfile(pf, subf);
void init_subfile(_RFILE *, _RFILE *);
int main(void)ä
int num¬MAXLEN|; /* An array of digits. */
char letter??(MAXLEN??); /* An array of characters*/
/* Trigraphs replace the square brackets. */
_RFILE *pf;
_RFILE *subf;
/* Open the subfile and the physical file. */
if ((pf = _Ropen(PFILENAME, "rr")) == NULL)
ä
printf("can't open file %sÖn", PFILENAME);
exit(1);
ü
if ((subf = _Ropen(SUBFILENAME, "ar+")) == NULL)
ä
printf("can't open file %sÖn", SUBFILENAME);
exit(2);
ü
/* Initialize the subfile with records from the physical file */
init_subfile(pf, subf);
/* Write the subfile to the display by writing a record */
/* to the subfile control format. */
of main routine */ , "SFLCTL");
_Rwrite(subf, "", 0);
_Rreadn(subf, "", 0, __DFT);
/* Close the physical file and the subfile */
_Rclose(pf);
_Rclose(subf);
ü /*close of main routine */
void init_subfile(_RFILE *pf, _RFILE *subf)
ä
_RIOFB_T *fb;
int i;
pf_t record;
/* Select the subfile record format */
_Rformat(subf, "SFL");
for (i = 1; i <= NUM_RECS; i++)
/* open bracket level #1 */
ä
fb = _Rreadn(pf, &record, RECLEN, __DFT);
if (fb->num_bytes Ü= EOF)
/* open bracket level #2 */
ä
fb = _Rwrited(subf, &record, RECLEN, i);
if (fb->num_bytes Ü= RECLEN)
/* open bracket level #3 */
ä
printf("error occurred during writeÖn");
exit(3);
ü /* close bracket level #3 */
ü /* close bracket level #2 */
ü /* close bracket level #1 */