Guardian Programmer's Guide

Table Of Contents
Writing a Command-Interpreter Monitor ($CMON)
Guardian Programmer’s Guide 421922-014
23 - 67
Sample $CMON Program
!------------------------------------------------------------
! Procedure to read the Startup message, and open the IN
! file, and open the $RECEIVE file. This procedure also
! initializes the CPU^LIST array.
!------------------------------------------------------------
PROC INIT;
BEGIN
STRING .RECV^FILE[0:MAXFLEN - 1];
INT RECVLEN;
STRING .TERMNAME[0:MAXFLEN - 1];
INT TERMLEN;
INT ERROR;
INT I;
! Read Startup message and save it in global data area:
CALL INITIALIZER(!rucb!,
!passthru!,
SAVE^STARTUP^MESSAGE);
! Open the IN file:
ERROR := OLDFILENAME_TO_FILENAME_(
CI^STARTUP.INFILE.VOLUME,
TERMNAME:MAXFLEN,TERMLEN);
IF ERROR <> 0 THEN CALL PROCESS_STOP_;
ERROR := FILE_OPEN_(TERMNAME:TERMLEN,TERMNUM);
IF ERROR <> 0 THEN CALL PROCESS_STOP_;
! Open $RECEIVE:
RECV^FILE ':=' "$RECEIVE" -> @S^PTR;
RECVLEN := @S^PTR '-' @RECV^FILE;
ERROR := FILE_OPEN_(RECV^FILE:RECVLEN,
RECVNUM,
!access!,
!exclusion!,
!nowait^depth!,
1);
IF ERROR <> 0 THEN
CALL FILE^ERRORS^NAME(RECV^FILE:RECVLEN,ERROR);
! Initialize the CPU^LIST array:
I := 2;
DO
BEGIN
CPU^LIST[I] := 0;
I := I + 1;
END
UNTIL I = TOP^CPU^NUMBER;
CPU^LIST[0] := 1;