Guardian Programmer's Guide

Table Of Contents
Writing a Command-Interpreter Monitor ($CMON)
Guardian Programmer’s Guide 421922-014
23 - 70
Sample Command-Interface Program
! For a user message, Select a procedure depending on
! the results of the read operation:
0 -> BEGIN
CASE BUFFER[0] OF
BEGIN
-60 -> CALL PROCESS^CONFIG^MSG;
-59 -> CALL PROCESS^PRELOGON^MSG;
-50 -> CALL PROCESS^LOGON^MSG;
-51 -> CALL PROCESS^LOGOFF^MSG;
-53 -> CALL PROCESS^ILLEGAL^LOGON^MSG;
-57 -> CALL PROCESS^PASSWORD^MSG;
-58 -> CALL PROCESS^REMOTEPASSWORD^MSG;
-52 -> CALL PROCESS^PROCESSCREATION^MSG;
-56 -> CALL PROCESS^ALTPRI^MSG;
-54 -> CALL PROCESS^ADDUSER^MSG;
-55 -> CALL PROCESS^DELUSER^MSG;
50 -> CALL CHANGE^LOGON^MESSAGE;
51 -> CALL CHANGE^LOGOFF^MESSAGE;
61 -> CALL REJECT^REQUESTS;
62 -> CALL ACCEPT^REQUESTS;
63 -> CALL CHANGE^CPU^STATUS;
OTHERWISE -> CALL UNEXPECTED^MESSAGE;
END;
END;
OTHERWISE -> CALL FILE^ERRORS(RECVNUM);
END;
END;
END;
Sample Command-Interface Program
The command-interface program displays a menu allowing the operator to choose the
run-time control function. A separate procedure processes each selection from the
menu.
The CONTROL^MAIN procedure calls INIT to perform initialization for the program
and then enters a loop in which it displays a menu and calls a procedure to
process the menu selection.
The INIT and SAVE^STARTUP^MESSAGE procedures open the IN file and call
CREATE^AND^OPEN^CMON to create the $CMON process if it does not exist
and to open it. If $CMON does not exist, then this procedure creates it.
The CREATE^AND^OPEN^CMON procedure calls OPEN^CMON to open the
$CMON process. If $CMON does not exist, then this procedure creates it before
calling OPEN^CMON. On return from OPEN^CMON, this procedure sends a
Startup message to the new process, closes $CMON, then calls OPEN^CMON to
open it again.