Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

ISAM Function Overview

Several ISAM functions have two versions - a standard version and an extended version. The extended version has the same name as the standard version with the suffix of Xtd. The extended version allows access to advanced functionality such as the security features of the FairCom Server.

The functions in the first section deal with Incremental ISAM structures. The functions in the second section deal with ISAM parameter files. The remaining sections work with Incremental ISAM structures and ISAM parameter files.

In This Section

Incremental ISAM System Functions

ISAM Parameter File System Functions

Data File and Index Functions

Set Functions

Previous Topic

Next Topic

Incremental ISAM System Functions

These functions work with Incremental ISAM structures in the application.

CloseIFile

Closes a data file and its associated indexes, based on an incremental ISAM structure.

CloseISAM

Closes all of the data files and indexes opened with calls to OpenISAM(), CreateISAM(), OpenIFile(), or CreateIFile(). One call to the function is all that is necessary. When using the FairCom Server this call also logs you off the Server.

CloseRFile

Closes a data file and its associated indexes that have been opened with the OpenFileWithResource() function.

CreateIFile, CreateIFileXtd, and CreateIFileXtd8

Creates a data file and its associated indexes, based on an incremental ISAM structure.

GetIfile

Retrieve the IFIL structure stored in the file’s resource.

InitISAM and InitISAMXtd

Prior to calling OpenFileWithResource(), OpenIFile(), or CreateIFile(), you must initialize the c-tree system. This allocates index buffer and file handle space for the files opened as a part of the incremental ISAM system. When using the FairCom Server the extended call also logs on to the Server.

OpenIFile and OpenIFileXtd

Opens an existing data file and its associated indexes using an incremental ISAM structure.

Note: This function supports EXCLUSIVE file opens. For more information, please refer to Multi-user File Mode.

OpenFileWithResource and OpenFileWithResourceXtd

Similar to OpenIFile(), but instead of using an incremental ISAM structure declared in the program it uses similar information stored as a Resource in the data file when it was created with CreateIFile().

PermIIndex and PermIIndex8

Adds one or more new incremental ISAM indexes and automatically adds key values from the existing records. The information about the new index is added to the incremental ISAM resource.

RebuildIFile, RebuildIFileXtd, and RebuildIFileXtd8

If a data file or index becomes corrupt, use RebuildIFile() to recover them. Based on the information found in an incremental ISAM structure, RebuildIFile() goes through every record in the data file to update the file header and then recreates all the required keys.

TempIIndexXtd and TempIIndexXtd8

Similar to PermIIndex() in that one, or more, indexes will be created, with the existing records being added to the indexes. However, the incremental ISAM resource is NOT updated.

Previous Topic

Next Topic

ISAM Parameter File System Functions

These functions work with the information found in the ISAM Parameter File.

CloseISAM

Closes all of the data files and indexes opened with calls to OpenISAM(), CreateISAM(), OpenIFile(), or CreateIFile(). One call to the function is all that is necessary. When using the FairCom Server this call also logs you off the Server.

CreateISAM and CreateISAMXtd

Creates all data files and indexes described in the ISAM parameter file. When using the FairCom Server this call also logs you on to the Server.

OpenISAM and OpenISAMXtd

Opens all data files and indexes described in the ISAM parameter file. The files and indexes must already exist. When using the FairCom Server this call also logs you on to the Server.

Note: This function supports EXCLUSIVE file opens. For more information, please refer to Multi-user File Mode.

Previous Topic

Next Topic

Data File and Index Functions

AddRecord

Adds a fixed-length data record to a file and updates all associated indexes.

AddVRecord

Adds a variable-length data record to a file and updates all associated indexes.

CurrentFileOffset

Retrieves the byte position of the current ISAM record.

CurrentISAMKey

Supplemental function for building an ISAM key from a data record image.

DeleteRecord and DeleteVRecord

Deletes the current data record and removes the associated keys from the indexes.

GetRecord and GetVRecord

Finds the target key in an index, and reads the matching data record.

FirstRecord and FirstVRecord

Reads either the first physical record in a data file or the record that has the first key in a particular index.

GetGTERecord and GetGTEVRecord

Reads the record with a key that is greater than or equal to the target key.

GetLTERecord and GetLTEVRecord

