|
On 20/07/2010, at 11:03 PM, MattLavinder@xxxxxxxxxxxxxxxxxxx wrote:
Have been looking at writing a pipe to process log information from the
IBM
HTTP. Program reads data but it appears to be in ASCII. Tried using
the
follow code to convert it and it didn't work. What did I do wrong?
Your prototype is wrong.
D Translate PR ExtPgm('QDCXLATE')
D Length 5P 0 const
D Data * const
D Table 10A const
The definition of parameter 2 is wrong. QDCXLATE expects [the address of]
a variable and it limits the length of data to convert to 32K--the length
field cannot exceed 32767. QDCXLATE is an external program therefore it
expects the variables to be passed by reference. Ingrain the following:
passing a variable by reference is EXACTLY the same as passing a pointer
by value
Thus if you want to pass a pointer then it must be by value not const.
You have two choices:
Define the prototype with a variable of flexible size e.g.:
D Translate PR ExtPgm('QDCXLATE')
D Length 5P 0 const
D Data 32767 options(*varsize)
D Table 10A const
or confuse the next person by defining it with a pointer e.g.:
D Translate PR ExtPgm('QDCXLATE')
D Length 5P 0 const
D Data * value
D Table 10A const
Note that since the main reason to use a pointer is to exceed the size
limitations inherent in defining a variable (32K prior to VRM440, 64K
from VRM440 to VRM540, and [hardly a limit] 16M from VRM610) and that
QDCXLATE is limited to 32K there is no point in defining a pointer--it
will simply confuse things.
One possible area of additional confusion is that IBM APIs with
variable-length character parameters are documented as CHAR(*) which some
programmers, usually those with a C mind-set, interpret as a pointer
[i.e., char *] which is simply incorrect--a mistake fostered entirely by
assumption. Reading the API concepts section should clear that up.
Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists
http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------
As an Amazon Associate we earn from qualifying purchases.
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.