Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 69
Sample Initialization
!------------------------------------------------------------
!Procedure to initialize file control blocks for the input
!file and output file specified in the Startup message, as
!well as a separate data file.
!------------------------------------------------------------
PROC INIT;
BEGIN
! Initialize the $RECEIVE file and common FCB:
?IF PTAL !Begin pTAL statements
STRING .SBUF = BUFFER;
?ENDIF PTAL !End pTAL statements
?IFNOT PTAL !Begin TAL statements
STRING .SBUF := @BUFFER '<<' 1;
?ENDIF PTAL !End TAL statements
CALL SET^FILE(RCV^FILE,INIT^FILEFCB^D00);
CALL SET^FILE(COMMON^FCB,INIT^FILEFCB^D00);
SBUF ':=' "$RECEIVE ";
! 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,ASSIGN^FILENAME,
@BUFFER);
CALL SET^FILE(RCV^FILE,ASSIGN^RECORDLENGTH,132);
! Open $RECEIVE for nowait I/O:
CALL OPEN^FILE(COMMON^FCB,RCV^FILE,
!block^buffer!,
!block^bufferlen!,
NOWAIT,NOWAIT);
! Allow Startup message from creator only:
CALL PROCESSHANDLE_GETMINE_(MY^PHANDLE);
ERROR := PROCESS_GETPAIRINFO_(MY^PHANDLE,
!pair:maxlen!,
!pair^len!,
!primary^processhandle!,
!backup^processhandle!,
!search^index!,
MOMS^PHANDLE);
IF ERROR = 7 THEN CALL PROCESS_GETINFO_(!process^handle!,
!file^name:maxln!,
!file^name^len!,