| 
 | 
> From: Joep Beckeringh
>
> BTW, while I was wondering why you were complicating things with
pointers,
> I noticed that according to the prototype your procedure returns a
pointer
> as well. But the rest of the coding suggests that is a typo.
You're of course correct, Joep.  Thanks for pointing that out.
> In RPG parameter passing is by reference unless specified otherwise.
Since
> you can only specify CONST and VALUE, VALUE is the only way to not
pass by
> reference. That is why you need to pass a pointer by value (otherwise
the
> pointer to the pointer would be passed).
True, but there's a slight problem with I/O.  You can't read an
externally described file into a field, so the following won't work:
FMYFILE    UF A E           K DISK  
DmyDS           E DS                  EXTNAME(MYFILE) BASED(pMYFILE)
PReadMYFILE       B                   export             
D                 PI              N                      
d  Key                                 like(MYKEY) value
d  Buffer                              likeds(myDS)
C     Key           chain     MYFILE                Buffer
C                   return    %found(MYFILE)                     
                                                    
P                 e       
This syntax is invalid.  The only way I could find to make it work
requires an EVAL, which is what I'm trying to avoid:
d  Key                                 like(MYKEY) value
d  Buffer                              likeds(myDS)
C     Key           chain     MYFILE
C                   if        %found
C                   eval      Buffer = myDS 
C                   endif
C                   return    %found(MYFILE)  
                   
As far as I know, there's no way in RPG to specific a parameter to use
the EXTNAME or LIKEREC parameter.  Maybe you can do it somehow in V5R2,
I don't know.
Joe 
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.