ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Passing Parameters driving me crazy - Pointer not set for location referenced

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

  • Passing Parameters driving me crazy - Pointer not set for location referenced

    I created two module then bound them to an executable PROGB. When executed, i get "Pointer not set for location referenced. " This should be so simple to fix but I do not see the issue. Thoughts?

    PROGRAM PROGB -calling program

    Ctl-Opt DEBUG OPTION(*SRCSTMT);
    D PROGA PR Extpgm('PROGA')
    D 2 0
    D 9 0
    D $Xacmp s 2 0
    $Xacmp = 1;
    Callp PROGA($Xacmp);
    dsply %char($Xacmp);
    *inlr = *on ;

    PROGRAM PROGA -called program

    Ctl-Opt DEBUG OPTION(*SRCSTMT);
    D PROGA pr
    D $Xacmp 2 0
    D PROGA pi
    D $Xacmp 2 0
    $Xacmp = 02;
    return;​

    CRTRPGMOD MODULE(*LIBL/PROGA) SRCFILE(*LIBL/QRPGLESRC) DBGVIEW(*ALL
    CRTRPGMOD MODULE(*LIBL/PROGB) SRCFILE(*LIBL/QRPGLESRC) DBGVIEW(*ALL
    CRTPGM PGM(*LIBL/PROGB) MODULE(*LIBL/PROGA *LIBL/PROGB) BNDSRVPGM((*N *IMMED)) ACTGRP(*NEW)
    STRDBG PGM(*LIBL/PROGB) UPDPROD(*YES)
    CALL PGM(*LIBL/PROGB)

    *PS: SORRY ABOUT THE FIXED LOCATIONS BEING WIPED OUT. ​

    Thank for you responses. I gave up on this version and rewrote in RPGILE always free and it worked the first time.
    Last edited by Ray14506; September 14, 2022, 07:51 AM. Reason: I APOLOGIZE.  I POSTED THE WRONG VERSION OF PROGB, D 9 0 WAS NOT IN MY LAST TEST.  It was removed although it still did not work. 

  • #2
    In "old" RPG, you'd use *ENTRY to designate incoming PARMS. Do you need the equivalent in your code ?

    Comment


    • #3
      Ccompare PROGB's prototype for PROGA with PROGA.

      Comment


      • #4
        In PROGA this:
        Code:
        D PROGA       pr
        Should be:
        Code:
        D PROGA       PI
        As MFisher noted you need the PI because it is the equivalent of an *Entry PLIST. I would say "in modern RPG" but you're coding in fixed format ...
        And the CALLP is superfluous - just delete it. You only need it when you need the call to set the error indicator i.e. CALLP(E)

        With regard to retaining formatting you simply wrap your code in code blocks as I did above. That is the word code wrapped in square brackets. With a matching /code ending tag.

        Comment


        • #5
          The prototypes for PROGA in the 2 programs should be identical (as UserName10 noted). Instead you have this for PROGB:
          Code:
          D PROGA           PR                  extpgm('PROGA')
          D                                2  0
          D                                9  0
          and this for PROGA:
          Code:
          D PROGA           pr
          D $Xacmp                         2  0​
          You have an extra parameter in the PROGA prototype in PROGB, which shouldn't even compile.

          Comment


          • #6
            There are several issues with your program. I also thought I'd reformat this so we can actually read it. You can do this yourself by wrapping your code in code tags. This can be done by highlighting the code and pressing the # button on the toolbar.

            This is program B.
            Code:
                   Ctl-Opt DEBUG OPTION(*SRCSTMT);
                 D PROGA           PR                  ExtPgm('PROGA')
                 D                                2  0
                 D                                9  0
            
                 D $Xacmp          S              2  0
            
                   $Xacmp = 1;
                   Callp PROGA($Xacmp);
                   dsply %char($Xacmp);
                   *inlr = *on;

            This is program A.
            Code:
                   Ctl-Opt DEBUG OPTION(*SRCSTMT);
                 D PROGA           pr
                 D $Xacmp                         2  0
            
                 D PROGA           pi
                 D $Xacmp                         2  0
            
                   $Xacmp = 02;
                   return;
            ​
            This is the final compile command that creates your program:
            Code:
            CRTPGM PGM(*LIBL/PROGB) MODULE(*LIBL/PROGA *LIBL/PROGB) BNDSRVPGM((*N *IMMED)) ACTGRP(*NEW)
            The first issue is you have said that program PROGB is the calling program. However, in your compile command the default for the entry program is *FIRST (the first program in the list with a PEP). As both have a PEP, PROGA is listed first so will be the PEP. You can see this if you issue a DSPPGM PROGB. So, when you call PROGB, module PROGA actually gets executed. You would need to swap the order of the modules in the compile command to list PROGB first. Because of this you need to pass a parameter when you call the program which is why you are getting the error when you attempt to call it.

            The second issue is as others have mentioned, the prototype in PROGB for module PROGA contains 2 parameters. The Prototype and procedure interface in PROGA only contains 1. These need to match.

            The third issue which is related to the 2nd one, is your CALLP statement is only passing one parameter. Your prototype says it requires 2. However, due to the mix up in parms between PROGB and PROGA we can't tell what it should be.

            Other things of note.
            The prototype in PROGA is superfluous in modern RPG. The compiler will use the procedure interface to create it.
            I'm surprised PROGB compiles as you haven't specified a procedure interface there and you really should but it interestingly does. Maybe it's OK because no parameters are passed.
            Last edited by john.sev99; September 13, 2022, 04:00 PM.

            Comment


            • Brian Rusch
              Brian Rusch commented
              Editing a comment
              PROGB wouldn't compile for me because the PROGA prototype requires 2 parameters and the call of PROGA only provides 1.

            • john.sev99
              john.sev99 commented
              Editing a comment
              Oops, you're right, it wouldn't compile for me either unless I added an extra parm to the callp....

          • #7
            Thank for you responses. I gave up on this version and rewrote in RPGILE always free and it worked the first time.

            Comment

            Working...
            X