ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Compile RPGLE effect

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

  • #31
    I still confused about how using user space can only need once to retrieve its value. I think the user space is same with data area but with more large size and better performance. This is what i think : - set user space value to pgm1v001 (example) - change pgm1 and recompile it - set user space value again to pgm1v002 - pgm caller : Dow forever { Get user space value; If last US value current US value { Last user space value = current user space value; pgmname = dummypgm; Call pgmname; pgmname = pgm1; Call pgmname; }Else; Call pgmname; } } I am curious about that because i need to implement the program change soon to prod env, and still with old style. I am afraid the job will be MSGW. (Reply using mobile phone, sorry if the format is not good)

    Comment


    • #32
      You are not correct. As I said earlier using a data area requires that you perform an RPG IN operation before each-and-every call. With a User space you resolve the pointer once during program initialization and that is it. So one operation during initialization compared with an operation on each and every call.

      I can't really read your code due to formatting but I _think_ this is what you said:
      Code:
      Dow forever;
        Get user space value;
         If last US value current = US value;
            Last user space value = current user space value;
            pgmname = dummypgm;
            Call pgmname;
            pgmname = pgm1;
            Call pgmname;
       Else;
           Call pgmname; 
       EndIf;
      EndDo;
      The only thing I would change is to remove the Else and place the Call pgmname; outside the If block. You need to do it anyway.

      There is no reason to suppose that you will have any problems with this approach BUT you can avoid MSGW simply by handling the problem yourself. You can do this by adding an (E) extender to the call and checking %Error after the call (this is the current version of the old error indicators used in your original code I think). You could also use a MONITOR block and trap any error that way. But trapping the error is not enough by itself as all it does is prevent the MSGW. Having detected it you need to take steps to a) resignal the dataqueue message (or whatever triggered the program in the first place) and b) Kill the job so it will all start over.

      Comment


      • #33
        This is the code that I mean :
        Code:
        pgmname = pgm1;
        Get user space value;
        Save to Last user space value;
        Dow forever;
           Get user space value;
           If last User Space value <> current User Space value;
               Last user space value = current user space value;
               pgmname = dummypgm;
               Call pgmname;
               pgmname = pgm1;
               Call pgmname;
           Else;
               Call pgmname; 
           Endif;
        EndDo;
        I am still learning to post tidy format.

        Comment


        • #34
          My comments are the same. Delete the Else and move Call pgmName outside of the If.

          If you are using a User Space there is no "Get user space value;" value required. The value will just "be there". You would define the variable holding it to be (for example):
          Code:
          dcl-s  programVersion  timestamp  Based(p_programVersion);
          In the program initialization logic you would use code like this and add the storage logic currently ahead of your Do loop:
          Code:
          dcl-pr GetPointer extpgm('QUSPTRUS') ;
             *n char(20) const ; // Name
             *n pointer ; // Pointer to user space
             *n char(32767) options(*varsize:*nopass) ; // Error feedback
          end-pr ; 
           GetPointer('@USRSPACE QTEMP': p_programVersion ) ;
          I "borrowed" that code from this article if you want to see the whole picture http://www.rpgpgm.com/2014/08/user-s...roduction.html

          NOTE: As I said before the "Dummy" program MUST exist for this whole thing to work.

          Comment


          • #35
            Oh I see Jon, there is API to get user space pointer.
            I only know API to create/retrieve/change user space.
            I am not familiar with how to declare file/field/prototype/etc in free format. What does *n mean?

            Comment


            • #36
              *N just means that you are not supplying a name. In fixed form you would just leave the columns blank - but in free the compiler needs to know when the name ends.

              In fixed form it looks like this:
              Code:
                   d GetPointer      Pr                  extpgm('QUSPTRUS') ;
                   d                               20a   const
                   d                                 *
                   d                            32767a   options(*varsize:*nopass)

              Comment

              Working...
              X