Guardian Programmer's Guide

Table Of Contents
Writing a Command-Interpreter Monitor ($CMON)
Guardian Programmer’s Guide 421922-014
23 - 84
Sample Command-Interface Program
!------------------------------------------------------------
! Procedure handles creating and opening a $CMON process. If
! $CMON already exists it calls OPEN^CMON to open it. If
! $CMON does not exist, it creates the process and sends it
! the standard process initialization sequence.
!------------------------------------------------------------
PROC CREATE^AND^OPEN^CMON(CMON^NUM,CMON^OBJECT^NAME,
OBJFILE^NAMELEN,PROCESS^NAME,
PROCESS^NAMELEN);
INT .CMON^NUM; !file number of $CMON process
STRING .CMON^OBJECT^NAME; !name of $CMON object file
INT OBJFILE^NAMELEN; !file-name length
STRING .PROCESS^NAME; !name of $CMON process
INT PROCESS^NAMELEN; !process-name length
BEGIN
INT ERROR;
! Check whether $CMON already running. If so, open it.
! If not, create it and open it:
ERROR := PROCESS_GETPAIRINFO_(
,PROCESS^NAME:PROCESS^NAMELEN);
! IF $CMON already exist, open it:
CASE ERROR OF
BEGIN
0, 4 -> BEGIN
! The process already exists; open it:
CALL OPEN^CMON(PROCESS^NAME,PROCESS^NAMELEN,
CMON^NUM);
END;
9 -> BEGIN
! The process does not exist, create it and open it,
! send it a Startup message, close it, and then reopen
! it: