Guardian Programmer's Guide

Table Of Contents
Writing a Command-Interpreter Monitor ($CMON)
Guardian Programmer’s Guide 421922-014
23 - 81
Sample Command-Interface Program
! Obtain the new priority for the processor from the operator:
DO
BEGIN
SBUFFER ':=' ["Enter new status: 1 for priority,",
"0 for non-priority: "]
-> @S^PTR;
CALL WRITEREADX(TERMNUM,SBUFFER,@S^PTR '-' @SBUFFER,
BUFSIZE,BYTES^READ);
IF <> THEN CALL FILE^ERRORS(TERMNUM);
SBUFFER[BYTES^READ] := 0;
@NEXT^ADR := DNUMIN(SBUFFER,NUMBER,10,STATUS);
END
UNTIL STATUS = 0
AND @NEXT^ADR = $XADR(SBUFFER[BYTES^READ])
AND ($INT(NUMBER) = 1 OR $INT(NUMBER) = 0);
! Put the new processor status into the message structure:
CPU^CHANGESTATUS^MESSAGE.STATUS := $INT(NUMBER);
! Send the message to $CMON:
CALL WRITEREADX(CMONNUM,CPU^CHANGESTATUS^MESSAGE,
$LEN(CPU^CHANGESTATUS^MESSAGE),
2,BYTES^READ);
IF <> THEN CALL FILE^ERRORS(CMONNUM);
END;
!------------------------------------------------------------
! Procedure to exit the process.
!------------------------------------------------------------
PROC EXIT^PROGRAM;
BEGIN
CALL PROCESS_STOP_;
END;
!------------------------------------------------------------
! Procedure to respond to an invalid request. This procedure
! displays a message and then returns to the main procedure
! to redisplay the menu.
!------------------------------------------------------------
PROC INVALID^REQUEST;
BEGIN
PRINT^STR("Invalid request. Please try again");
END;