5.13: TQERR

TOCGroup 5TQGTLCTQINIGroup 1A-ZGroup 5

GET-ERROR-MESSAGE

Use TQERR to get an error message.

Synopsis

FORTRAN: CALL TQERR(MESS,NOERR)

C: tqerr(&mess,&noerr);

Pascal: tqerr(mess,noerr);

Basic: Call tqerr(mess,noerr)


Name Type Value set on call or returned
MESS Array of
CHARACTER
Returns an error message
NOERR INTEGER Returns an error number

All ChemApp error messages are written sequentially to the unit/file associated with ERROR (see Table 6 and TQCIO on how to change the associated unit/file and on how to prevent the automatic output of error messages).

Alternatively, they can also be retrieved individually after each ChemApp subroutine call by invoking TQERR. MESS is a CHARACTER array with 3 elements each 80 characters long. These three entries in MESS contain the error message. Appendix A contains a list of all possible error messages and their associated numbers.

Note that it is only necessary to call TQERR if the error variable (NOERR) returned by the most recent previous call to a ChemApp subroutine contains a positive value. Otherwise, a blank return by TQERR indicates 'no error'.

Examples

FORTRAN:View plain source code



C Retrieve error messages
PROGRAM CAF21 IMPLICIT NONE
INTEGER NOERR, NPHASE CHARACTER MESS(3)*80
C Initialise ChemApp CALL TQINI(NOERR)
C TQERR is especially useful if is undesirable that ChemApp writes C error messages to the standard output unit (usually 6, the connected C terminal). If the application program which calls ChemApp has a C graphical user interface, ChemApp error messages written to the C default output unit might either not be displayed at all, or might C corrupt the graphical interface window. In these cases it is more C useful to have ChemApp not output error messages automatically, but C retrieve them using TQERR, if the error variable returned by a ChemApp C subroutine indicates that an error occurred.
C Prevent the error messages from being displayed automatically CALL TQCIO('ERROR ', 0, NOERR)
C Provoke an error by trying to get the number of phases C before even having read a thermochemical data-file CALL TQNOP(NPHASE, NOERR) IF (NOERR .NE. 0) THEN WRITE(*,FMT='(A,I4)') ' ChemApp reports error no.', NOERR
C Retrieve the error message using TQERR and the character array MESS CALL TQERR(MESS,NOERR)
C To display the message, print all three strings of MESS : WRITE(UNIT=*,FMT='(3(A,/))') MESS(1), MESS(2), MESS(3)

Output:
 ChemApp reports error no. 104
 A thermodynamic data-file must be read first                                   
 The error appeared after a call of "TQNOP "

ENDIF
END

C:View plain source code




/* Program cac21 */ /* Retrieve error messages */
#include "cacint.h"
int main() { LI noerr, nphase; int i;
/* Initialise ChemApp */ tqini(&noerr);
/* tqerr is especially useful if is undesirable that ChemApp writes error messages to standard output. If the application program which calls ChemApp has a graphical user interface, ChemApp error messages written to standard output might either not be displayed at all, or might corrupt the graphical interface window. In these cases it is more useful to have ChemApp not output error messages automatically, but retrieve them using tqerr, if the error variable returned by a ChemApp function indicates that an error occurred. */
/* Prevent the error messages from being displayed automatically */ tqcio("ERROR", 0, &noerr);
/* Provoke an error by trying to get the number of phases before even having read a thermochemical data-file */ tqnop(&nphase, &noerr); if (noerr) { printf(" ChemApp reports error no. %li\n", noerr);
/* Retrieve the error message using tqerr. The variable TQERRMSG to be used for that purpose is declared in cacint.c as TQERRMSG[3][80] */ tqerr(TQERRMSG,&noerr);
/* To display the message, print all three strings of TQERRMSG: */ for(i=0;i<3;i++) printf("%s\n",TQERRMSG[i]);

Output:
 ChemApp reports error no. 104
 A thermodynamic data-file must be read first
 The error appeared after a call of "TQNOP "

}
return 0;
}


ChemApp Programmer's Manual, Edition 3.6© GTT-Technologies, 2003