Guardian Programmer's Guide

Table Of Contents
Using the IOEdit Procedures
Guardian Programmer’s Guide 421922-014
14 - 12
Selecting a Starting Point
Selecting a Starting Point
Most I/O operations involve reading or writing sequential data. However, unlike other
available methods of access to EDIT files, the IOEdit routines allow you to start your
read or write operation at any record in the file. This record can be:
The beginning of the file (record number -1)
The end of the file (record number -2)
Any specified record number
The record indicated by the next-record pointer (record number -3)
You can set the starting position for a series of one or more sequential I/O operations
using one of the following operations:
Specify the record number in a call to the POSITIONEDIT procedure.
Specify the record number directly in the call to READEDIT.
Specify the record number directly in a call to WRITEEDIT.
Using the POSITIONEDIT Procedure
The following example sets the value of the next-record pointer to line 50 using the
POSITIONEDIT procedure:
RECORD^NUMBER := 50000D;
ERROR := POSITIONEDIT(FILE^NUM,RECORD^NUMBER);
IF ERROR > 0 THEN ...
Using the READEDIT Procedure
The following example sets the value of the next-record pointer to the first line in the
file by supplying -1D as the record number to the READEDIT procedure:
RECORD^NUMBER := -1D;
ERROR := READEDIT(FILE^NUM,RECORD^NUMBER,BUFFER,BUFFER^LEN,
BYTES^READ);
IF ERROR > 0 THEN ...
If you supply the READEDIT procedure with a record number that does not exist, then
the next record is assumed to be the next-higher record number that does exist.
Using the WRITEEDIT Procedure
The following example sets the value of the next-record pointer to the end of the file
using the WRITEEDIT procedure:
RECORD^NUMBER := -2D;
ERROR := WRITEEDIT(FILE^NUM,RECORD^NUMBER,BUFFER,WCOUNT);
IF ERROR > 0 THEN ...