×
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.
> Scott does this neat little trick with his EXPAT test programs (Scott
> I hope I am remembering this correctly) where he pass a pointer to a
> data structure defined in local storage to an intermediate program by
> value along with a address of a procedure to do a callback.
Yes, I do that... but I don't use CONST when I do that, since my goal is
usually to use the parameter as *output*, not input. So it's just using
a pointer by value in one place, and a straight reference field in another.
Callbacks are an area where the RPG compiler developers don't let us use
a matching prototype. You can't simply define it in one place and
re-use it, because one place has to have EXTPROC(PointerName) and the
other has to be a straight PR/PI.
But, you're right... I've tricked the compiler into dereferencing a
CONST parameter in the past. There's one situation I've found where
there's no other way (other than making a copy of the data). The
iconv() API...
The input to the iconv() API requires a pointer to a pointer. It will
change the pointer as it translates the data from the input buffer to
the output buffer.
For example, let's say you're writing a program that sends a string to a
TCP socket. You want to wrap the process in a subprocedure, so you can
simply say sendTcp('my string here') and it'll automatically add CRLF,
and translate the whole thing to an arbitrary CCSID (presumably, ASCII
or Unicode) then send it over the socket.
The iconv() API would be used in that subprocedure to translate the
data. No problem... iconv() doesn't change the input buffer when it
translates it... it puts the output into the output buffer.
Unfortunately, iconv() needs a pointer to a pointer as input. It
actually increments the input pointer as it goes along, thus keeping
track of where it left off during the translation. If it encounters an
untranslatable character, you can use this mechanism to skip it.
Unfortunately, since the input to iconv() is a pointer to a pointer,
there's no way to use it on a CONST field! You can't get a pointer to a
CONST field in RPG. It's a limitation of the language syntax.
So you have no choice... you have to trick the compiler into
dereferencing the pointer to the CONST field, even though you have no
intention of changing the data it points to. It drives me nuts, but
that's the way RPG works.
As an Amazon Associate we earn from qualifying purchases.
This thread ...
RE: Another ILE question : CONST vs VALUE, (continued)
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.