home *** CD-ROM | disk | FTP | other *** search
- {$A+,B+,D-,E-,F-,I-,L-,N-,O-,R-,S-,V-}
- {$M 65520,0,655360}
- Program MultKeys;
-
- Uses Crt,TPDB;
-
- {Demonstration of indexing on multiple keys.}
-
- Var
- J : LongInt;
-
- begin
- ClrScr;
- Writeln('Indexing on multiple keys...');
- DBOpenFile('multkeys.dbf');
- MakeDBIndex('multkeys.ndx',20,Duplicates);
- OpenDBIndex('multkeys.ndx',20,Duplicates);
- For J := 1 to TotalRecs do {Number of records in a .DBF file
- is always stored in the global var
- TotalRecs.}
- begin
- GetDBRec(J);
- AddDBKey(RTrim(FieldToStr(1))+RTrim(FieldToStr(2)));
- {Key string is created by trimming blanks from field 1 and
- field 2 and concatenating field 1 + field 2.}
- end;
- CloseDBIndex;
- DBReset;
- OpenDBIndex('multkeys.ndx',20,Duplicates);
- For J := 1 to TotalRecs do
- begin
- NextDBKey(RTrim(FieldToStr(1))+RTrim(FieldToStr(2)));
- {The first call to NextDBKey positions the index file
- pointer to the first record in the index.}
- Display;
- end;
- CloseDBFile;
- CloseDBIndex;
- Writeln('End of index file...');
- end.