Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 32
Handling Padding Characters
Trimming Trailing Blanks Before Writing
Use the WRITE^TRIM flag with the OPEN^FILE procedure or the SET^FILE
SET^WRITE^TRIM operation to remove trailing blanks from a record before writing the
record to a file. By default, write-trailing-blank-trimming is turned on.
The following statement uses the OPEN^FILE procedure to turn off write-trailing-blank-
trimming because WRITE^TRIM is selected in the flag mask while the flags
parameter defaults to zeros:
CALL OPEN^FILE(COMMON^FCB,
DFILE,
!block^buffer!,
!block^bufferlen!,
!flags parameter!,
WRITE^TRIM);
The following statement turns it back on again using SET^FILE:
LITERAL ON = 1;
CALL SET^FILE(DFILE,
SET^WRITE^TRIM,
ON);
In the following example, the WRITE^FILE procedure would write 24 bytes of data into
the logical record in the data file if write-trailing-blank-trimming was turned off.
However, because write-trailing-blank-trimming is turned on, trailing blanks are not
copied to the file. Therefore only 16 bytes are actually written:
LITERAL ON = 1;
RECORD^LENGTH := 24;
CALL SET^FILE(DFILE,
ASSIGN^RECORDLENGTH,
RECORD^LENGTH);
CALL OPEN^FILE(COMMON^FCB,
DFILE,
!block^buffer!,
!block^bufferlen!,
!flags parameter!,
WRITE^TRIM);
.
.
CALL SET^FILE(DFILE,
SET^WRITE^TRIM,
ON);
WRITE^BUFFER[0] ':=' " ";
WRITE^BUFFER[1] := WRITE^BUFFER[0] FOR 23;
WRITE^BUFFER ':=' "This is a record";
CALL WRITE^FILE(DFILE,
WRITE^BUFFER,
RECORD^LENGTH);