Loading Lines

A record contains an array of fixed-length lines, each of which stores data fields of random lengths separated by spaces.  The lines have the initial value of spaces.  Whenever a certain program selects the record, it attempts to load up to two new fields.  For each new field, the program examines the lines in sequence, inserting the field at the end of the first line found to have sufficient free space.

The following example demonstrates the case of an arrangement of existing fields within the lines that permits the insertion of only one of two new fields, but would have permitted the insertion of both of them if an extra existing field previously had been inserted.

In the chart below, there are 3 lines, each 27 bytes in length, in which: a capital letter denotes a data field in the order of its insertion; sp denotes the space character separating two fields; fs denotes the free space at the end of a line; and a numerical suffix denotes length.

In the “AFTER” image, field B2 is omitted.

                       BEFORE                                      AFTER

LINE 1     A5  sp1  B2  sp1  C4  sp1  D3  fs10       A5  sp1  C4  sp1  D3  sp1  E11  fs1

LINE 2     E11  sp1  F3  sp1  G3  fs8                F3  sp1  G3  sp1  H9  sp1  I5  fs4

LINE 3     H9  sp1  I5 sp1  J10  fs1                 J10  fs17

If the two new fields to be inserted are 9 bytes long and 7 bytes long, they would fit into lines 1 and 2 if field B2 previously had been inserted, but otherwise they will not both fit into line 3.

Copyright © 2007 The Stevens Computing Services Company, Inc.  All rights reserved.