× 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.



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  / \
--------------------------------------------------------------------



As an Amazon Associate we earn from qualifying purchases.

This thread ...


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

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.