×
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.
On 02/10/2004, at 5:05 AM, David C. Shea wrote:
When I look at the dump, I see:
&RRN9 *DEC 15 0 ' '
1E0000000000000F
What should the format of the passed variable from the CL be?
CL is expecting a packed decimal value so you better make damned sure
that's what you return from C.
In the C program:
.
.
int main(int argc, char * argv[])
.
.
*argv[2] = riofb_fwd->rrn;
.
.
I'm guessing that I need to convert a field format someplace...
Your problem is that C has no idea what *argv[2] is. It is just a
pointer to some chunk of storage. The only thing C knows at this point
is that riofb_fwd->rrn is an unsigned long integer so it assigns the
integer value to the bytes addressed by the pointer. But because C
rather stupidly treats char as a numeric type and *argv[2] is a char it
copies (via assignment) only the last byte of the unsigned long. The
value in riofb_fwd->rrn was probably 30 which is x'0000001E' (or 0x1e
since this is the C list). You can see from the dump that the 1E has
been assigned to the first byte of the packed decimal. x'E' is not a
valid value in a packed decimal (digits 0 to 9 only) thus the decimal
data error.
You need to ensure C understands the receiving data type so it can
convert correctly. The following code
decimal(15,0) * rrn = (decimal(15,0)*)argv[2];
*rrn = riofb_fwd->rrn;
will do it. If you don't do it this way you'll have to do something
ugly like passing character values or convert to decimal in the C (by
assigning to an appropriate decimal variable) and copy the correct
number of bytes into your caller's storage. Doesn't C suck?
Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software AS/400 Technical Specialists
http://www.flybynight.com.au/
Phone: +61 3 9419 0175 Mobile: +61 0411 091 400 /"\
Fax: +61 3 9419 0175 \ /
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.