Re: C program for QDFRTVFD API
Jevgeni Astanovski <[email protected]>
| Newsgroups | gmane.comp.lang.as400.c |
|---|---|
| Message-ID | <CAJuVQr3m3-xT6D1AHorAY4T8Gv_jCmYqgpim0=HGWisXxseC9w@mail.gmail.com> |
Frank, After careful examining of your DISPINFOC1 program I should say that probably you misunderstood the idea of using user space. Currently your program is not simply inefficient, but it is "dangerously" inefficient in case you apply it to display files having really big number of fields. I had a look at our vendor's system and it has DSPF-s with hundreds fields. By the time you are retrieving field nr. 300, you will call API 600 times and will step 45000 times from one field to the next one. What was advised is the approach that I use in all cases where your program is called in the same way as in your case: 1. Give me first; 2. Give me next; 3. Give me next; ..... N. Give me next. In this case on the first call program gets ALL the data required and places it into the user space - possibly in a structured way. If you are returning X numbers and Y strings, you just define a structure and place these structures one after another into the user space (in your case structure can be FieldData_t). Additionally in the beginning of the user space I place 2 integers: one keeps a length of actual data (or you can keep total number of data units) and a second points to the first yet unsent data unit. So after the first call (give me first) you fill the user space by a number of FieldData_t structures (for all fields). And put the 2 integers in the beginning appropriately. Then you send out the first structure and increment the pointer to the first unsent structure. When you get "give me next" call, you do not call QDFRTVFD any more! You rather get the user space and send away the first unsent structure and increment the pointer. If the pointer to the next reached the end, you inform the caller about that with the last structure. This is one of the possible solutions using user space. On Wed, Sep 17, 2014 at 2:13 PM, Frank Kolmann <[email protected]> wrote: > Hi > > Thanks Gary and Charles for your suggestions. > FWIW I have updated the site with 2 additional versions, one using User > Space the other as C module. > > The module was a bit harder to code because the C code remained in the > ACTGRP so I needed to have a CLLE to do a RCLACTGRP. > > > Regards > Frank > -- This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list To post a message email: C400-L-Zwy7GipZuJhWk0Htik3J/[email protected] To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/c400-l or email: C400-L-request-Zwy7GipZuJhWk0Htik3J/[email protected] Before posting, please take a moment to review the archives at http://archive.midrange.com/c400-l.