ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Passing Parameters

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

  • Passing Parameters

    Sorry for many questions - I am new to RPG free.

    How do you pass a value back to a calling CL program.. and visa-versa? i.e. parameters and return code..

    Thanks
    www.midlifegamers.co.uk

  • #2
    Re: Passing Parameters

    I think, you want to pass parameters to The main procedure..
    Code:
    H DFTACTGRP(*NO)                                 
                                                     
    D myRPGname      PR                             
    d  Input1                        3               
    d  Input2                        3               
    d  OutPUT                        6               
                                                     
    D myRPGname       PI                             
    d  Input1                        3               
    d  Input2                        3               
    d  OutPUT                        6               
                                                     
     /free                                           
           *Inlr = *on;                              
             Input1 = 'AAA';                         
             Output = Input1 + Input2;               
           return;                      
     /end-free
    Code:
              PGM                                                        
    
              DCL        VAR(&INPUT1) Type(*CHAR) Len(3) Value('XXX')    
              DCL        VAR(&Input2) Type(*Char) Len(3) Value('BBB')    
              DCL        VAR(&OutPUT) Type(*Char) Len(6)                 
                                                                         
    
              CALL       PGM(myRPGname) PARM(&INPUT1 &INPUT2 &OUTPUT)      
    
              SNDPGMMSG  MSG(&output)                                    
    
              endpgm

    Comment


    • #3
      Re: Passing Parameters

      pssst...

      vice versa

      but keep it quiet... no-one will notice.
      Regards

      Kit
      http://www.ecofitonline.com
      DeskfIT - ChangefIT - XrefIT
      ___________________________________
      There are only 3 kinds of people -
      Those that can count and those that can't.

      Comment


      • #4
        Re: Passing Parameters

        Originally posted by dhanuxp View Post
        .. snip..
        Many thanks for that. Ok this compiles but I get an error on the call from the CLP:

        Code:
        MCH3601    Escape                  40   06/07/10  09:35:43.211688  APM10G       BLBTSTLIB5  *STMT    APM10G 
                                             From module . . . . . . . . :   APM10G                                 
                                             From procedure  . . . . . . :   APM10G                                 
                                             Statement . . . . . . . . . :   285                                    
                                             To module . . . . . . . . . :   APM10G                                 
                                             To procedure  . . . . . . . :   APM10G                                 
                                             Statement . . . . . . . . . :   285                                    
                                             Message . . . . :   Pointer not set for location referenced.           
                                             Cause . . . . . :   A pointer was used, either directly or as a basing 
                                               pointer, that has not been set to an address.
        This is the code:

        Code:
        d APM10G          pr                                                       
        d  RtnCndFnd                     1                                         
                                                                                   
        d APM10G          pi                                                       
        d  RtnCndFnd                     1
        From CLP:

        Code:
                     DCL        VAR(&ALERTCOND) TYPE(*CHAR) LEN(1)               
        /* Check for Jobs...                                                  */     
                     CALL       PGM(APM10G) PARM(&ALERTCOND)
        Any idea what I'm doing wrong? Thanks
        www.midlifegamers.co.uk

        Comment


        • #5
          Re: Passing Parameters

          Strange.. If I call the program using this:

          Code:
          PGM                                                        
                       DCL        VAR(&NUM) TYPE(*CHAR) LEN(1)       
                       DCL        VAR(&NUM2) TYPE(*CHAR) LEN(1)      
                       CALL       PGM(APM10G) PARM(&NUM)             
                       CHGVAR     VAR(&NUM2) VALUE(&NUM)             
          ENDPGM
          it works
          www.midlifegamers.co.uk

          Comment


          • #6
            Re: Passing Parameters

            Crazy - I fixed it.

            I changed the parameter name in the CLP from &ALERTCOND to &NUM and it worked ?????????
            www.midlifegamers.co.uk

            Comment

            Working...
            X