ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Calling a prototyped program

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

  • Calling a prototyped program

    Hi I am trying to call a prototyped program (lets say b)using callp in A.

    All the sources were compiled properly.but i did not add the export keyword.(to be added on p-spec) ,i did not add the begin and end of the procedure(cause i treat it as a program)

    i have coded the PR & PI in Program B, when i am trying to put b in debug it says

    'Cannot resolve to object' pointer stuff..

  • #2
    Re: Calling a prototyped program

    Make sure the program name on your ExtPgm('NAME-HERE') is in all uppercase.

    If that's not the problem, you'll need to post the PR/PI and the actual error message.

    Comment


    • #3
      Re: Calling a prototyped program

      Originally posted by Scott Klement View Post
      If that's not the problem,...
      Library list?
      Tom

      There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

      Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

      Comment


      • #4
        Re: Calling a prototyped program

        Originally posted by Scott Klement View Post
        Make sure the program name on your ExtPgm('NAME-HERE') is in all uppercase.

        If that's not the problem, you'll need to post the PR/PI and the actual error message.
        Thx a lot Scott wasted a lot of my time Kindly let me know the reason it should be in upper case

        Comment


        • #5
          Re: Calling a prototyped program

          Originally posted by satya View Post
          Kindly let me know the reason it should be in upper case
          Because program names are upper-case and you're referencing a program name when you specify EXTPGM().
          Tom

          There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

          Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

          Comment


          • #6
            Re: Calling a prototyped program

            Many people do not know this, but the operating system can use case-sensitive (mixed-case) names. If you use a name like that, then you need to specify it in upper/lower case. (However, in my experience, nobody uses this feature.)

            For example, let's say I have a very simple RPG program. This is member TESTME of my QRPGLESRC file:
            Code:
            /free                       
               dsply ('test test test');
               *inlr = *on;             
            /end-free
            When I compile it, I can do this:
            Code:
            CRTBNDRPG PGM("testMe") SRCFILE(QRPGLESRC) SRCMBR(TESTME)
            Now if I do WRKOBJ TESTME, it does not find it.

            But if I do WRKOBJ "testMe" it does -- it's now in lowercase, not all-uppercase like we're used to:
            Code:
                                           Work with Objects                               
                                                                                           
             Type options, press Enter.                                                    
               2=Edit authority        3=Copy   4=Delete   5=Display authority   7=Rename  
               8=Display description   13=Change description                               
                                                                                           
             Opt  Object      Type      Library     Attribute   Text                       
                  "testMe"    *PGM      SKTEST      RPGLE
            So that is the reason you have to type the program name in all uppercase when using ExtPgm(). By default (if you don't use the mixed case approach) everything is all uppercase, but since the operating system supports mixed upper/lowercase names, RPG has to support them too.

            (The old CALL/PARM opcodes from RPG/400 had the same issue.)

            Comment


            • #7
              Re: Calling a prototyped program

              I suspect it's mainly an issue to allow because of JAVA and C where mixed case is standard - which allows for the other program languages to used mixed cases as Scott mentioned.

              Comment


              • #8
                Re: Calling a prototyped program

                Rocky, Java/C are not case-sensitive in program names (except on Unix where everything is case sensitive). They are case-sensitive on function/method calls (aka subprocedures) but this discussion is about ExtPgm rather than ExtProc.

                Comment


                • #9
                  Re: Calling a prototyped program

                  Thanks for the clarification Scott - I figured that since Java is case sensitive elsewhere it would be on IBM i as well - obviously a bad assumption...

                  Comment


                  • #10
                    Re: Calling a prototyped program

                    @Scott:

                    Yep, many mixed-case object names are possible as long as quoted properly. Once properly quoted, you're generally not even limited to the usual letters/digits class of characters. Probably not a very good idea to think about doing it, though, for the vast majority. I've had to code monitoring/auditing products to account for the extremely rare case where some odd site somehow chose to create a non-standard object. Always makes things 'interesting'.
                    Tom

                    There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

                    Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

                    Comment


                    • #11
                      Re: Calling a prototyped program

                      If you are on 7.2 or on 7.1 and have the PTFs that allow free-form H, F, D and P specs, you can specify EXTPGM without a parameter as long as the prototype name is the same as the program name (even in fixed form). The compiler will uppercase the prototype name and use that as the EXTPGM.

                      For this prototype, it will call *LIBL/MYPGM.
                      Code:
                      D mypgm           pr                  extpgm
                      So now you only need to specify the EXTPGM parameter if the prototype name is different, or you want to specify the library, or the program name is in a variable.
                      Code:
                      D getPriceQuote   pr                  extpgm('XBZ02231')
                      D mypgm           pr                  extpgm('MYLIB/MYPGM')
                      D somepgm         pr                  extpgm(pgmToCall)
                      Last edited by kitvb1; January 16, 2015, 02:33 AM. Reason: fixed code tags

                      Comment

                      Working...
                      X