Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 70
Sample Initialization
!priority!,
MOMS^PHANDLE);
! The following statement calls a DEFINE which executes the
! appropriate (native or TNS) form of the SET^FILE
! call.
CALL_SET^FILE_ADDRESS_(ERROR,RCV^FILE,OPENERSPHANDLE,
@MOMS^PHANDLE);
! Read the Startup message from the $RECEIVE file:
DO
BEGIN
CALL READ^FILE(RCV^FILE,BUFFER,
!count^returned!,
!prompt^count!,
!max^read^count!,
1);
DO ERROR := WAIT^FILE(RCV^FILE,LENGTH,6000D)
UNTIL ERROR <> SIOERR^IORESTARTED;
END
UNTIL BUFFER = -1; !Startup message read
! Close the $RECEIVE file:
CALL CLOSE^FILE(RCV^FILE);
! Check whether the process is being used interactively.
! That is, is the input file the same terminal file or
! process file as the output file?
CALL DEVICEINFO(BUFFER[9],DEVTYPE,JUNK);
INTERACTIVE :=
IF (DEVTYPE.<4:9> = TERMINAL OR
DEVTYPE.<4:9> = PROCESS) AND
NOT FNAMECOMPARE (BUFFER[9],BUFFER[21]) THEN 1 ELSE 0;
! Initialize the input file:
CALL SET^FILE(INFILE,INIT^FILEFCB);
! The following statement calls a DEFINE which executes the
! appropriate (native or TNS) form of the SET^FILE
! call.
CALL_SET^FILE_ADDRESS_(ERROR,INFILE,ASSIGN^FILENAME,
@BUFFER[9]);
CALL SET^FILE(INFILE,ASSIGN^OPENACCESS,
IF INTERACTIVE THEN READWRITE^ACCESS
ELSE READ^ACCESS);
! If the process is run interactively, set the OUT file
! equal to the IN file:
IF INTERACTIVE THEN