ISMOPEN Procedure

ISMOPEN opens a file that has its FILEORGANIZATION attribute equal to INDEXED or INDEXEDNOTRESTRICTED. If a new file is being created, the file is initialized and the key information is saved. Initialization includes creation of a key root table for each key defined by your program. If your program is accessing an existing file, your file declaration and key information are checked against those of the existing file, and your current record pointer and current key of reference are established.

The information in the FILEINFO parameter is used only when a new output file is opened. If file attributes other than the default values are necessary, the values can be set according to the information found in the File Attributes Programming Reference Manual. The record unit, block size, and maximum record size values must be supplied in the FILEINFO parameter.

The ISMOPEN procedure uses the following parameters and returns an open result:

ISMOPEN (ISAMFILE, FILEINFO, OPENTYPE)
  • ISAMFILE—The user's file.

  • FILEINFO—Information contained in the array is only returned when the OPENTYPE value is 2 (OUTPUT). When you open a file, the following information should be available in word 0 (zero):

    Field

    Value

    Meaning

    [25:01]

    Record unit

    0

    Words

    1

    Characters

    [7:08]

    Number of nonrelative keys

    The meanings of the values returned in word 1 of the array are as follows:

    Field

    Meaning

    [31:16]

    Block size

    [15:16]

    Maximum record size

    Note: Words 2 through n+1 (1 greater than the number of keys) contain 1 word of key information for each key. See “Key Information” earlier in this section.
  • OPENTYPE—Specifies how the file is to be opened. OPENTYPE has the same value as the FILEUSE attribute. ISMOPEN sets the NEWFILE attribute to FALSE when the OPENTYPE is input or input/output. ISMOPEN creates a new file when the OPENTYPE is output.

    Value

    Meaning

    1

    Input

    2

    Output

    3

    Input/Output

    If the open result is 1, the open was successful. Other odd numbered results are errors detected in the ISMOPEN procedure. These errors are given in the following text. For even-numbered results, refer to the explanation of the OPEN results in the File Attributes Programming Reference Manual.

Error Results

Note that bit 0 is included in the value.

Field

Value

Meaning

*[3:4]

3

The length of FILEINFO was less than that required for the number of keys given.

 

5

OPTION was not a valid value.

 

7

An Error in key setting.

 

9

The file was already open.

 

11

Two primary keys were found.

 

13

No primary key was found.

 

15

The keys overlap.