Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 30
Handling Long Writes
Handling Long Writes
The OPEN^FILE and SET^FILE procedures provide options that allow write operations
that are longer than the logical-record length without losing any data.
The SIO routines normally truncate write operations that are longer than the logical-
record length, saving only that part of the write that fits into the logical record. In such
cases, the system does not issue an error. However, if you issue the OPEN^FILE
procedure with the WRITE^FOLD flag set or the SET^FILE procedure with the
SET^WRITE^FOLD operation, then the write operation will be split into as many logical
records as it needs.
The following example shows how you can use the OPEN^FILE procedure to write a
42-character buffer to a file whose logical-record length is 16 bytes. The data is saved
in the file in three logical records:
RECORD^LENGTH := 16;
CALL SET^FILE(DFILE,
ASSIGN^RECORDLENGTH,
RECORD^LENGTH);
CALL OPEN^FILE(COMMON^FCB,
DFILE,
!block^buffer!,
!block^bufferlen!,
WRITE^FOLD,
WRITE^FOLD);
.
.
BUFFER ':=' "This write operation is more than 16 bytes"
-> @S^PTR;
CALL WRITE^FILE(DFILE,
BUFFER,
@S^PTR '-' @SBUFFER);