Guardian Programmer's Guide

Table Of Contents
Writing a Command-Interpreter Monitor ($CMON)
Guardian Programmer’s Guide 421922-014
23 - 74
Sample Command-Interface Program
!------------------------------------------------------------
! Procedure for displaying file-system error numbers on the
! terminal. The parameters are the file name, name length,
! and error number. This procedure is mainly to be used when
! the file is not open, when there is no file number for it.
! File^ERRORS should be used when the file is open.
!
! The procedure also stops the program after displaying
! the error message.
!------------------------------------------------------------
PROC FILE^ERRORS^NAME(FNAME:LEN,ERROR);
STRING .FNAME;
INT LEN;
INT ERROR;
BEGIN
! Compose and print the message:
START^LINE;
PUT^STR("File system error ");
PUT^INT(ERROR);
PUT^STR(" on file " & FNAME FOR LEN);
CALL WRITEX(TERMNUM,SBUFFER,@S^PTR '-' @SBUFFER);
! Terminate the program:
CALL PROCESS_STOP_(!process^handle!,
!specifier!,
ABEND);
END;
!------------------------------------------------------------
! Procedure for displaying file-system error numbers on the
! terminal. The parameter is the file number. The file name
! and error number are determined from the file number and
! FILE^ERRORS^NAME is then called to display the text.
!
! FILE^ERRORS^NAME also stops the program after displaying
! the error message.
!------------------------------------------------------------
PROC FILE^ERRORS(FNUM);
INT FNUM;
BEGIN
INT ERROR;
INT .FNAME[0:11];
INT LEN;
CALL FILE_GETINFO_(FNUM,ERROR,FNAME:MAXFLEN,LEN);
CALL FILE^ERRORS^NAME(FNAME:LEN,ERROR);
END;