Professional Documents
Culture Documents
DBFCDX Driver - Viva Clipper
DBFCDX Driver - Viva Clipper
DBFCDX Driver - Viva Clipper
Viva Clipper !
Chapter 4
DBFCDX is the FoxPro 2 compatible RDD for Clipper. As such, it connects to the low-
level database management subsystem in the Clipper architecture. When you use the
DBFCDX RDD, you add a number of new features including:
. Compact indexes
. Compound indexes
https://vivaclipper.wordpress.com/2013/07/26/c5dg-4-dbfcdx-driver/ 1/8
9/2/2018 C5DG-4 DBFCDX Driver | Viva Clipper !
. Conditional indexes
In This Chapter
This chapter explains how to install DBFCDX and how to use it in your applications.
The following major topics are discussed:
The DBFCDX driver lets you create and maintain (.cdx) and (.idx) files with features
different from those supplied with the original DBFNTX driver and is compatible with
files created under FoxPro 2. The new features are supplied in the form of several
syntactical additions to the INDEX and REINDEX commands. Specifically, you can:
Compact Indexes
Like FoxPro 2, The DBFCDX driver creates compact indexes. This means that the key
data is stored in a compressed format, resulting in a substantial size reduction in the
index file. Compact indexes store only the actual data for the index keys. Trailing
blanks and duplicate bytes between keys are stored in one or two bytes. This allows
considerable space savings in indexes with much empty space and similar keys. Since
https://vivaclipper.wordpress.com/2013/07/26/c5dg-4-dbfcdx-driver/ 2/8
9/2/2018 C5DG-4 DBFCDX Driver | Viva Clipper !
Compound Indexes
A compound index is an index file that contains multiple indexes (called tags).
Compound indexes (.cdx)’s make several indexes available to your application while
only using one file handle. Therefore, you can overcome the Clipper index file limit of
15. A compound index can have as many as 99 tags, but the practical limit is around 50.
Once you open a compound index, all the tags in the file are automatically updated as
the records are changed.
Once you open a compound index, all the tags contained in the file are automatically
updated as the records are changed. A tag in a compound index is essentially identical
to an individual index (.idx) and supports all the same features. The first tag (in order
of creation) in the compound index is, by default, the controlling index.
Conditional Indexes
The DBFCDX driver can create indexes with a built-in FOR clause. These are
conditional indexes in which the condition can be any expression, including a user-
defined function. As the database is updated, only records that match the index
condition are added to the index, and records that satisfied the condition before, but
don’t any longer, are automatically removed.
Expanded control over conditional indexing is supported with the revised INDEX and
REINDEX command options as in the new DBFNTX driver.
To link the DBFCDX database driver into an application program, you must specify
DBFCDX.LIB to the linker in addition to your application object files (.OBJ).
https://vivaclipper.wordpress.com/2013/07/26/c5dg-4-dbfcdx-driver/ 3/8
9/2/2018 C5DG-4 DBFCDX Driver | Viva Clipper !
Note: These link commands all assume the LIB, OBJ, and PLL environment variables
are set to the standard locations. They also assume that the Clipper programs were
compiled without the /R option.
1. Place REQUEST DBFCDX at the beginning of your application or at the top of the
first program file (.prg) that opens a database file using the DBFCDX driver.
2. Specify the VIA “DBFCDX” clause if you open the database file with the USE
command.
-OR-
3. Specify “DBFCDX” for the <cDriver> argument if you open the database file with the
DBUSEAREA() function.
-OR-
Except in the case of REQUEST, the RDD name must be a literal character string or a
variable. In all cases it is important that the driver name be spelled correctly.
REQUEST DBFCDX
.
.
.
USE Customers INDEX Name, Address NEW VIA "DBFCDX"
-OR-
https://vivaclipper.wordpress.com/2013/07/26/c5dg-4-dbfcdx-driver/ 4/8
9/2/2018 C5DG-4 DBFCDX Driver | Viva Clipper !
REQUEST DBFCDX
RDDSETDEFAULT( "DBFCDX" ) .
.
.
USE Customers INDEX Name, Address NEW
You can use both (.idx) and (.ntx) files concurrently in a Clipper program like this:
Note, however, that you cannot use (.idx) and (.ntx) files in the same work area. For
example, the following does not work:
You may use (.cdx) with (.idx) files concurrently (even in the same work area);
however, in most cases it is easier to use a single (.cdx) index for each database file or
separate (.idx) files. When using both types of index at the same time, a empting to
select an Order based on its Order Number can be confusing and will become difficult
to maintain.
When an existing tag in a compound index (.cdx) is rebuilt using INDEX ON…TAG…
the space used by the original tag is not automatically reclaimed. Instead, the new tag
is added to the end of the file, increasing file size.
You can use the REINDEX command to “pack” the index file. REINDEX rebuilds each
tag, eliminating any unused space in the file.
If you rebuild your indexes on a regular basis, you should either delete your (.cdx) files
before rebuilding the tags or use the REINDEX command to rebuild them instead.
https://vivaclipper.wordpress.com/2013/07/26/c5dg-4-dbfcdx-driver/ 5/8
9/2/2018 C5DG-4 DBFCDX Driver | Viva Clipper !
The DBFCDX driver uses FoxPro compatible memo (.fpt) files to store data for memo
fields. These memo files have a default block size of 64 bytes rather than the 512 byte
default for (.dbt) files.
DBFCDX memo files can store any type of data. While (.dbt) files use an end of file
marker (ASCII 26) at the end of a memo entry, (.fpt) files store the length of the entry.
This not only eliminates the problems normally encountered with storing binary data
in a memo field but also speeds up memo field access since the data need not be
scanned to determine the length.
1. Make sure index extensions aren’t hard-coded in your application. The default
extension for DBFCDX indexes is (.idx), not (.ntx). You can still use (.ntx) as the
extension as long as you specify the extension when you create your indexes. The best
way to determine index extensions in an application is to call ORDBAGEXT().
For example, if you currently use the following code to determine the existence of an
index file:
IF .NOT. FILE("index.ntx")
INDEX ON field TO index
ENDIF
IF .NOT. FILE("index"+ORDBAGEXT())
INDEX ON field TO index
ENDIF
2. If your application uses memo fields, you should convert your (.dbt) files to (.fpt)
files.
There are some good reasons for using (.fpt) files. Most important is the smaller block
size (64 bytes). Clipper’s (.dbt) files use a fixed block size of 512 bytes which means that
every time you store even 1 byte in a memo field Clipper uses 512 bytes to store it. If
the data in a memo field grows to 513 bytes, then two blocks are required.
https://vivaclipper.wordpress.com/2013/07/26/c5dg-4-dbfcdx-driver/ 6/8
9/2/2018 C5DG-4 DBFCDX Driver | Viva Clipper !
When creating (.fpt) files, the block size is set at 64 bytes to optimize it for your needs.
A simple conversion from (.dbt) files to (.fpt) files will generally shrink your memo
files by approximately 30%.
Summary
In this chapter, you were given an overview of the features and benefits of the
DBFCDX RDD. You also learned how to link this driver and how to use it in your
applications.
Advertisements
Report this ad
$3.2
Report this ad
This entry was posted in Uncategorized and tagged .cdx, .dbt, .fpt. memo, .idx, .ntx,
.prg, block, Compact indexes, Compound indexes, Conditional indexes, DBFCDX,
https://vivaclipper.wordpress.com/2013/07/26/c5dg-4-dbfcdx-driver/ 7/8
9/2/2018 C5DG-4 DBFCDX Driver | Viva Clipper !
DBFNTX, DBUSEAREA(), FOR, FoxPro, Index, INDEX ON..., memo file, New(), NEXT,
ORDBAGEXT(), PACK, positional syntax, RDDSETDEFAULT(), REINDEX, REQUEST,
REST, RTLINK, Tag, USE, VIA, WHILE. Bookmark the permalink.
https://vivaclipper.wordpress.com/2013/07/26/c5dg-4-dbfcdx-driver/ 8/8