|
Alexei: Thanks for your help earlier. I was able to get the proper RRN. Now I have only one more question. I need to pass the resulting RRN back to the calling CL program. I am passing parameters into the C program (to get the file name, lib, etc) but now I need to know how to get the resulting number back to the CL. Thanks. /* */ /* */ #include <limits.h> #include <stdlib.h> #include <string.h> #include <decimal.h> #include <stdio.h> #include <recio.h> #include <xxfdbk.h> #include <errno.h> #pragma linkage(QDBCHEOD,OS) static _RFILE *forward; static char open_fwd_options[100] = "rr+ blkrcd=n riofb=y arrseq=y"; int main(int argc, char * argv[]) { _RIOFB_T * riofb_fwd; _XXOPFB_T * opnfb; char * file_name; char * file_rrn; decimal (15, 0) file_rrni; void ** p; unsigned long rrn1; int i, j; if (argc > 1) { file_name = argv[1]; /* first parm is the file name */ file_rrni = *((decimal (15, 0) *) argv[2]); /* second parm is the RRN */ } else { printf("Enter file name in format LIB/FILE(MEMBER): \n"); gets(file_name); gets(file_rrn); } /* open the file the first time to get basic information */ if ((forward = _Ropen(file_name,open_fwd_options)) == NULL) { printf("ERROR - file %s not found. \n",file_name); exit(EXIT_FAILURE); } opnfb = _Ropnfbk(forward); /* position the file to the requested RRN */ i = file_rrni; errno =0; /*riofb_fwd = _Rlocate(forward,NULL,i,__RRN_EQ|__NO_LOCK); */ riofb_fwd = _Rreadl(forward,NULL,0,__NO_LOCK); p = (void *)(forward); if ( errno == 0 ) { /* set the passed value to the rrn retrieved */ file_rrni = riofb_fwd->rrn; _Rclose(forward); exit(EXIT_SUCCESS); } else { _Rclose(forward); exit(EXIT_FAILURE); } } ++++++++++++++++++++++++++++++++++++++++++++ Go... FASTER! Without an upgrade! With ARCTOOLS/400(tm) http://www.arctools.com info@xxxxxxxxxxxx DCSoftware, Inc. Ph: (508) 435-8243 Fax: (508) 435-4498 ++++++++++++++++++++++++++++++++++++++++++++ ________________________________ From: c400-l-bounces@xxxxxxxxxxxx on behalf of Alexei Pytel Sent: Thu 9/30/2004 5:34 PM To: C programming iSeries / AS400 Subject: Re: [C400-L] Rreadl - finding last active RRN in a file In the open option string you specifically ask system not to update feedback area - riofb=n. static char open_fwd_optionsÝ100¨ = "rr+ blkrcd=n riofb=n arrseq=y"; This is how this option is defined: riofb=value Where value can be: Y All fields in the _RIOFB_T structure are updated by any I/O operation that returns a pointer to the _RIOFB_T structure. However, the blk_filled_by field is not updated when using the _Rreadk function. This is the default. N Only the num_bytes field in the _RIOFB_T structure is updated. Alexei always speaking for myself only Where is the beginning of the end, which ends the beginning? "David C. Shea" <dshea@xxxxxxxxxxxx> Sent by: c400-l-bounces@xxxxxxxxxxxx 09/30/2004 04:11 PM Please respond to C programming iSeries / AS400 To "C programming iSeries / AS400" <c400-l@xxxxxxxxxxxx> cc Subject [C400-L] Rreadl - finding last active RRN in a file I have been playing with Rreadl lately. Bear in mind that I'm not a C programmer... RPG, yes, but not C. But... I can cut and paste pretty well, and I can figure things out if I see enough examples. It's still pretty much Greek to me, but it's starting to sink in. According to the documentation I've seen, Rreadl is supposed to find the last active record in a file member. When it does this, it is supposed to return the RRN of the record found amongst other things. I have figured out how to execute this program, and it is, in fact, finding the last record in the file. I can get the buffer of the record to confirm that it is, in fact, the right record. I can get the buffer length from RIOFB_T, and that is correct. So, it appears that RIOFB_T is getting populated with some stuff. But... I'm not seeing anything in the rrn field in RIOFB_T. For some reason it's always coming back zero. I have tried printing the value with various flavors of field definitions, but that's not helping either. So... either I'm doing something wrong in my program, or I'm reading the docs wrong and Rreadl does not, in fact, return the RRN of the record that it found. Can anyone tell me what I'm doing wrong? The last active record in the file is at RRN 30. Here's the code I'm running: #include <limits.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <recio.h> #include <xxfdbk.h> static _RFILE *forward; static char open_fwd_optionsÝ100¨ = "rr+ blkrcd=n riofb=n arrseq=y"; int main(int argc, char * argvݨ) { /*_RIOFB_T * riofb_fwd; */ _RIOFB_T * fb; _XXOPFB_T * opnfb; char * file_name; void ** p; int i, j; if (argc > 1) { file_name = argvÝ1¨; /* first parm is the file name */ } else { printf("Enter file name in format LIB/FILE(MEMBER): \n"); gets(file_name); } /* open the file the first time to get basic information */ if ((forward = _Ropen(file_name,open_fwd_options)) == NULL) { printf("ERROR - file %s not found. \n",file_name); exit(EXIT_FAILURE); } opnfb = _Ropnfbk(forward); /* position to just after last data record in the file */ fb = _Rreadl(forward,NULL,0,__NO_LOCK); printf("RRN: %d. \n",fb->rrn); printf("RRN: %dl . \n",fb->rrn); printf("RRN: %UL . \n",fb->rrn); printf("RRN: %d . \n",fb->rrn); _Rclose(forward); exit(EXIT_SUCCESS); } and here's the output I'm getting: RRN: 0. RRN: 0l . RRN: L . RRN: 0 . Press ENTER to end terminal session. ++++++++++++++++++++++++++++++++++++++++++++ Go... FASTER! Without an upgrade! With ARCTOOLS/400(tm) http://www.arctools.com info@xxxxxxxxxxxx DCSoftware, Inc. Ph: (508) 435-8243 Fax: (508) 435-4498 ++++++++++++++++++++++++++++++++++++++++++++ _______________________________________________ This is the C programming iSeries / AS400 (C400-L) mailing list To post a message email: C400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/c400-l or email: C400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/c400-l. _______________________________________________ This is the C programming iSeries / AS400 (C400-L) mailing list To post a message email: C400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/c400-l or email: C400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/c400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 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.