The system function can be a little bit lacking in terms of providing
information back to the program. I generally use something like the
following to give a little better control



static void cmd_check(_INTRPT_Hndlr_Parms_T *excp_info) {

int *count = (int *)(excp_info->Com_Area);

char MsgFs[2][20] = {"*REQUESTER ",

"FTPMSGQ *LIBL "};

char Msg_File[20] = "FTPMSGF *LIBL "; /* msg file */

char Msg_Type[10] = "*INFO "; /* msg type */

char Call_Stack[10] = {"*EXT "}; /* call stack entry */

char QRpy_Q[20] = {' '}; /* reply queue */

char Msg_Key[4] = {' '}; /* msg key */

char msg_dta[255]; /* message data */

Rcv_Msg_t rtv_dta; /* message struct */

EC_t Error_Code = {0}; /* error code struct */



Error_Code.EC.Bytes_Provided = _ERR_REC;



QMHRCVPM(&rtv_dta,

sizeof(rtv_dta),

"RCVM0100",

"* ",

0,

"*ANY ",

(char *) (&(excp_info->Msg_Ref_Key)),

0,

"*SAME ",

&Error_Code);

if(Error_Code.EC.Bytes_Available > 0) {

snd_error_msg(Error_Code);

sprintf(msg_dta,"Failed to retrieve message data");

snd_msg("GEN0001",msg_dta,strlen(msg_dta));

return;

}

if((memcmp(excp_info->Msg_Id,"CPF0005",7) == 0) ||

(memcmp(excp_info->Msg_Id,"CPF2103",7) == 0) ||

(memcmp(excp_info->Msg_Id,"CPF2112",7) == 0)) {

*count = 0;

}

else if(memcmp(excp_info->Msg_Id,"CPF6801",7) == 0) {

*count = 2;

}

else {

*count = 1;

}

if(*count == 1) {

QMHSNDM(excp_info->Msg_Id,

"QCPFMSG *LIBL ",

rtv_dta.msg_data,

rtv_dta.msg_struct.Data_Returned,

Msg_Type,

MsgFs,

2,

QRpy_Q,

Msg_Key,

&Error_Code);

if(Error_Code.EC.Bytes_Available > 0) {

snd_error_msg(Error_Code);

Error_Code.EC.Bytes_Available = 0;

}

QMHSNDPM(excp_info->Msg_Id,

"QCPFMSG *LIBL ",

rtv_dta.msg_data,

rtv_dta.msg_struct.Data_Returned,

"*STATUS ",

"*EXT ",

0,

" ",

&Error_Code);

if(Error_Code.EC.Bytes_Available > 0) {

snd_error_msg(Error_Code);

Error_Code.EC.Bytes_Available = 0;

}

}

QMHCHGEM(&(excp_info->Target), 0,

(char *) (&(excp_info->Msg_Ref_Key)),

"*HANDLE ","",0,&Error_Code);

if(Error_Code.EC.Bytes_Available > 0) {

snd_error_msg(Error_Code);

}

return;

}



/**

* (Function) Issue_Cmd

* @parms

* Command string

* returns 1 on success or returned value

*/



int Issue_Cmd(char *cmd_str) {

volatile int e_count = 0; /* error flag */

char msg_dta[50]; /* msg buffer */

char reply; /* reply */



#pragma exception_handler(cmd_check,e_count,0,_C2_ALL,_CTLA_HANDLE)

e_count = 0;

QCMDEXC(cmd_str,strlen(cmd_str));

#pragma disable_handler

if(e_count == 2) {

return 2;

}

if(e_count == 1) {

snd_msg("GEN0001","QCMDEXC Caught exception.",25);

return -1;

}

return 1;

}



I have cut and pasted this directly from a program so you will have to
change a few things to fit your needs. But it should give you an idea...



Chris...





Chris Hird

Director

Shield Advanced Solutions Ltd

Website :- <http://www.shield.on.ca>
http://www.shield.on.ca

<http://www.jobqgenie.com/>
http://www.jobqgenie.com

Blog :- <http://www.shield.on.ca/Blog>
http://www.shield.on.ca/Blog

Telephone :- 519-940-1192




This thread ...

Follow-Ups:

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 here. If you have questions about this, please contact [javascript protected email address].