Accessing Filelists

Each entry in FILELIST.CFG is associated with a file number (also called a file handle) and contains three names associated with the file; the display name, the logical name and the root name. These names are accessed as the DF_FILE_DISPLAY_NAME, DF_FILE_LOGICAL_NAME and the DF_FILE_ROOT_NAME attributes respectively. To access these names for a specific file number, the file handle passed to the get_ or set_attribute function is the file number. Following are some examples:

// Set the logical name for file number five to CUSTOMER 


// Get the root name for file number 50 

String lpszRootName

Get_Attribute DF_FILE_ROOT_NAME of 50 to lpszRootName

There are also attributes, DF_FILE_NEXT_USED and DF_FILE_NEXT_EMPTY, for getting the next used or next empty file number. Both of these attributes return a file number relative to the file handle passed to the function. Below is an example of creating a new FILELIST.CFG entry for the first non-used file number after file number 100. If there are no empty slots greater than 100, then DF_FILE_NEXT_EMPTY will be 0.

Handle hFile


// Get the next available file number after 100 

Get_Attribute DF_FILE_NEXT_EMPTY of 100 to hFile

If (hFile > 0) Begin

    // Create the entry in FILELIST.CFG 

    Set_Attribute DF_FILE_LOGICAL_NAME of hFile to "VENDOR"

    Set_Attribute DF_FILE_ROOT_NAME of hFile to "VENDOR"

    Set_Attribute DF_FILE_DISPLAY_NAME of hFile to "Vendor File"


Else If (hFile = 0) Begin

    // There were no unused file numbers

    Showln "No empty FILELIST slots."



See Also

The Filelist

Database Essentials