home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / w3_prog / db3tpwun.arj / DB3TPWUN.DOC < prev   
Encoding:
Text File  |  1991-09-12  |  3.6 KB  |  114 lines

  1. TPASCAL for Windows DBase 2 and 3 read / write unit
  2. ===================================================
  3.  
  4. Based on Routines published by James Troutman in 1986
  5. Rewritten as Turbo PASCAL for Windows unit by Nigel Salt 1991
  6.  
  7. MANIFEST
  8. ========
  9. db3tpwun.doc      this document
  10. db3.tpu           Turbo PASCAL unit for DB3 functions
  11. db3demun.pas      Simple demo of the DB3 unit
  12. db3demun.exe
  13.  
  14. UNIT DECLARATIONS
  15. =================
  16.  
  17. CONST
  18.   MAX_HEADER           = 4129; { maximum length of dBASE III header }
  19.   MAX_BYTES_IN_RECORD  = 4000; { dBASE III record limit }
  20.   MAX_FIELDS_IN_RECORD = 128;  { dBASE III field limit   }
  21.   BYTES_IN_MEMO_RECORD = 512;  { dBASE III memo field record size }
  22.  
  23.   { Valid field types }
  24.   ValidTypes : SET OF Char = ['C', 'N', 'L', 'M', 'D'];
  25.  
  26.   { Special Error codes for .DBF files }
  27.   NOT_DB_FILE    = $80; { first byte was not a $3 or $83 or a $2 (dBASE II)}
  28.   INVALID_FIELD  = $81; { invalid field type was found }
  29.   REC_TOO_HIGH   = $82; { tried to read a record beyond the correct range }
  30.   PARTIAL_READ   = $83; { only a partial record was read }
  31.  
  32. TYPE
  33.   _Str64            = STRING[64];
  34.   _HeaderType       = ARRAY[0..MAX_HEADER] OF Byte;
  35.   _FieldDescType    = ARRAY[0..31] OF Byte;
  36.   _dRec             = ^_DataRecord;
  37.   _DataRecord       = ARRAY[0..MAX_BYTES_IN_RECORD] OF Byte;
  38.   _HeaderPrologType = ARRAY[0..31] OF Byte;
  39.   _dbfFile          = FILE;
  40.  
  41.   _FieldRecord      = RECORD
  42.     Name : String[10];
  43.     Typ  : Char;
  44.     Len  : Byte;
  45.     Dec  : Byte;
  46.     Off  : Integer;
  47.     END;
  48.  
  49.   _FieldArray     = ARRAY[1..MAX_FIELDS_IN_RECORD] OF _FieldRecord;
  50.   _dFields        = ^_FieldArray;
  51.   _MemoRecord     = ARRAY[1..BYTES_IN_MEMO_RECORD] OF Byte;
  52.   _MemoFile       = FILE OF _MemoRecord;
  53.   _StatusType     = (NotOpen, NotUpdated, Updated);
  54.  
  55.   dbfRecord       = RECORD
  56.    FileName     : String[64];
  57.    dFile        : _dbfFile;
  58.    HeadProlog   : _HeaderPrologType;
  59.    dStatus      : _StatusType;
  60.    WithMemo     : Boolean;
  61.    DateOfUpdate : String[8];
  62.    NumRecs      : Longint;
  63.    HeadLen      : Integer;
  64.    RecLen       : Integer;
  65.    NumFields    : Integer;
  66.    Fields       : _dFields;
  67.    CurRecord    : _dRec;
  68.    END;
  69.  
  70. VAR
  71.    { See special error codes in INTERFACE CONST }
  72.    dbfError: Integer; {Global error code}
  73.    dbfOK: Boolean;
  74.  
  75. PROCEDURE WriteDBError;
  76.           {Writes text version of dbferror}
  77. PROCEDURE WriteDBFormat(D: dbfRecord);
  78.           {Writes file and filed information}
  79. PROCEDURE WriteDBRec(D: dbfRecord; RecNum: Longint);
  80.           {Writes one record}
  81. PROCEDURE GetDbfRecord(VAR D : dbfRecord; RecNum : Longint);
  82.           {Gets one record to buffer}
  83. PROCEDURE PutDbfRecord(VAR D : dbfRecord; RecNum : Longint);
  84.           {Puts one record in file}
  85. PROCEDURE AppendDbf(VAR D : dbfRecord);
  86.           {Appends one record to end of file}
  87. PROCEDURE CloseDbf(VAR D : dbfRecord);
  88.           {Closes a database}
  89. PROCEDURE OpenDbf(VAR D : dbfRecord);
  90.           {Opens a databse}
  91. PROCEDURE CreateDbf(VAR D: dbfRecord; filename: _Str64; numfields: Integer;
  92.                     fldarrayptr : _dFields);
  93.     {
  94.     Call CreateDbf with the full pathname of the file that you want
  95.     to create (filename), the number of fields in a record (numfields),
  96.     and a pointer to an array of _FieldRecord (fldarrayptr).  The procedure
  97.     will initialize all the data structures in the dbfRecord (D).
  98.     }
  99. ============================================================================
  100.  
  101. As always all comments and contributions gratefuly received
  102.  
  103. Nigel Salt
  104. 25 Lower Station Rd
  105. Crayford
  106. Kent
  107. DA1 3PY
  108.  
  109. Phone 0322 553260
  110.  
  111. CIX ID nao@cix.complink.co.uk
  112. RAX Nigel Salt on node 2:440/52.49 
  113.  
  114.