Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Code Base 4


April 1990/Code Base 4


The author is a consulting dBase and Clipper programmer. He holds a bachelor's degree in computer science from Central New England College of Technology in Worcester, Mass. He can be contacted at 253 Main St., Cherry Valley, MA 01611 (508) 892-3351.

Code Base 4 from Sequiter Software, Inc., is a set of C routines which allow you to access dBase III+ and IV files and perform screen I/O similar to dBaseIII+. Code Base 4 includes support for dBase .NDX index files, Clipper .NTX files, memo fields, and networked applications. The new dBaseIV .MDX (multiple index) files are not yet supported. Code Base 4 also adds some new levels of functionality with special routines for windows, menus, and memory handling.

Code Base 4 supports dBase/Clipper functionality with 12 categories of routines:

  • conversion routines
  • database routines
  • expression evaluation
  • field routines
  • get routines
  • memory handling routines
  • index file routines
  • memo routines
  • menuing routines
  • utility routines
  • windowing routines
  • extended routines
The conversion routines convert data from one format to another. For example, c4dt_dbf() converts Julian dates from the internal double representation to a string formatted CCYYMMDD (century, year, month and day).

The database routines are the main meat of the Code Base 4 package. They allow C programmers to access and store information in the well-established dBase .DBF file format and include C function equivalents of many dBase commands. Due to the more stringent nature of compiled C programming as opposed to the dBase interpretive environment, some differences exist. Table 1 compares dBase commands to their Code Base 4 function counterparts.

Expression And Indexes

With the dBase LINK_DEST 125 command, one may use any valid dBase expression to interactively build an index. For example, to create an index for an accounts receivable file based on invoices sorted by invoice date, you could use the following command:

INDEX ON STR(YEAR(invc_date))+;  STR(MONTH(invc_date))+STR(DAY(invc_date)); TO INVOICE
The STR(YEAR(invc_date.... portion is an "index expression". dBase evaluates this expression from left to right at runtime, and builds an .NDX file based on the expression. Code Base 4 uses an internal expression parser similar to dBase's. Several of the expression functions are available to advanced programmers who might wish to build an SQL-like front end to their application.

The field routines access individual fields and information pertaining to the fields (e.g., their name, length, and data type).

The get routines form the basis for data entry. The get routines arrange field data entry blocks and control field-to-field navigation within that block. As with dBase, you can control the get field in various ways, through pictures and validation clauses. Unlike dBase, Code Base 4 also allows you to access the individual attributes of each get field, allowing each Code Base 4 field to have its own color, brightness, or other attribute setting.

Programmers with strong memory management background can use the Code Base 4 memory handling routines to optimize their applications memory usage. Routines are included to allocate, reallocate, and free memory from the internal Code Base 4 structures.

Index files are used to access data in sorted order. With Code Base 4, either dBase .NDX files or Clipper .NTX files can be used. Like dBase and Clipper, Code Base 4 automatically updates all open index files when a record is written. However, with Code Base 4 you can use lower-level routines to access and update the index files directly.

The memo routines access dBase variable length memo fields (pointers to a separate text file containing free format text).

Unfortunately, Code Base 4 doesn't provide an editor for memo fields. A small Wordstar-compatible editor window function should have been included in the package, with definable screen coordinates. Nantucket's Clipper provides a MEMOEDIT() function which takes screen coordinates as its parameters, and allows you to edit memo fields in a word-wrapping window.

The menuing routines include pulldown, popup, vertical, horizontal, and Lotus 1-2-3 style menus.

The utility routines provide some low-level functions for parsing and validating file names, sorting arrays, and locking and unlocking regions of a shared file.

The windowing routines display and manipulate regions of the I/O screen. The windowing routines form the basis for the menuing routines.

The extended routines support some of dBaseIII and dBaseIV's extended functions, including record filtering (a subset view of a file based on some selection criteria), dBase relations (conditions which synchronize the movement of record pointers in separate files), an edit function (interactively change records), a record listing function, and an insertion function (adds blank records at any point).

Code Base 4 comes with complete source code and conditional compilation switches for Clipper .NTX compatibility, no screen management, OS/2 support, Turbo C compatibility and Microsoft Windows support. A batch file is supplied for performing customized compilations of the library.

dBase programs ported to Code Base 4 should be faster than the interpreted dBase original and smaller than a version compiled by Clipper. The Clipper (t) compiler from Nantucket Software speeds up program execution greatly, but due to library overhead, Clipper applications have a minimum size of 150K. Complete applications are typically about 300-350K. This makes it difficult to run a Clipper program with many TSRs loaded or in a multitasking environment such as DoubleDos. With Code Base 4, the linker only links in exactly what it needs from the library, so the application is much smaller.

Code Base 4 assumes the user has a lot of C and dBase experience and a good command of C pointers, memory allocation, and structures. Beginning C programmers may quickly find themselves lost. The package makes heavy use of linked lists to model database, field, window, and menu structures. Code Base 4 is primarily a tool for the programmer who has mastered C and dBase and wants to transcend the limits of dBase and Compiled dBase (Clipper, Quicksilver).

The wire-bound, 200-page Code Base 4 manual, while comprehensive, has no tutorial or examples section. Each chapter is broken down into a functional area of the Code Base 4 library, and each library function is documented for that section. Some function descriptions have small source code examples; others do not. Several sample programs are supplied on diskette. The samples are well written, and illustrate examples of how to build menus, windows, and database applications. I liked the manual's organization but often found the function descriptions a little thin. A front-end tutorial section with plenty of examples would help this manual greatly.

Technical support is available by phone.

Overall, Code Base 4 does the job for which it is intended: it brings a dBase-like programming environment to C, and allows you to share data between dBase and C programs. It does have some limitations. Using an external editor to access dBase memo fields is a little awkward.

I have worked with several other dBase C libraries. APEX ADL from Apex Software offers similar support for dBase file and index creation and access, but doesn't include any menuing, windowing, or get functions.

I would recommend Codeview4 to any programming shop that needs to transcend the limits of dBaseIII+ and Clipper. Code Base 4 can address speed, memory requirements, or specialized dBase compatible applications (such as a memory resident TSR). For straightforward applications development, dBase and Clipper are still pretty powerful programming environments.

The MS-DOS version is listed at $295 and the UNIX version at $495. For more information contact Sequiter Software Inc., P.O. Box 5659, Station L, Edmonton, Alberta T6C 4G1 (403) 439 8171; FAX (403) 433-7460.

Listing 1


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.