|
Eval len = %len(%trim(field)) Should do it. Phil -----Original Message----- From: owner-midrange-l@midrange.com [mailto:owner-midrange-l@midrange.com]On Behalf Of Joe Pluta Sent: Thursday, June 07, 2001 12:31 AM To: MIDRANGE-L@midrange.com Subject: RE: errno (is no longer: VIRUS ALERT!) The topic is changed <laughing>. Seriously, I suspect this thread will die a natural death soon, so no major problem. I've gotten errno to work now, using Rolf's original prototype. I now have a called subprogram that (almost) writes intelligently to a stream file in EBCDIC. I'm still getting used to the BIFs - %TRIMR trims a string before I store it in a variable, but %SIZE returns the whole size of the variable. I'm unsure whether to use varying on the variable, or if there's a BIF that returns the length of the trimmed string. But I'm learning, and learning quickly. Joe > -----Original Message----- > From: owner-midrange-l@midrange.com > [mailto:owner-midrange-l@midrange.com]On Behalf Of Sion Coulter > Sent: Wednesday, June 06, 2001 9:54 PM > To: MIDRANGE-L@midrange.com > Subject: errno (was: VIRUS ALERT!) > > > > Hello Joe, > > Change the bloody topic! > > You wrote: > >Does anybod have the ILE C pieces needed to allow me to retrieve the > >"errno" parameter when using the Unix APIs? According to the manuals, I > >need a C module because the error is exported as "errno", which is lower > >case and cannot be accessed by ILE RPG. > > Not strictly true. RPG IV can access lower case exports. For example > > * Errno in C style - imported from QC2UTIL1 service program > D errno S LIKE(int_t) IMPORT('errno') > > however, although that is syntactically correct it won't work because the > errno variable exported from the QC2UTIL1 service program is > always zero. > Bastards! Read on .... > > >And rather than provide a "geterrno()" method in the Unix APIs, > evidently > >I'm expected to make my own. Since I don't have the ILE C compiler, > >that's sort of difficult, so I was wondering if anybody else had gone > >through this step. > > You are expected to create your own because the conventional > wisdom is that > you should be using C for this stuff. However, you don't need to > create it > completely because the C runtime (which is on every system) already > provides it. Read on ... > > You do have the C compiler. It is on your installation CD-ROM. You can > install it and run it for 70 days before it dies. It is probably worth > installing simply so you can examine the C header files whenever you need > to convert an include to RPG IV. If you look at the errno.h include you > will see that errno in C on the AS/400 is actually a function call. > > extern int *__errno(void); > #define errno (*__errno()) > > You can prototype the function call and use it from RPG IV. It is not as > transparent as the C version but it works. Here is an excerpt from my > version of errno.h for RPG IV. Note that you only need to address the > errno variable once in the program so put the > EVAL @errno = getErrno > in the *INZSR and then errno is always available. > > ************************************************************************* > * Definition of errno : Slightly different from C language invocation * > * due to language semantics. Invoke like: * > * CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++++++++++++++++++++++ * > * EVAL @errno = getErrno * > * and then test like: * > * IF errno = $EWOULDBLOCK * > * do something about it * > * ENDIF * > ************************************************************************* > > * Error number returned > D errno S LIKE(int_t) BASED(@errno) > D @errno S * > > D getErrno PR * Extproc('__errno') > /endif > > Regards, > Simon Coulter. > > """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" > "" FlyByNight Software AS/400 Technical Specialists "" > "" Eclipse the competition - run your business on an IBM AS/400. "" > "" "" > "" Phone: +61 3 9419 0175 Mobile: +61 0411 091 400 /"\ "" > "" Fax: +61 3 9419 0175 mailto: shc@flybynight.com.au \ / "" > "" X "" > "" ASCII Ribbon campaign against HTML E-Mail / \ "" > """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" > +--- > | This is the Midrange System Mailing List! > | To submit a new message, send your mail to MIDRANGE-L@midrange.com. > | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com. > | To unsubscribe from this list send email to > MIDRANGE-L-UNSUB@midrange.com. > | Questions should be directed to the list owner/operator: > david@midrange.com > +--- > +--- | This is the Midrange System Mailing List! | To submit a new message, send your mail to MIDRANGE-L@midrange.com. | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com. | To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +--- _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com +--- | This is the Midrange System Mailing List! | To submit a new message, send your mail to MIDRANGE-L@midrange.com. | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com. | To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
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.