Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

AvailableFileNbr

Return next available FairCom DB file number.

Short Name

AVLFILNUM()

Type

Low-Level data file function

Declaration

COUNT AvailableFileNbr(COUNT numfils)

Description

AvailableFileNbr() returns a valid FairCom DB file number that is available for use (i.e., not presently assigned to a file). numfils is the number of consecutive file numbers required. If numfils consecutive file numbers are not available, AvailableFileNbr() returns -1.

This function does not consume the file number(s) returned. The file number is consumed only if you subsequently create or open a file with the returned file number. Therefore, two calls in succession to AvailableFileNbr(), without any intervening creates, opens, or closes, will return the same file number. However, the scope is local to your application. No multi-user interference is possible, since each application only references file numbers internally.

If used for a host superfile, remember to use an argument of 2.

Return

AvailableFileNbr() returns the first file number in the series requested. If the requested block of file numbers is not available, it returns -1. Check uerr_cod for the error value.

Value

Symbolic Constant

Explanation

46

FUSE_ERR

No file number is available.

47

ISDP_ERR

FairCom DB is not initialized.

See FairCom DB Error Codes for a complete listing of valid FairCom DB error values.

Example

FILENO super_number;

COUNT retval;


super_number = AvailableFileNbr(2);

if (super_number == -1) {

printf("\nNot enough file numbers available");

exit(1);

}

retval = OpenCtFile(super_number,"superfil",

ctPERMANENT | ctEXCLUSIVE | ctSUPERFILE);

TOCIndex