× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: How to prototype CL modules
  • From: "Simon Coulter" <shc@xxxxxxxxxxxxxxxxx>
  • Date: Tue, 18 Jul 00 11:24:37 +1000

A
Hello Leslie,

Scott is correct.  CONST should only be used on input parameters.  It allows 
you to 
specify literals, and values with a size different FROM the size defined on the 
prototype.  Using CONST in this fashion would cause the compiler to allow a 
call of the 
form:
        CALLP   QmhSndPgmMsg('CPF9898' :
                             'QCPFMSG   *LIBL' :
                             'Hello World!' :
                             12 :
                             '*ESCAPE   ' :
                             '*' :
                             0 :
                             '    ' :
                             errCode )

Although the compiler will allow that statement, QMHSNDPM will try and update 
the 
storage which currently contains the 4 blanks, resulting in at best lost values 
and at 
worst a runtime exception.  Without the CONST on the 8th parameter, the 
compiler will 
complain about the use of a literal where a variable is expected.

There are a few things wrong with your prototype:  ErrCode is not optional for 
the  
QMHSNDPM API.  You should prototype the two optional parameter groups too.  
Also from a 
style point of view ... putting names on the parameter definition IS A GOOD 
THING!

Here is my prototype for the same function.  I'd be interested in comments and 
criticism:

/if defined(QMHSNDPM_h)                                                   
/eof                                                                      
/else                                                                     
/define QMHSNDPM_h                                                        
*** START HEADER FILE SPECIFICATIONS ************************************ 
*                                                                       * 
* Header File Name  . . . . : QMHSNDPM                                  * 
*                                                                       * 
* Descriptive Name  . . . . : Send Program Message API.                 * 
*                                                                       * 
* Copyright:                                                            * 
*   (C) Copyright FlyByNight Software Pty. Ltd. 2000                    * 
*       All rights reserved.                                            * 
*                                                                       * 
* Description . . . . . . . : Header file for Send Program Message API  * 
*                             which sends a message to an invocation    * 
*                             message queue or the external message     * 
*                             queue.                                    * 
*                                                                       * 
* Header Files Included . . : *NONE                                     * 
*                                                                       * 
* Macros List . . . . . . . : *NONE                                     * 
*                                                                       * 
* Structure List  . . . . . : *NONE                                     * 
*                                                                       * 
* Function Prototype List . : QMHSNDPM                                  * 
*                                                                       * 
* Notes:                                                                * 
*   Dependencies  . . . . . :                                           * 
*                                                                       * 
*   Restrictions  . . . . . :                                           * 
*                                                                       * 
*   Comments  . . . . . . . : Define the macro LONG_PROC_NAMES if you   * 
*                               want meaningful procedure names.        * 
*                                                                       * 
* Change Activity:                                                      * 
*               Rlse &                                                  * 
* Flag Reason   Level  Date   Pgmr       Comments                       * 
* ---- -------- ------ ------ ---------- ---A-------------------------- * 
* $A0=          VRM310 000423 SHC        New include.                   * 
* $A1=          VRM360 000423 SHC        Support long sending/receiving * 
*                                        names on sender information    * 
*                                        returned by RCVM0300.          * 
*                                                                       * 
*                                                                       * 
*  Change activity detail:                                              * 
*                                                                       * 
*** END HEADER FILE SPECIFICATIONS ************************************** 
                                                                          
************************************************************************* 
* Prototype for calling Message Handler API QMHSNDPM                    * 
************************************************************************* 
/if defined(LONG_PROC_NAMES)                                              
 QmhSndPgmMsg    PR                                                       
/else                                                                     
 QMHSNDPM        PR                                                       
/endif                                                                    
                                     EXTPGM('QMHSNDPM')                   
*                                                                         
* Required parameter group:                                               
*                               Message identifier                        
  msgId                         7    CONST                                
*                              Qualified message file name                
  qualMsgF                     20    CONST                                
*                              Message data or text                       
  msgDta                    32767    CONST OPTIONS(*VARSIZE)              
*                              Length of message data or text             
  msgDtaLen                    10I 0 CONST                                
*                              Message type                               
  msgType                      10    CONST                                
 *                              Call stack entry               
D  callStkEnt                 4102    CONST
 *                              Call stack counter             
D  callStkCnt                   10I 0 CONST                    
 *                              Message key                    
D  msgKey                        4                             
 *                              Error code                     
D  errCode                    1024    OPTIONS(*VARSIZE)        
 *                                                             
 * Optional parameter group 1:                                 
 *                                 Length of call stack entry. 
D  callStkEntLen                10I 0 CONST OPTIONS(*NOPASS)   
 *                                 Call stack entry            
 *                                    qualification.           
D  callStkEntQual...                                           
D                               20    CONST OPTIONS(*NOPASS)   
 *                                 Display program messages    
 *                                    screen wait time.        
D  dspPgmMsgTime                10I 0 CONST OPTIONS(*NOPASS)   
 *                                                             
 * Optional parameter group 2:                                 
 *                                 Call stack entry data type. 
D  callStkEntType...                                           
D                               10    CONST OPTIONS(*NOPASS)   
 *                                 Coded Character Set Id.   
D  msgDtaCCSID                  10I 0 CONST OPTIONS(*NOPASS) 
                                          A                  
 /endif                                                      

Regards,
Simon Coulter.

«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»
«» FlyByNight Software         AS/400 Technical Specialists       «»
«» Eclipse the competition - run your business on an IBM AS/400.  «»
«»                                                                «»
«» Phone: +61 3 9419 0175      Mobile: +61 0411 091 400           «»
«» Fax:   +61 3 9419 0175      mailto: shc@flybynight.com.au      «»
«»                                                                «»
«» Windoze should not be open at Warp speed.                      «»
«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»
//--- forwarded letter -------------------------------------------------------
> X-Mailer: Mozilla/3.0 (compatible; StarOffice/5.2;Win32)
> Date: Mon, 17 Jul 2000 21:36:27 +0000
> From: "Leslie Russell" <leslier@datrek.com>
> To: RPG400-L@midrange.com
> Reply-To: RPG400-L@midrange.com
> Subject: How to prototype CL modules

> 
> R don't know for sure but I will try to find out. I have only had a few 
> problems using this prototype and that was only with the messages place 
> in the call stack.
> 
> >>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<
> 
> On 7/17/00, 3:26:20 PM, Scott Klement <klemscot@klements.com> wrote 
> regarding Re: How to prototype CL modules:
> 
> 
> > On Mon, 17 Jul 2000, Leslie Russell wrote:
> 
> > > You could just use the QMHSNDPM API to send the message.
> > >
> > >  DQMHSNDPM         PR                  extpgm('QMHSNDPM')
> > >  D                                7A   const
> > >  D                               20A   const
> > >  D                               70A   const
> > >  D                               10I 0 const
> > >  D                               10A   const
> > >  D                               10A   const
> > >  D                               10I 0 const
> > >  D                                4    const
> > >  D                              116A   options(*nopass:*varsize)
> > >
> > >
> 
> > The Message Key parameter (the  "4 const" one)  shouldn't be "const",
> > should it?  Since thats something returned by the API?
> 

+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.