DF_FILE_STATUS
See Also: Get_Attribute, Set_Attribute
The status of the table’s record buffer.
Level
Table
Supported by
All Drivers
Type
Enumeration list, temporary
Access
Read / Write
Values
DF_FILE_INACTIVEDF_FILE_ACTIVEDF_FILE_ACTIVE_CHANGED
Remarks
When a table is opened, a global table buffer is allocated. This buffer can hold one record at a time. The DF_FILE_STATUS attribute returns the status of the global table buffer. A buffer status will remain the same until an operation changes the status. The table below shows the meaning of the possible values and the operations that cause the buffer to get that status.
| Value | Meaning |
|---|---|
DF_FILE_INACTIVE |
The record buffer does not hold an active record. The next save operation on the buffer will create a new record. Record buffers become inactive by issuing a clear. If the table is a recnum table, an alternative way for the buffer to become inactive is by moving a value (any value) to the recnum column. This was often used to create copies of existing records. This technique is considered obsolete; instead, set the DF_FILE_STATUS attribute. |
DF_FILE_ACTIVE |
The record buffer holds an active record. The buffer becomes active when a record is found or after a successful save. |
DF_FILE_ACTIVE_CHANGED |
The record buffer holds an active record of which at least one column has changed. The buffer becomes active changed after moving a value to a column in an active buffer. Moving a value to a column that is already in the buffer is not considered a change. |
It is possible to set this attribute directly, but the only value that you can set it to is DF_FILE_INACTIVE.
Note that Data Dictionaries use local buffers. See Understanding File Buffers and DDO Field Buffers for information on when to use the global or local buffer.
The DF_FILE_STATUS attribute can be used to determine if a find or save operation was successful. When a find operation is successful, the global variable Found is also set. The problem with Found is that it is used by many of the commands and cannot be relied upon unless tested directly after the find operation. The status of the buffer, on the other hand, is only changed by certain operations and can be relied upon even if there are several other operations between the find and the test of the status.
Procedure CreateCustomerCopy Integer iOrgCustomer Integer iNewCustomer
Clear Customer
Move iOrgCustomer To Customer.Customer_Number
Find Eq Customer.Customer_Number
If (Found) Begin
Begin_Transaction
Set_Attribute DF_FILE_STATUS Of Customer.File_Number To DF_FILE_INACTIVE
Move iNewCustomer To Customer.Customer_Number
SaveRecord Customer
End_Transaction
End
End_Procedure // CreateCustomerCopy
The sample procedure above shows how to create a low-level copy of a record.
Function PendingChanges Returns Boolean
Handle hTable
Integer iStatus
Move 0 To hTable
Repeat
Get_Attribute DF_FILE_NEXT_OPENED Of hTable To hTable
If (hTable > 0) Begin
Get_Attribute DF_FILE_STATUS Of hTable To iStatus
If (iStatus = DF_FILE_ACTIVE_CHANGED) ;
Function_Return True
End
Until (hTable = 0)
Function_Return False
End_Function // PendingChanges
The sample function above returns true if there is at least one open table for which the buffer has the DF_FILE_ACTIVE_CHANGED status; it returns false otherwise. It can be used to see if there are pending changes to existing records.