Variable Length Fields
A variable length field is one for which the number of characters in it is not determined beforehand.

With variable length fields, special characters called separators have to be used. There may be field separators which show the end of the field or record separators to show the end of the record.

Advantage : The whole file will be much smaller and will not need so much storage space.

Example 1

The first three records of the file in Task 2 would therefore be stored as in the following table (each square represents one byte):

# is a field separator

% is a record separator

9 1 2 3 0 # S a m # F e n e l l a # B #
% 9 1 2 3 1 # S a n d e r s # M i c h a
e l # G # % 9 1 2 3 2 # S a u n d e r s
# I a n # B # %                        
                                       

Each record takes up ? bytes of storage space - It is impossible to say because each one is different.

The first three records of the file take up 68 bytes of storage. This is smaller than when using fixed length fields (78 bytes)

 

Exercise : Variable Length Fields
Some of the interactive tasks are only available on the CD version.
(Green indicates success)