|
Note:
I mis-spoke here. With my Proc3 and the fact that proc3(data) and
proc2(ptr) were equivalent.
Actually, given the prototype of Proc3, Proc3(data) won't compile.
What I was trying to say is that given the following procedure:
P Proc3 b
D Proc3 pi
D in *
You can prototype it two ways:
D Proc3a pr extproc('PROC3')
D in * value
D Proc3b pr extproc('PROC3')
D in 10a
Giving you two ways to call it:
Proc3a(%addr(data))
Proc3b(data)
You could also simply use
Proc3a(ptr)
The key idea is that Proc3 itself expects a pointer.
It will get a pointer if you pass a pointer variable by value, or _ANY_
variable by reference (either CONST or not).
HTH,
Charles Wilt
--
iSeries Systems Administrator / Developer
Mitsubishi Electric Automotive America
ph: 513-573-4343
fax: 513-398-1121
> -----Original Message-----
> From: rpg400-l-bounces@xxxxxxxxxxxx
> [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Wilt, Charles
> Sent: Friday, January 27, 2006 10:39 AM
> To: RPG programming on the AS400 / iSeries
> Subject: RE: CONST vs. VALUE on a pointer parameter
>
> CONST = pass by constant reference ( a pointer in other words)
> VALUE = pass by value
>
> Using the following:
> D data s 10a
> D ptr s * inz(%addr(data))
>
> D proc1 pr
> D in * const
>
> D proc2 pr
> D in * value
>
> D proc3 pr
> D in *
>
> Then:
> Proc1(data) --> passes the addr of data, doesn't allow data to be
> changed
> Proc1(ptr) --> passes the addr of ptr, doesn't allow ptr to be changed
>
> Proc2(data) --> won't compile, since the value of data is 10A and we
> said we're passes a pointer.
> Proc2(ptr) --> passes the value of ptr, ie. the addr of data. Allows
> data to be changed.
>
> Proc3(data) --> passes the addr of data, allows data to be changed
> Proc3(ptr) --> passes the addr of ptr, allows ptr to be changed
>
> These two calls are equivalent:
> Proc2(ptr)
> Proc3(data)
>
> Proc1(data) is almost the same, except data can't be changed.
>
>
>
> HTH,
>
> Charles Wilt
> --
> iSeries Systems Administrator / Developer
> Mitsubishi Electric Automotive America
> ph: 513-573-4343
> fax: 513-398-1121
>
>
> > -----Original Message-----
> > From: rpg400-l-bounces@xxxxxxxxxxxx
> > [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of darren@xxxxxxxxx
> > Sent: Friday, January 27, 2006 10:09 AM
> > To: rpg400-l@xxxxxxxxxxxx
> > Subject: CONST vs. VALUE on a pointer parameter
> >
> >
> > I attempted to call the Qp0lGetAttr API to get the creation
> > date of a file
> > in the IFS. I used the following prototype.
> >
> > D Qp0lGetAttr PR 10I 0 ExtProc('Qp0lGetAttr')
> > D path * Const
> > D AttArrPtr * Const
> > D BuffPtr * Const
> > D BuffLenSent 10U 0 Const
> > D BuffLenNeed 10U 0
> > D BuffLenRet 10U 0
> > D FollowLink 10U 0 Value
> >
> >
> > The above did not work, apparently because I had used Const.
> > The program
> > compiles fine both ways, but the API returns a -1 indicating
> > that some kind
> > of error occurred. I can toggle the 'path' parameter from
> > Value to Const
> > and get it to fail, with everything else as shown below. My
> > reason for
> > using Const was to document that the variable being pointed
> > to was an Input
> > only variable per the API's specs. Can someone in the know,
> > educate me as
> > to the different between Const and Value in this case?
> >
> > D Qp0lGetAttr PR 10I 0 ExtProc('Qp0lGetAttr')
> > D path * Value
> > D AttArrPtr * Value
> > D BuffPtr * Value
> > D BuffLenSent 10U 0 Value
> > D BuffLenNeed 10U 0
> > D BuffLenRet 10U 0
> > D FollowLink 10U 0 Value
> >
> > --
> > This is the RPG programming on the AS400 / iSeries (RPG400-L)
> > mailing list
> > To post a message email: RPG400-L@xxxxxxxxxxxx
> > To subscribe, unsubscribe, or change list options,
> > visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
> > or email: RPG400-L-request@xxxxxxxxxxxx
> > Before posting, please take a moment to review the archives
> > at http://archive.midrange.com/rpg400-l.
> >
> >
>
> --
> This is the RPG programming on the AS400 / iSeries (RPG400-L)
> mailing list
> To post a message email: RPG400-L@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
> or email: RPG400-L-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/rpg400-l.
>
>
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.