Skip to content

DF_FILE_MODE

See Also: Get_Attribute, Set_Attribute

The access mode for the table.

Level

Table

Supported by

All Drivers

Type

Flag of bits, temporary

Access

Read / Write

Values

Any iored combination of the following modes:

  • DF_FILEMODE_DEFAULT
  • DF_FILEMODE_NO_REREAD
  • DF_FILEMODE_NO_LOCKS
  • DF_FILEMODE_NO_EDITS
  • DF_FILEMODE_NO_DELETES
  • DF_FILEMODE_NO_FINDS
  • DF_FILEMODE_NO_CREATES

Predefined combinations of the above:

  • DF_FILEMODE_READONLY
  • DF_FILEMODE_SINGLE_USER

Remarks

Access modes affect operational characteristics of a table.

Constant Value Meaning
DF_FILEMODE_DEFAULT 0 No access restrictions on the table.
DF_FILEMODE_NO_REREAD 1 Reread on the table is not allowed.
DF_FILEMODE_NO_LOCKS 2 The table will not be locked.
DF_FILEMODE_SINGLE_USER 3 Table is opened in single user mode.
DF_FILEMODE_NO_EDITS 8 Records in the table cannot be edited.
DF_FILEMODE_NO_DELETES 16 Records in the table cannot be deleted.
DF_FILEMODE_NO_FINDS 32 Records in the table cannot be found.
DF_FILEMODE_NO_CREATES 64 Records in the table cannot be created.
DF_FILEMODE_READONLY 91 Table is opened in read-only mode.

DF_FILEMODE_READONLY combines DF_FILEMODE_NO_REREAD, DF_FILEMODE_NO_LOCKS, DF_FILEMODE_NO_EDITS, DF_FILEMODE_NO_DELETES, and DF_FILEMODE_NO_CREATES.

DF_FILEMODE_SINGLE_USER combines DF_FILEMODE_NO_REREAD and DF_FILEMODE_NO_LOCKS.

You can make your own combinations of access restrictions by using the bitwise or operator (ior) to combine individual modes. For example, if you want to place a restriction on table MyTable that no records can be created or updated, you would use the following code fragment:

Set_Attribute DF_FILE_MODE Of MyTable.File_Number to ;
(DF_FILEMODE_NO_EDITS iOr DF_FILEMODE_NO_CREATES)

It is expected that the only settings an average DataFlex programmer will need are DF_FILEMODE_DEFAULT and DF_FILEMODE_READONLY. Since the DataSet and DataDictionary classes support smart file mode, setting the file mode is not needed to tune for lock performance. Setting file mode to read-only for reporting can improve report speed.

Function OverallTotal Returns Number
    Number nTotal
    Integer iOrgMode

    Get_Attribute DF_FILE_MODE of OrderHea.File_Number to iOrgMode
    Set_Attribute DF_FILE_MODE of OrderHea.File_Number to DF_FILEMODE_READONLY
    Clear OrderHea
    Find Gt OrderHea By 1

    While (Found)
        Add OrderHea.Order_total to nTotal
        Find GT OrderHea By 1
    End

    Set_Attribute DF_FILE_MODE Of OrderHea.File_Number to iOrgMode
    Function_Return nTotal
End_Function

The sample function above sets the file mode of the OrderHea table temporarily to read-only and then calculates the total amount of all orders.