Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 77
Using the SIO Procedures: An Example
!------------------------------------------------------------
! Procedure to open the input and output files. The
! procedure opens structured disk files with a block buffer.
! Unstructured disk files are given no block buffer. The
! output file is opened first with write-only access to
! create it if it does not already exist. The procedure
! closes the file then reopens it with read/write access.
!------------------------------------------------------------
PROC OPEN^OUTPUT(ACCESS^MODE);
INT ACCESS^MODE;
BEGIN
! Set the access mode of the output file to read-only for
! read access or write-only for write access:
CALL SET^FILE(OUTFILE,ASSIGN^OPENACCESS,ACCESS^MODE);
! For a structured file, reopen the file with a block
! buffer:
IF FILE^TYPE.<0:3> = 1
OR FILE^TYPE.<0:3> = 2
OR FILE^TYPE.<0:3> = 3
OR FILE^TYPE.<0:3> = 4
THEN CALL OPEN^FILE(COMMON^FCB,OUTFILE,OUTBLKBUF,
OUTBLKLEN);
! For an unstructured or odd unstructured file, do not use
! a block buffer:
IF FILE^TYPE.<0:3> = 0
OR FILE^TYPE.<0:3> = 8
THEN CALL OPEN^FILE(COMMON^FCB,OUTFILE);
END;