Dec 102017
Perform a dBase PACK on a database from DOS. Also, a .BIN file to signficantly speed up PACKing from within dBase.
File PACKIT.ZIP from The Programmer’s Corner in
Category Dbase Source Code
Perform a dBase PACK on a database from DOS. Also, a .BIN file to signficantly speed up PACKing from within dBase.
File Name File Size Zip Size Zip Type
PACKIT.ASM 32539 7020 deflated
PACKIT.BIN 13524 839 deflated
PACKIT.DOC 7344 2931 deflated
PACKIT.EXE 4389 2775 deflated

Download File PACKIT.ZIP Here

Contents of the PACKIT.DOC file

Packit is a modified version of the program "Fastpack" written
by R. Russell Freeland and published in dBASE POWER: Building and Using
Programming Tools, by P. L. Olympia, R. Russell Freeland and Randy Wallin,
Ashton-Tate Corporation, 1988.

It substitutes for the dBASE PACK command, but operates much more
quickly than the dBASE III+ PACK command and usually more quickly than
the dBASE IV (Version 1.0 tested) PACK command. It can either pack a file
"in place" as dBASE does or create a new packed file while renaming the
original file with a .BAK extension. The "in place" pack is faster and needs
no free disk space, but risks data loss and permits no recovery from errors.

The .EXE and .BIN files posted are the slowest but most versatile
versions of the program. The .BIN file is intended to be run from within
dBASE, the .EXE file without.

The dBASE .BIN file:

The syntax for the .BIN (within dBASE) is:

LOAD Packit
CALL Packit WITH Mfile


LOAD Packit

In either case, Result will on completion hold a code indicating the
success or reason for failure of the pack. See "Errors" below. The
intermediate step of assigning the name of the file to a memory variable is
required if using the CALL ... WITH syntax or the result code will not be
accessible to dBASE.

The .EXE file:

The .EXE file provided may be run outside dBASE to pack a dBASE file.
It contains symbolic information needed to run it and debug it within the
CodeView debugger. The syntax, from the DOS prompt or following "CV" for
CodeView, is:


The .EXE returns one of the same codes as the .BIN, but as the DOS
ERRORLEVEL. Since the code for success is 1, the 0 return that often means
success to DOS is used instead for "no argument given on command line."
The .EXE file cannot itself be converted to a dBASE .BIN file, but exe2bin can
be used to convert it to a .COM file.


The .BIN and .EXE files permit two optional "switches". They should
follow the filename in the argument (dBASE or command line) passed on calling
the program. They are:

/T Terse - no writing to the screen of # of records copied.
/N Nobak - no backup file; pack will be "in place."

The switches may, but need not, be separated from the filename or each
other by one or more spaces. The slash must be immediately followed by the
character identifying the switch, although case is ignored.

Some of the assembly options (which see) eliminate the code related to
the switches, which is an appreciable fraction of the total.


If all goes well, the error code 1 will be returned, the file of which
the name was given as an argument will be packed, and if the /N switch was not
given the original file will exist in the same directory with a .BAK extension.
Any preexisting file of the same name and .BAK extension will be overwritten.
The header of the packed file will reflect the date of packing and number of
records remaining.

If the file to be packed does not exist in the current or specified
directory, if the header cannot be read for some reason, or if the rw_buff
buffer is too small to hold an entire record of the file, the error code 2
will be returned. It is necessary to specify the extension of the file to
be packed only if it is not .DBF.

If the new file to hold the packed data cannot be created or if an
error occurs in writing to it, the error code 3 will be returned.

If an error occurs in reading the original file, code 5 will be
returned. The absence of an EOF mark at the end of the original file is not
treated as an error, but one will be appended to the packed file.

Conditions and limitations:

The buffer for file reads and writes must be large enough to hold the
entire .DBF header, which can be as long as 8K bytes + 1. It must also be
large enough to hold at least one entire data record of the file being packed.
This is ordinarily a problem only with a dBASE .BIN file (or other version
assembled with DOSexe false--see Assembly Options) since such a file, including
the buffer, must fit within the dBASE limit (32,000 bytes for dBASE III+ and
Version 1.0 of dBASE IV.)

The maximum improvement in performance over the native dBASE PACK
command will occur when records of the file are small. Large records require
more disk accesses per record and the process becomes bound by disk I/O speed
using any packing method. The "/N" switch, see below, will often improve
execution speed as the overhead of adding clusters to the new file if /N is
not used can be significant.

Assembly options:

The assembly options described permit users with the MicroSoft
Macro Assembler, or compatible assemblers, to create .BIN or .EXE files with
features slightly different from the files supplied. If you do not have
an assembler, these options are of no use to you.

If creating an assembler .LST file, you may wish to suppress the
conditionals that are false to avoid cluttering the listing.

The "debugging" option creates a "trap" when and if the program is
run. Its primary use is when testing a .BIN routine within dBASE. To do
so, set "debugging" true before assembly, create the routine with MASM,
LINK and EXE2BIN, and give the command "DEBUG dBASE". When the routine is
called, the trap will return control to DEBUG which may then be used to debug
the program (or dBASE).

The "for386" option tells the assembler to create a program that can
be run only on a computer with an 80386 (or, presumably, later) processor.
A few instructions available only on an 80386 improve speed marginally.

The "terse" selection disables the "/T" switch, see above. The program
may be configured either to run in terse mode (no report of records copied) or
in standard mode, but the code relating to the switch, and if terse mode is
selected the code required to issue the report, will not be assembled.

The "nobak" selection disables the "/N" switch, see above. As with the
"/T" switch, the program may be configured to run as if the switch were on or
off. The fastest and shortest versions of the program are those assembled with
the "nobak", and secondarily the "allterse", options.

Although the .BIN and .EXE file approximates 14,000 bytes due to
inclusion of the buffer, a .COM file to do the same job will require far
fewer than 1,000 bytes.


This code may be used and modified freely and incorporated in program
systems sold to others. However, it may not be sold as or as part of a free-
standing "utility" program or package without permission of Ashton-Tate Corp.

Please report any bugs to Jay Parsons, CIS # 70160,340.

 December 10, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>