The "file descriptor" used by _Rwrite() is actually a structure with several subfields. The most helpful one in your case might be "buf_length".

In your case, you should be able to write something like this:
iofb = _Rwrite(ecdstp_fd, pdat, ecdstp_fd->buf_length);

You will, of course, wish to ensure that "pdat" is "ecdstp_fd->buf_length" in length.

Hope this helps!

Wayne

-----Original Message-----
From: c400-l-bounces+wjames=nubridges.com@xxxxxxxxxxxx [mailto:c400-l-bounces+wjames=nubridges.com@xxxxxxxxxxxx] On Behalf Of Lim Hock-Chai
Sent: Monday, February 08, 2010 2:53 PM
To: c400-l@xxxxxxxxxxxx
Subject: Re: [C400-L] _Rwrite - How to check for a successful write operation

Thanks Kent.

I changed the code to be like below and it compiled successfully (Not
very good at c language. I'm over joyed whennever my changes compiled
successfully:); will test it out later.

int sizeOfECDSTP = sizeof(UAM);

. . .
iofb = _Rwrite(ecdstp_fd, pdat, sizeOfECDSTP);

if (iofb->num_bytes != sizeOfECDSTP) {

. . . .
}


"Ulrich, Kent" <Kent.Ulrich@xxxxxxx> wrote in message
news:<mailman.7095.1265657094.2580.c400-l@xxxxxxxxxxxx>...
One way is to use the sizeof operator (providing that pdat is a
structure matching the record).

Kent


-----Original Message-----
From: c400-l-bounces+kent.ulrich=lfg.com@xxxxxxxxxxxx
[mailto:c400-l-bounces+kent.ulrich=lfg.com@xxxxxxxxxxxx] On Behalf Of
Lim Hock-Chai
Sent: Monday, February 08, 2010 12:44 PM
To: C programming iSeries / AS400
Subject: [C400-L] _Rwrite - How to check for a successful write
operation

I ran into the following piece of code in one of our C programs. I
notice that the length of the record (1099) is being hardcoded in the
program. Is there a better way of doing this (other than define it is
constant in a copy book)?

iofb = _Rwrite(ecdstp_fd, pdat, 1099);

if (iofb->num_bytes != 1099) {

. . . .
}



thanks

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 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].