TABLE.COMPACT Function

Syntax

L Compact(C file)

Arguments

file

The table (.dbf file) or data dictionary to be compacted. You can use wildcard characters (? and * ) in the Filename.

Description

Compact DBF,SET,DDD,ALB files.

Discussion

The TABLE.COMPACT() method compacts the table (.dbf file) or data dictionary as specified by filename. When you delete a record in a table it is marked for deletion. Similarly, when you delete a layout design (form, browse, report, etc), it is only marked for deletion. When you edit a layout design, the old design is not overwritten, but the code is just marked for deletion. Packing removes the marked records and layouts. After many edits, there is a lot of deleted code still being saved. Compact will remove this unneeded code. A good rule of thumb is to compact after any design session before you close the database. If you are making many edits and saving after each edit, you may want to compact more often. Note : This method is similar to the File > Database Compact command on the Alpha Anywhere menu. However, it allows you to compact dictionaries on a file by file basis. It is also very similar to the DICTIONARY.UPDATE() method. The only difference is that when you specify a .dbf file in the DICTIONARY.UPDATE() method, Alpha Anywhere compacts the corresponding dictionary file, whereas TABLE.COMPACT() packs the .DBF file (as in <TBL>.PACK()). Dictionary filename extensions are:

.DDD - Table
.SET - Set
.ALB - Library

Example 

This script tests if it can get exclusive access to invoice_items. If so, it compacts the table, and its dictionary.

file = "c:\program files\a5v5\invoice\invoice_items.dbf"
file_dict = "c:\program files\a5v5\invoice\invoice_items.ddd"
test = table.in_use(file)
if (.not. test ) then
    table.COMPACT(file)
    table.COMPACT(file_dict)
else
    ui_msg_box("Error","File is in use.")
end if

See Also