• Aucun résultat trouvé

SUPPORT ROUTINES

Dans le document Pascal in MTS (Page 193-199)

This section lists the support routines available for the Pascal adapter routines.

A given error condition belongs to one of several error classes. A given error class either has the attribute PRINT or NOPRINT. It also either has the attribute FATAL or NONFATAL. The following describes these attributes in more detail:

PRINT An error message will be printed whenever that error is detected (the default for most errors).

NOPRINT If an error class has the attribute NOPRINT and does not have the attribute FATAL, then no indication is made that there was an error. The existence of an error must be detected by means of the SYSRC routine.

FATAL An error message is printed and the current error count is checked whenever an error in that class occurs (the error count defaults to zero). One is subtracted from the error count and, if it becomes negative, the MTS system subroutine ERROR# is called and execution is terminated; otherwise, execution continues.

NONFATAL Execution is not terminated, and an error message is printed or not printed depending on the setting of the PRINT attribute.

Unless there is a statement to the contrary for a particular routine, all error classes have FATAL and PRINT as defaults. The correspondence between error classes and specific errors is explained in the individual routine descriptions that follow.

The settings of the FATAL/NONFATAL and PRINT/NOPRINT attributes can be changed with the support routine PSETERR. PSETERR also allows the current error count to be changed. By default, all error messages are printed on SERCOM. However by calling PSETERR, errors can produced on any file or device. The routines SYSRC, PMODULE, and PERRMESS can be used to retrieve information about errors that adapter routines have detected.

Pascal Adapter Routines: Support Routines 193

SYSRC

Subroutine Description

Purpose: Whenever any of the Pascal adapter routines are called, the return code is stored so that it can be retrieved later. This routine retrieves that value.

Location: *PASCALVSSYSLIB and *PASCALJBSYSLIB

Module Name: SYSRC

Includes: %INCLUDE SYSRC Calling Sequences: Pascal: SYSRC

Value Returned:

SYSRC returns the value of the return code after the last adapter routine returned. If no routines have been called, zero is returned.

Return Codes:

This routine does not update the return code as returned by SYSRC. It returns zero in GR15. No errors are possible.

Example: The following example illustrates the use of the SYSRC routine.

%INCLUDE SYSRC

%INCLUDE PCREATE PCREATE1('FILE',30);

IF SYSRC˜=0

THEN WRITELN(' Couldn''t create file,' ' return code is ', SYSRC:0);

194 Pascal Adapter Routines: SYSRC

PERRMESS Subroutine Description

Purpose: To allow a Pascal program to retrieve the last error message used by an adapter routine.

Location: *PASCALVSSYSLIB and *PASCALJBSYSLIB

Module Name: PERRMESS

Includes: %INCLUDE PERRMESS

Calling Sequences: Pascal: PERRMESS(ErrMsg);

Parameters:

ErrMsg : String;

The value of the last error message is placed in ErrMsg. If ErrMsg is too short to hold the string, the string is truncated without warning. (No messages are longer than 100 characters.) Note that an error message is recorded even if it is not printed. If there have been no error messages so far, a null string is returned.

Return Codes:

This routine does not update the return code as returned by SYSRC.

It returns zero in GR15. No errors are possible.

Pascal Adapter Routines: PERRMESS 195

PMODULE Subroutine Description

Purpose: To allow a Pascal program to determine the name of the last routine that detected an error.

Location: *PASCALVSSYSLIB and *PASCALJBSYSLIB

Module Name: PMODULE

Includes: %INCLUDE PMODULE Calling Sequences: Pascal: PMODULE(Module);

Parameters:

Module : String;

The module name of the last routine to detect an error. This is always an 8-character string. If no errors have been detected, eight blanks are returned. If the string is greater than eight characters, it is truncated without warning.

Return Codes:

This routine does not update the return code as returned by SYSRC.

It gives a zero in GR15 on return. No errors are possible.

Description: The name of a module for the routine that detected the error is returned.

196 Pascal Adapter Routines: PMODULE

PSETERR Subroutine Description

Purpose: To allow a Pascal program to control the behavior of the adapter routines on detection of an error condition.

Location: *PASCALVSSYSLIB and *PASCALJBSYSLIB

Module Name: PSETERR

Includes: %INCLUDE Fdub_Type

%INCLUDE PSETERR

Calling Sequences: Pascal: PSETERR(ErrList,Selections,ErrLimit,Fdub);

Parameters:

ErrList : Errnum_Type;

A list of error conditions that are to be controled. This list must be expressed as a set with elements selected from the following:

ERR_READWRITE

The error conditions mentioned in ErrList are controlled. If one of the options is ERR_FATAL, then all the errors in the list are made fatal errors. If one of the options is ERR_NONFATAL, then all errors in ERROR_LIST become nonfatal. If one of the options is ERR_PRINT, an error message is printed when any of the errors in ERROR_LIST occur. If one of the options is ERR_NOPRINT, then when any of the errors in error list are detected, no error message is printed. (Exception: A fatal error always prints an error message regardless of the setting of the PRINT option). Other error conditions remain as before. If either ErrList or Selections are the empty set, no change occurs.

ErrLimit : Integer;

If ErrLimit is positive, the error limit is set to ErrLimit. The error limit is only used for “FATAL” errors. If an error is FATAL, the error limit is checked for zero. If it is greater than zero, one is

Pascal Adapter Routines: PSETERR 197

subtracted from the error limit and execution continues. If the error limit is less than or equal to zero, execution terminates. If the ErrLimit parameter is negative, the error limit remains unchanged.

Fdub : Fdub_Type;

There are four options:

(1) A blank string.

(2) Fdub is a Fdub-pointer as returned by GETFD or PGETFD (or perhaps another system routine).

(3) Fdub is the character string for one of the units SCARDS, GUSER, SPRINT, SERCOM, or SPUNCH.

(4) Fdub is an integer unit number (0-99) represented as a string. If the unit is between 0 and 9, it must be represented as a one character string such as “0” or “1”. If the unit is between 10 and 99, it must be represented as a two character string such as “50” or “60”.

If Fdub is blank, no change occurs, otherwise all future error messages will be printed using that Fdub or I/O unit.

Return Codes: This routine does not update the return code as returned by SYSRC. It gives a zero in GR15 on return. No errors are possible.

Example: The following example illustrates the use of the PSETERR routine.

%INCLUDE FDUB_TYPE

%INCLUDE PSETERR BEGIN

{Alter the error tables so that whenever an error involving either PGUINFOI or PGUINFOS occurs, an error message will be printed and execution will continue.}

PSETERR([ERR_GUINFO],

[ERR_PRINT,ERR_NONFATAL],-1, ' ');

198 Pascal Adapter Routines: PSETERR

Dans le document Pascal in MTS (Page 193-199)