Guardian Programmer's Guide

Table Of Contents
Using the IOEdit Procedures
Guardian Programmer’s Guide 421922-014
14 - 15
Setting and Getting the Record Number Increment
Inserting Lines
Typically, you insert text after the current line in the file. To do this, you need to choose
an ascending sequence of record numbers that are all greater than the current record
number and all less than the next record number. The following sequence outlines one
approach:
1. Determine the current record number using the GETPOSITIONEDIT procedure.
2. Determine the appropriate record number increment to use by checking the
increment between the current-record and next-record pointers.
For example, if the current position is record 5000 and the next record is record
5100, then a record increment of 10 is appropriate. Inserted lines then have record
numbers 5010, 5020, and so on.
Use the INCREMENTEDIT procedure to set the increment.
3. Start writing records.
4. If any write operation returns error 10, then you are trying to overwrite an existing
record. Return to Step 2 and use a smaller increment.
5. If a smaller increment is not available, you must renumber the subsequent text
line(s) to make room in the record-numbering scheme for the additional lines.
Setting and Getting the Record Number Increment
When you write or renumber records in an EDIT file, each record number differs from
the previous record number by the record number increment.
The INCREMENTEDIT and GETINCREMENTEDIT procedures allow you to control the
record number increment. The following example gets the current record number
increment:
INT(32) INCREMENT;
.
.
INCREMENT := GETINCREMENTEDIT(FILE^NUM);
The next example sets the record number increment to 100:
DELTA := 100D;
CALL INCREMENTEDIT(FILE^NUM,DELTA);
Renumbering Lines
When inserting lines into an EDIT file, you sometimes need to renumber some lines
because you have exhausted the possible record numbers in the range between the
record preceding the inserted text and the record that follows the inserted text. For
example, if you try to insert text between records 1001 and 1002, then record 1002 will
have to be renumbered.