Guardian Programmer's Guide

Table Of Contents
Using the IOEdit Procedures
Guardian Programmer’s Guide 421922-014
14 - 18
Using Nowait I/O With IOEdit Files
Using Nowait I/O With IOEdit Files
If your program issues a call to AWAITIO with -1 specified for the file number (meaning
wait until any outstanding I/O request from this process is finished), you may get a
completion status for a nowait I/O operation previously started by IOEdit. If such an
AWAITIO call returns a file number that could be that of an IOEdit file, then your
program must use the COMPLETEIOEDIT procedure to inform IOEdit that the I/O
request is complete and pass to IOEdit the results that AWAITIO returned.
The COMPLETEIOEDIT procedure returns a function value of -1 if the file is being
managed by IOEdit; otherwise, it returns 0.
The following example checks the outcome of an AWAITIO call to see if the completing
I/O operation is managed by IOEdit or the file system:
CALL AWAITIO(FILE^NUM,BUFFER,BYTES^READ,TAG);
IF COMPLETEIOEDIT(FILE^NUM,BUFFER,BYTES^READ,TAG)
THEN !IOEdit file
ELSE !other file
See Section 4, Using Nowait Input/Output, for a detailed discussion of nowait I/O.
Compressing an IOEdit File
Compressing files is done to save disk space. Because of the way IOEdit manages its
files, areas of unused space may occur within the space allocated to the file.
You can compress an EDIT file using the COMPRESSEDIT procedure. This
procedure copies a file line by line, making each block as full as possible, thereby
minimizing the number of disk pages occupied by the file. You can do the same thing
using the PUT! command of the EDIT program.
On completion, COMPRESSEDIT returns the file number of the compressed file in the
file-number parameter. The old file gets deleted. The current-record pointer
identifies the first line in the new file (current record number -1).
You identify the file you want compressed by supplying the file-number parameter.
Optionally, you can also specify the record number of the first line of the new file and
the record number increment. If you do not supply these optional parameters, the line
numbering remains unchanged.
The following example compresses a file and renumbers the lines, starting at line 1,
with a record number increment of 1000:
START := 1000D;
INCREMENT := 1000D;
ERROR := COMPRESSEDIT(FILE^NUM,START,INCREMENT);
IF ERROR > 0 THEN ...