Skip to content

DF_FILE_OPENED

See Also: Get_Attribute, Set_Attribute

Indicates whether the table is opened in the current application.

Level

Table

Supported by

All Drivers

Type

Numeric, temporary

Access

Read Only

Values

  • True
  • False

Remarks

If DF_FILE_OPENED is true, the table is opened in the current application. This attribute will not return whether the table is opened in another application, only the current one. This attribute cannot be set directly; it reflects the open commands executed by the application.

There is no generic way to check if a table is open in another application. If the database used supports exclusive open mode, one could attempt to open the table exclusively and if that fails, conclude that the table is open in some other application. Although it would work, it is a pretty blunt way to check this.

The DataFlex open logic will not open a table if there already is an open table using the same number. If one attempts to open two different tables using the same table number, the second attempt will not have any effect. One can use the DF_FILE_OPENED attribute to determine if the table is already open and decide to close the table or use another table number. Note that table numbers used by an application do not need to correspond 100% with the table numbers assigned in the filelist.

Function FirstAvailableNumber String sTable Returns Handle
    Integer iNumTables
    Handle hTable
    Boolean bOpen

    Get_Attribute DF_NUMBER_FILES_SUPPORTED To iNumTables
    For hTable From 1 To iNumTables
        Get_Attribute DF_FILE_OPENED Of hTable To bOpen
        If (Not(bOpen)) ;
            Function_Return hTable
    Loop

    Function_Return 0
End_Function // FirstAvailableNumber

The sample function above returns the first available number to open a table.