|
thanks simon, i am getting proper message IDs in _EXCP_MSGID. > ---------- > From: Simon Coulter[SMTP:shc@flybynight.com.au] > Reply To: c400-l@midrange.com > Sent: Tuesday, June 04, 2002 7:31 AM > To: c400-l@midrange.com > Subject: RE: [C400-L] system() > > > Hello Phil, > > You wrote: > >> sprintf(buffer,_format_an_invalid_CL_command); > >> rc = system(buffer); > >> if(rc != 0) > >> { > >> printf("Error is %s\n",_EXCP_MSGID); > >> exit(-1); > >> } > > > >system() doesn't work like that. > > Actually, system() does work like that. > > >system() runs a 'self contained' task, the control boundary for it means > >that the any CPF msgs generated by it are 'out of scope' when system() > >returns control to you. If you want to be able to retrieve the CPF msgs, > >use QCAPCMD API instead of the system() runtime function. > > That's true as far as it goes, however system() does set the _EXCP_MSGID > variable to point to a string containing the message ID of the error > message. While this is not as useful as retrieving the message > description > it does allow error handlig to branch according to the received error. > > I modified Srikanth's example to create a working program. > > #include<stdio.h> > #include<stdlib.h> > #include<stddef.h> > > main() > { > int rc; > char buffer[100]; > > sprintf(buffer, "_format_an_invalid_CL_command"); > rc = system(buffer); > if(rc != 0) > { > printf("Error is %s\n",_EXCP_MSGID); > exit(-1); > } > > return 0; > } > > Running it on my 440 system results in the expected behaviour. For > example: > > Error is CPF0006 > Press ENTER to end terminal session. > > 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 mailto: shc@flybynight.com.au \ / > X > ASCII Ribbon campaign against HTML E-Mail / \ > -------------------------------------------------------------------- > > _______________________________________________ > This is the C programming iSeries / AS400 (C400-L) mailing list > To post a message email: C400-L@midrange.com > To subscribe, unsubscribe, or change list options, > visit: http://lists.midrange.com/cgi-bin/listinfo/c400-l > or email: C400-L-request@midrange.com > Before posting, please take a moment to review the archives > at http://archive.midrange.com/c400-l. > ************************************************************************** This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated. **************************************************************************
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.