User Tools

Site Tools


pack_remove_deleted_records_.htm
Navigation:  Language Reference > 13 - Built-in Functions >====== PACK (remove deleted records) ====== Previous pageReturn to chapter overviewNext page

PACK(file)

blk2blue.jpg

PACK Removes deleted records from a data file and rebuilds its keys.
file The label of a FILE declaration.

The PACK statement removes deleted records from a data file and rebuilds its keys. The resulting data files are as compact as possible. PACK requires at least twice the disk space that the file, keys, and memos occupy to perform the process. New files are created from the old, and the old files are deleted only after the process is complete. PACK requires exclusive access to the file. Therefore, the file must be opened with access mode set to 12h (Read/Write Deny All) or 22h (Read/Write Deny Write).

PACK will generate events to the currently open window if you assign a value (an integer from 1 to 100) to PROP:ProgressEvents for the affected FILE before you issue the PACK. The larger the value you assign to PROP:ProgressEvents, the more events are generated and the slower the PACK will progress. These events allow you to indicate to the user the progress of the PACK. This can keep end-users informed that PACK is still working while building large files (so they don't re-boot thinking the machine has locked up).

It is not valid to make any calls to the file being built except to query its properties, call NAME(file), or CLOSE(file) (which aborts the process and is not recommended). Issuing a CYCLE statement in response to any of the events generated (except EVENT:BuildDone) cancels the operation. During the PACK operation, file{PROP:Completed} returns the percentage completed of the re-build and you can use file{PROP:CurrentKey} to get a key reference then either key{PROP:Name} or key{PROP:Label} to return the name of the current key being built.

Errors Posted:

63  Exclusive Access Required

Events Generated:

EVENT:BuildFile PACK(file) is rebuilding the data portion of the file.
EVENT:BuildKey PACK(file) is rebuilding the keys in the file.
EVENT:BuildDone The PACK is complete.

Example:

OPEN(Trans,12h)    !Open the file in exclusive mode

PACK(Trans)        ! and pack it

See Also:

OPEN

SHARE

BUILD

PROP:ProgressEvents

PROP:Completed

pack_remove_deleted_records_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1