× 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.



Hi Bil: 
 
>I have a program where I'd like one of the 
>parameters to be optional (to maintain 
>compatiblity with a prior version of the 
program). 
> This is the current prototype of the new 
program: 
> 
>D CalcDat         pr                  
>ExtPgm('CALCDAT')           
>D  inpDat                       10                 
>               
>D  inpDatFmt                    10                 
>               
>D  inpDays                       4  0              
>               
>D  outDat                       10                 
>               
>D  outDatFmt                    10                 
>               
> 
>I'd like to make outDatFmt optional since the 
>original didn't have that parameter.  I believe 
>this is done via the "Options(*NoPass)", correct?  
 
Correct. 
 
 
>If so, I believe if I use *NoPass I can't change 
>the value of outDatFmt like this: 
>                                        
>      If outDatFmt = *Blanks ;          
>        outDatFmt = inpDatFmt ;         
>      EndIf ;                           
>                                        
 
In this case that is correct because your 
prototype requires the parameter to be passed by 
reference.  If you attempt this when the parm was 
not sent you will receive a "pointer not 
referenced" error or something like it.  To 
include this code only when the parm was passed, 
wrap it in a %parms() if statement... 
 
    If %parms() > 4 ;                                        
      If outDatFmt = *Blanks ;          
        outDatFmt = inpDatFmt ;         
      EndIf ;        
    Endif ;                    
                                        
Now this check will only be performed if the parm 
is sent.  What you cannot do, however, is refer to 
the parm as a field EVER if the parm was not 
sent... UNLESS... 
 
>So, my question is:  What would be the best way 
to 
>accomplish the above goals?  Something along the 
>lines of a working variable for outDatFmt?  Are 
>there other ways of checking for the missing 
>parameter than "If %Parms" ? 
 
I use this approach all the time to establish 
default behaviours: add the 'Value' attribute to 
the prototype for the new parm: 
 
D CalcDat         pr                  
ExtPgm('CALCDAT')           
D  inpDat                       10                 
               
D  inpDatFmt                    10                 
               
D  inpDays                       4  0              
               
D  outDat                       10                 
               
D  outDatFmt                    10                 
Value Options(*nopass)               
 
 
Now you can use outDatFmt even if it wasn't 
sent... just don't forget to initlize it... 
 
    If %parms() > 4 ;                                        
      If outDatFmt = *Blanks ;          
        outDatFmt = inpDatFmt ;         
      EndIf ;     
    Else ; 
      outDatFmt = myDefaultValue ;    
    Endif ;                    
 
>Bill 
 
Hope this helps, 
 
Joel  
http://www.rpgnext.com 
 
P.S. Have you checked out the Date service program 
in my free xRPG library? 
 
http://www.rpgnext.com/docs/rnbdates.php 
 
It may have what you are looking for already... if 
not let me know and I may be able to add it.

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.