×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




You need to also check the %PARMS value inside your subprocs.
*NOPASS can be used hence %PARMS could be 1, 2,3,4,5,6, or 7.
While you may pass *OMIT on these parms, *NOPASS means you do not have to.
Therefore, If %addr(myparm)<>*NULL  is not strickly correct.
I always do this insteadL

  If %parms >= 2
    If %addr(myParm2) <> *NULL
      Eval localVal = Parm2Val
    Endif
  Endif

It's the only way to be sure.  Also, note that the %addr thing with a CONST
parameter does not work on V4R5 and may not work on V5R1. I believe it was
"fixed" on V5R2. If you're on an earlier release, you have to use that CEE
API.  So my code really looks like this:

     D bP1             S             10I 0
     D bP2             S             10I 0
     D bP3             S             10I 0
     D bP4             S             10I 0
     D bP5             S             10I 0
     C                   if        %Parms >= 1
     C                   CallP     IsParmOmit(bP1: 1 : *OMIT) 
     C                   if        %Parms >= 2
     C                   CallP     IsParmOmit(bP2: 2 : *OMIT) 
     C                   if        %Parms >= 3
     C                   CallP     IsParmOmit(bP3: 3 : *OMIT)
     C                   if        %Parms >= 4
     C                   CallP     IsParmOmit(bP4: 4 : *OMIT)
     C                   if        %Parms >= 5
     C                   CallP     IsParmOmit(bP5: 5 : *OMIT)
     C                   endif
     C                   endif
     C                   endif
     C                   endif
     C                   endif

Kind of ugly, but it is safe and works as far back as I can compile. FYI,
IsParmOmit() looks like this:
     D IsParmOmit      PR                  ExtProc('CEETSTA')
     D  nParmPassed                  10I 0
     D  nParmNum                     10I 0 Const
     D  szParmError                  12A   OPTIONS(*OMIT)


-Bob Cozzi
www.RPGxTools.com
If everything is under control, you are going too slow.
- Mario Andretti

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Larry Ducie
Sent: Tuesday, July 26, 2005 2:58 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: creating a new procedure that call an existing procedure
withone additional parm

Hi Lim,
 
Hmmm...
 
OK, lets take your procedure prototypes as an example:
d  SndMsg         PR                  opdesc
d  MsgInId                      10    const                            
d  MsgInData                 32766    const options(*varsize:*nopass:*omit)
d  MsgInType                    10    const options(*nopass:*omit )    
d  MsgFile                      10    const options(*nopass:*omit)     
d  MsgLib                       10    const options(*nopass:*omit)     
d  MsgInQueue                   10    const options(*nopass:*omit)     

d  SndMsgQ        PR                  opdesc
d  MsgInQueue                   10    const  
d  MsgInId                      10    const                            
d  MsgInData                 32766    const options(*varsize:*nopass:*omit)
d  MsgInType                    10    const options(*nopass:*omit )    
d  MsgFile                      10    const options(*nopass:*omit)     
d  MsgLib                       10    const options(*nopass:*omit)     

 
 
Within the body of SndMsg you will already have code such as:
d this            DS                  qualified
d msgInId                             like(MsgInId)
d msgInData                           like(MsgInData)
d msgInType                           like(MsgInType)
d msgFile                             like(MsgFile)
d msgLib                              like(MsgLib)
d msgInQueue                          like(MsgInQueue)
/free
 
  this.msgInId = MsgInId;
 
  if %addr(MsgInData) <> *null;
    this.msgInData = MsgInData;
  else;
    this.msgInData = *blanks;
  endif;
 
  if %addr(MsgInType) <> *null;
    this.msgInType = MsgInType;
  else;
    this.msgInType = *blanks;
  endif;
 
  if %addr(MsgFile) <> *null;
    this.msgFile = MsgFile;
  else;
    this.msgFile = *blanks;
  endif;
  
  if %addr(MsgLib) <> *null;
    this.msgLib = MsgLib;
  else;
    this.msgLib = *blanks;
  endif;
  
  if %addr(MsgInQueue) <> *null;
    this.msgInQueue = MsgInQueue;
  else;
    this.msgInQueue = *blanks;
  endif;
 
  // your internal procedure code here...
 
  return your.opdesc;
 
/end-free
 
 
If you move the code to SndMsgQ you can simply remove the check for
%addr(MsgInQueue) as it is now a required parameter. Everything within
SndMsgQ should work. 
 
Now, in SndMsg your whole procedure code will be relagated to:
p  SndMsg         b
d  SndMsg         PR                  opdesc
d  MsgInId                      10    const                            
d  MsgInData                 32766    const options(*varsize:*nopass:*omit)
d  MsgInType                    10    const options(*nopass:*omit )    
d  MsgFile                      10    const options(*nopass:*omit)     
d  MsgLib                       10    const options(*nopass:*omit)     
d  MsgInQueue                   10    const options(*nopass:*omit)     


d this            DS                  qualified
d msgInId                             like(MsgInId)
d msgInData                           like(MsgInData)
d msgInType                           like(MsgInType)
d msgFile                             like(MsgFile)
d msgLib                              like(MsgLib)
d msgInQueue                          like(MsgInQueue)
/free
 
  this.msgInId = MsgInId;
 
  if %addr(MsgInData) <> *null;
    this.msgInData = MsgInData;
  endif;
 
  if %addr(MsgInType) <> *null;
    this.msgInType = MsgInType;
  else;
    this.msgInType = *blanks;
  endif;
 
  if %addr(MsgFile) <> *null;
    this.msgFile = MsgFile;
  else;
    this.msgFile = *blanks;
  endif;
  
  if %addr(MsgLib) <> *null;
    this.msgLib = MsgLib;
  else;
    this.msgLib = *blanks;
  endif;
  
  if %addr(MsgInQueue) <> *null;
    this.msgInQueue = MsgInQueue;
  else;
    this.msgInQueue = *blanks;
  endif;
 
  return SndMsgQ(this.msgInQueue
                :this.msgInId
                :this.msgInData
                :this.msgInType
                :this.msgFile
                :this.msgLib);
 
/end-free
p  SndMsg         e
 
 
So what's changed?
 
1) You've moved your code from SndMsg to SndMsgQ and removed the check for
MsgInQueue being passed.
2) You've replaced the internal procedure code in SndMsg with a call to
SndMsgQ.
 
That's it!
 
You've only got one set of code - now in SndMsgQ.
You've still got your original param checks in SndMsg.
You wont get a signature violation on SndMsg as the prototype hasn't
changed.
You get code in SndMsgQ which you KNOW works.
 
Cheers
 
Larry Ducie 

This thread ...

Replies:

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

This mailing list archive is Copyright 1997-2026 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.