home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TPDB21.ZIP / MULTKEYS.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-02-22  |  1.2 KB  |  40 lines

  1. {$A+,B+,D-,E-,F-,I-,L-,N-,O-,R-,S-,V-}
  2. {$M 65520,0,655360}
  3. Program MultKeys;
  4.  
  5. Uses Crt,TPDB;
  6.  
  7. {Demonstration of indexing on multiple keys.}
  8.  
  9. Var
  10.    J : LongInt;
  11.  
  12. begin
  13.      ClrScr;
  14.      Writeln('Indexing on multiple keys...');
  15.      DBOpenFile('multkeys.dbf');
  16.      MakeDBIndex('multkeys.ndx',20,Duplicates);
  17.      OpenDBIndex('multkeys.ndx',20,Duplicates);
  18.      For J := 1 to TotalRecs do {Number of records in a .DBF file
  19.                                  is always stored in the global var
  20.                                  TotalRecs.}
  21.      begin
  22.           GetDBRec(J);
  23.           AddDBKey(RTrim(FieldToStr(1))+RTrim(FieldToStr(2)));
  24.           {Key string is created by trimming blanks from field 1 and
  25.            field 2 and concatenating field 1 + field 2.}
  26.      end;
  27.      CloseDBIndex;
  28.      DBReset;
  29.      OpenDBIndex('multkeys.ndx',20,Duplicates);
  30.      For J := 1 to TotalRecs do
  31.      begin
  32.           NextDBKey(RTrim(FieldToStr(1))+RTrim(FieldToStr(2)));
  33.           {The first call to NextDBKey positions the index file
  34.            pointer to the first record in the index.}
  35.           Display;
  36.      end;
  37.      CloseDBFile;
  38.      CloseDBIndex;
  39.      Writeln('End of index file...');
  40. end.