Reads the record with a key that is less than or equal to the target key.

LockISAM

Enables or frees locks

LastRecord and LastVRecord

Reads either the last physical record in a data file or the record that has the last key in a particular index.

NextRecord and NextVRecord

Reads the next record in the data file, either in sequential physical order or key order. This is relative to the current ISAM record.

PreviousRecord and PreviousVRecord

Reads the previous record in the data file, either in sequential physical order or key order. This is relative to the current ISAM record. Note the limitations of this function in the function reference section.

ReadIsamData and ReadIsamVData

Read the data record at a given record position. Does not access the index, since the record offset within the data file is known.

ReReadRecord

Reread current ISAM record. Only reads the fixed portion of a variable-length record.

ReReadVRecord

Unlike the variable-length API functions, functions such as FirstRecord() read only the fixed-length portion of the data record. ReReadVRecord() reads the entire variable-length record after a fixed-length function. Make sure that your buffer is large enough by getting the record length with VRecordLength().

ResetRecord

Updates the current ISAM record. Use this to manipulate the c-tree internal representation of the current ISAM record, such as restoring the current ISAM record to the record position before a rewrite.

ReWriteRecord

Rewrite the current fixed-length data record.

ReWriteVRecord

Rewrite the current variable-length data record.

ReWritePartialRecord

Rewrite only a first portion of the current fixed or variable-length record.

SetRecord

Allows you to alter the current ISAM buffers and data record image location.

TransformKey

The ISAM parameters for your application specify how a key is to be built. This may include translations of segments of the key. You can use TransformKey() to build a target according to the ISAM parameters. Many ISAM functions require a properly transformed target.

VRecordLength

Returns the length of current variable-length ISAM data record.

Previous Topic

Next Topic

Set Functions

A "set" is a group of records that have keys that match a certain target. These functions are used to define and access Sets. For example, an index contains the following keys:

CASE DISKCASE DISKDRIVE DISKETTE KEY KEYBOARD KEYCAP

When using functions like FirstRecord() and NextRecord() to scan through the index, looking for records, these functions work on the entire index file. FirstRecord() finds the first key in the file, CASE, and NextRecord() gives each of the following keys in turn, on through KEYCAP. If you define a set with a target of “DISK” and a target length of 4, FirstInSet() finds the key DISKCASE. NextInSet() gives each of the following keys in turn, with DISKETTE being the last key found. This allows you to establish subsets of an index, and process them as if they were a separate index.

Normally one set is worked with at a time, as established by the functions FirstInSet(), LastInSet(), or PositionSet(). However, it is also possible to define and manage multiple sets simultaneously. Call ChangeSet() with a unique set number when a new set is necessary. Each time ChangeSet() is called with a unique, previously unused, set number, AllocateSet() creates a new set of key buffers. To change between the active sets, use the unique set numbers passed at the initial ChangeSet() calls. ChangeSet in the function reference section has a good working example of this behavior.

AllocateSet

Internal c-tree function called by ChangeSet() to allocate ISAM key buffers for multiple, simultaneous sets.

ChangeSet

If you are using multiple, simultaneous sets, you must use this function to specify which set is going to be used by a set function call. If the value passed to this function has not been previously used, AllocateSet() is called automatically.

DoBatch

Performs operations on a set of records. For instance, it can delete all records in a set, read all records in a set into a buffer, or count the number of records in a set.

FirstInSet and FirstInVSet

Establishes a set based on a target key value and length. Reads the first record of the set into the buffer, making it the current ISAM record.

FreeSet

Frees memory allocated by AllocateSet(). CloseISAM() also frees the set buffers.

LastInSet and LastInVSet

Reads the last record in a set. Establishes a set, as does FirstInSet().

NextInSet and NextInVSet

Equivalent to NextRecord(), except that it works on the current set instead of the entire index. NextInSet() is limited to working on index files.

PositionSet and PositionVSet

Establishes a set, as does FirstInSet(), but the set is based on the key value for the current ISAM record, rather than on a target value passed as a parameter.

PreviousInSet and PreviousInVSet

Equivalent to PreviousRecord(), except that it works on the current set instead of the entire index. PreviousInSet() is limited to working on index files.

TOCIndex