Previous Topic

Next Topic

AvailableFileNbr

Return next available c-tree Plus file number.

Short Name

AVLFILNUM()

Type

Low level data file function

Declaration

COUNT AvailableFileNbr(COUNT numfils)

Description

AvailableFileNbr() returns a valid c-tree Plus 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

c-tree Plus is not initialized.

See c-tree Plus Error Codes for a complete listing of valid c-tree Plus error values.

Example

COUNT super_number,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);