Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Api/Pointer help needed

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Api/Pointer help needed

    Hi, I am trying to learn how to use api's and pointers. I took an example from Robin Kilma's book API concepts but ran into a problem. When using the list fields api QUSLFLD an array is used. This works fine until the array limit is met. Is there a way to reposition the pointer/array(?) Below is the code. I know there are different and probably better ways to code this but this will give me a better understanding. Thanks for any help. fGotAHit2 o e Disk d spacePtr s * d headerPtr s * d listPtr s * d userSpace ds Based(spacePtr) d data 1 116 d offSetHdr 117 120b 0 d offSetLst 125 128b 0 d numLstEnt 133 136b 0 d entrySize 137 140b 0 d header ds Based(headerPtr) d fileName 1 10 d librName 11 20 d fileType 21 30 d rcdFormat 31 40 d list ds Based(listPtr) d fldName 1 10 d dataType 11 11 d length 21 24b 0 d digits 25 28b 0 d decPos 29 32b 0 d text 33 82 * Parms for creating the userspace * d spaceName s 20 Inz('DSPFFDSPC QTEMP ') d Attr s 10 d initSize s 9b 0 Inz(1024) d initValue s 1 d aut s 10 d usText s 50 d replace s 10 d errCode s 9b 0 Inz(0) * Parms for calling QUSLFLD api * d format s 8 d inpFilLib s 20 Inz('TCPCUST *LIBL ') d Override s 1 d rcdFormat2 s 10 c Exsr crtUsrSpc c Exsr callApi c Exsr Process c Exsr dltUsrSpc c Eval *Inlr = *On ************************************************** ************ * Subroutine: crtUsrSpc * * Purpose: Creates the userspace for the QUSLFLD api. * ************************************************** ************ c crtUsrSpc BegSr c CALL 'QUSCRTUS' c PARM spaceName c PARM *BLANKS Attr c PARM InitSize c PARM *BLANK InitValue c PARM '*CHANGE' Aut c PARM usText c PARM '*YES' Replace c PARM ErrCode c Endsr ************************************************** ************ * Subroutine: callApi * * Purpose: Calls the QUSLFLD api. * ************************************************** ************ c callApi BegSr C CALL 'QUSLFLD' 99 C PARM spaceName C PARM 'FLDL0100' format C PARM inpFilLib C PARM '*FIRST' rcdFormat2 C PARM '1' Override c Endsr ************************************************** ************ * Subroutine: Process * * Purpose: Process the records from the userspace * ************************************************** ************ c Process BegSr * Retrieve pointer to userspace c Call 'QUSPTRUS' c Parm spaceName c Parm spacePtr * Get Heading information c Eval headerPtr = %ADDR(data(offSetLst + 1)) * Repeat for each entry in the List Data section c Do numLstEnt c If offSetLst + entrySize > 32767 c************* Exsr PosnFld c Endif * Get detail information **** WHEN THE DATA ARRAY GOES OVER 32767 THE PROGRAM BOMBS. c Eval listPtr = %ADDR(data(OffSetLst + 1)) * Load workfile fields and write c Eval outFld = fldName c Eval outTxt = text c If digits = 0 c Eval outLen = length c Else c Eval outLen = digits c Eval outDec = decPos c Endif c Write hit2 * Get location of next entry c Eval offSetLst = offSetLst + entrySize c Enddo c Endsr

  • #2
    Api/Pointer help needed

    Sorry. It looked better when I copied it in. Also the "data" field is actually an array defined as 1 byte with 32767 elements. I was playing around with it and forgot to change it back.

    Comment


    • #3
      Api/Pointer help needed

      Hello Lar sab, The technique you're describing is how you would do it before pointer arithmetic was introduced in RPG/IV - V3R7?. I've attached an example that lists all spoolfiles in a job and sends them to a specific user - directly manipulating the list pointer when reading through the list. Best regards, Carsten Flensburg

      Comment


      • #4
        Api/Pointer help needed

        Thanks Carsten. I'll have a look at it

        Comment


        • #5
          Api/Pointer help needed

          Thanks Carsten, a few changes in my program and it worked!

          Comment


          • #6
            Api/Pointer help needed

            Hi C, Nice solution you posted here (some years ago). I've been wrestling with this problem all day started off first thing with an idea to make a version of this list api to use with cgi pgms, I got the example from a recent publicication RPG IV and ILE (by RK). It seems you have this problem under control. I also noted the same example, pretty much, as posted by Lars, excerpt 2001. I guess these authors get lazy to update their routines. Oh well. Is it possible I can see an example of how to change this array solution into a pointer arithmetic version that works? Thanks for the proper guidance!

            Comment

            Working...
            X