CodeBase for Delphi Example and Function List

CodeBase API

The CodeBase API is simple to learn and use. If you have an xBASE programming background, you'll appreciate the familiarity of the CodeBase API, which uses an xBASE-like naming convention. Even if you don't, you'll appreciate the API's straightforward naming convention. Here's a small example that shows you how easy it is to use CodeBase from Delphi.

CodeBase - Delphi Example

{ List the MAILING.DBF data file ordered alphabetically by last name. }


  program Mailing;

  uses CodeBase, Crt;

  var
     code     : CODE4;
     dataFile : DATA4;
     lastName : TAG4;
     field    : FIELD4;
     rc, j    : Integer;

  begin
     code := code4init;                        {Initialize CodeBase}
     dataFile := d4open(code, 'MAILING');      {Open MAILING.DBF}
     lastName := d4tag(dataFile, 'LASTNAME');
     d4tagSelect(dataFile, lastName);          {Select the last name tag}
     d4top(dataFile);                          {Go to top of data file}

     while d4eof(dataFile) = 0 do              {While not end of file do...}
     begin
        writeln;
        write(d4recno(dataFile):4);            {Display the record number}

        for j := 1 to d4numFields(dataFile) do {For each field in data file}
        begin
           field := d4fieldJ(dataFile, j);
           write('  ', f4str(field));          {Display contents of field}
        end;

        d4skip(dataFile, 1);                   {Move to next logical record}
     end;

     d4close(dataFile);                        {Close data file}
  end.

CodeBase 6 Function List:

Here are just a few of the fully documented CodeBase functions:

Data File Functions

d4append d4eof d4lockFile d4reccount d4top
d4blank d4field d4lockGroup d4recno d4unlock
d4bottom d4flush d4numFields d4record d4write
d4close d4go d4open d4reindex d4zap
d4create d4index d4pack d4seek  
d4data d4lock d4position d4skip  
d4delete d4lockAppend d4recall d4tagSelect  

Field Functions

f4assign f4assignLong f4char f4len f4ptr
f4assignChar f4assignN f4decimals f4long f4str
f4assignDouble f4assignPtr f4double f4name f4true
f4assignInt f4blank f4int f4ncpy f4type

Index File Functions

i4close i4create i4open i4reindex i4tagAdd

Relation Functions

relate4bottom relate4master relate4querySet relate4skip relate4top

Logging and Transaction Functions

code4connect code4logFileName code4logOpenOff code4tranRollback
code4logCreate code4logOpen code4tranCommit code4tranStart


webmaster@codebase.com