Skip to content

Accessing File Lists

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 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.

Examples

Setting the Logical Name

// Set the logical name for file number five to CUSTOMER
Set_Attribute DF_FILE_LOGICAL_NAME of 5 to "CUSTOMER"

Getting the Root Name

// Get the root name for file number 50
String lpszRootName
Get_Attribute DF_FILE_ROOT_NAME of 50 to lpszRootName

Next Used and Empty File Numbers

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.

Example: Creating a New FILELIST.CFG Entry

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"
End
Else If (hFile = 0) Begin
    // There were no unused file numbers
    Showln "No empty FILELIST slots."
End

See Also