VMS Help
ADA, Language Topics, INDEXED_IO

 *Conan The Librarian

    INDEXED_IO is a generic Compaq Ada package that provides input-
    output operations for access to and from indexed files.

    All of the file management input-output operations are also
    provided by this package (see HELP Ada Language_Topics File_
    Management).

    The package INDEXED_IO provides a generic READ_BY_KEY procedure,
    which defines input for the given element type. This procedure
    must be instantiated with an actual type parameter for the
    generic parameter KEY_TYPE; it may be instantiated with or
    without a value for the generic parameter DEFAULT_KEY_NUMBER.
    The range of values for DEFAULT_KEY_NUMBER is 0 to 254; a value
    of 0 (the default) designates the primary key.

    If the RELATION parameter to the READ_BY_KEY procedure is
    specified, it must have a value of EQUAL_NEXT, EQUAL, or NEXT
    (the default is EQUAL).

  1 - READ

    procedure READ (FILE : in  FILE_TYPE; ITEM : out  ELEMENT_TYPE);

    generic
        type KEY_TYPE is private;
        DEFAULT_KEY_NUMBER : INTEGER := 0;
    procedure READ_BY_KEY(FILE       : in  FILE_TYPE;
                          ITEM       : out ELEMENT_TYPE;
                          KEY        : in  KEY_TYPE;
                          KEY_NUMBER : in  INTEGER :=
                                              DEFAULT_KEY_NUMBER;
                          RELATION   : in  RELATION_TYPE := EQUAL);

    Operates on a file of mode IN_FILE or INOUT_FILE. In the case
    of the first form, returns, in the parameter ITEM, the value of
    the next element, according to the most recent key and relation
    information. In the case of the second form, returns, in the
    parameter ITEM, the value of the element specified by the given
    key information; KEY gives the key value; KEY_NUMBER designates a
    primary (0) or alternate key (1 to 254); and RELATION determines
    the kind of match to be made for the key value. For both forms,
    the element read becomes the current element. In the case of the
    first form, the next sequential element becomes the next element,
    according to the most recent key and relation information. In
    the case of the second form, the next sequential element becomes
    the next element. If neither the key nor the relation information
    changes from one READ_BY_KEY operation to the next, the same
    element will continue to be read.

    The exception MODE_ERROR is raised if the current mode is OUT_
    FILE. The exception END_ERROR is raised if an attempt is made to
    read past the end of the file by the first form. The exception
    LOCK_ERROR is raised if the element to be read is locked; this
    error is possible only if the external file is being shared.
    The exception EXISTENCE_ERROR is raised if the element does not
    exist. The exception KEY_ERROR is raised if the size of the given
    key is not a multiple of eight bits.

  2 - WRITE

    procedure WRITE(FILE : in FILE_TYPE; ITEM : in ELEMENT_TYPE);

    Operates on a file of mode INOUT_FILE or OUT_FILE. Gives the
    value of the parameter ITEM to the element whose position in the
    given file is specified by the key information contained within
    the value of ITEM.

    The exception MODE_ERROR is raised if the current mode is IN_
    FILE. The exception USE_ERROR is raised if the element position
    in the file has already been written. The exception KEY_ERROR
    is raised if a key has been duplicated and if duplicates are not
    allowed by the external file.

  3 - UPDATE

    procedure UPDATE(FILE : in FILE_TYPE; ITEM : in ELEMENT_TYPE);

    Operates on a file of mode INOUT_FILE. Updates the current
    element of the given file with the value of the parameter ITEM.

    The exception MODE_ERROR is raised if the current mode is not
    INOUT_FILE. The exception USE_ERROR is raised if the current
    element is undefined at the start of this operation or if some
    key specification in ITEM violates the external file attributes
    defined for that key. The exception KEY_ERROR is raised if a key
    has been changed or duplicated and if changes or duplicates are
    not allowed by the external file.

  4 - UNLOCK

    procedure UNLOCK(FILE : in FILE_TYPE);

    Operates on a file of any mode. After this operation, the current
    element is undefined.

  5 - DELETE_ELEMENT

    procedure DELETE_ELEMENT(FILE : in FILE_TYPE);

    Operates on a file of mode INOUT_FILE. Deletes the current
    element of the file.

    The exception MODE_ERROR is raised if the current mode is not
    INOUT_FILE. The exception USE_ERROR is raised if the current
    element is undefined at the start of this operation.

  6 - END_OF_FILE

    function END_OF_FILE(FILE : in FILE_TYPE) return BOOLEAN;

    Operates on a file of mode IN_FILE or INOUT_FILE. Returns TRUE if
    there are no more elements (according to the most recent key and
    relation information) starting at the next element in the file;
    otherwise returns FALSE.

    The exception MODE_ERROR is raised if the current mode is OUT_
    FILE.
  Close     Help