home *** CD-ROM | disk | FTP | other *** search
- program DemoU004;
- {------------------------------------------------------------------------------
- DBase Index Manager
- Useless Examples
- Demo Program
-
- Copyright (c) Richard F. Griffin
-
- 22 February 1992
-
- 102 Molded Stone Pl
- Warner Robins, GA 31088
-
- -------------------------------------------------------------
- Unit to demonstrate multiple index processing.
-
- The DEMOU4.DBF file will be created by using the MakeTestData
- procedure in GS_GENF.PAS.
-
- The IndexTo routine will be used to index on LASTNAME and
- BIRTHDATE.
-
- The indexed file will be listed ascending.
-
- Additional Records will be added to test multiple index update.
-
- Finally, the file will be listed again in LASTNAME and BIRTHDATE
- index sequence. Note the use of SetIndexMaster to switch between
- which index is the master.
-
- -------------------------------------------------------------------------------}
- uses
- CRT,
- DOS,
- printer,
- GS_Strng,
- GS_Date,
- GS_dBFld,
- GS_dBase,
- GS_GenF;
- var
- MyFile : GS_dBFld_Objt;
- s : string;
- li : boolean;
- i : integer;
- c : char;
- jd : longint;
- ms : string[30];
- begin
- GS_Date_Century := true;
- ClrScr;
-
- writeln('Creating DemoU4.DBF');
- MakeTestData('DemoU4', 50, false);
- writeln('DemoU4.DBF Created');
-
- MyFile.Init('DemoU4');
- MyFile.Open;
- MyFile.IndexTo('DemoU4A','LASTNAME');
- MyFile.IndexTo('DemoU4B','BIRTHDATE');
- MyFile.Index('DemoU4A, DemoU4B');
-
- i := 0;
- MyFile.GetRec(Top_Record);
- while (not MyFile.File_EOF) do
- begin
- inc(i);
- if (i mod 23) = 0 then
- begin
- write('Press any key to continue.');
- c := ReadKey;
- writeln;
- end;
- writeln(MyFile.RecNumber:8,' ',MyFile.FieldGet('LASTNAME'),i:6);
- MyFile.GetRec(Next_Record);
- end;
-
- writeln('End of File, Now for More Records...');
- writeln('Press any key to continue.');
- c := ReadKey;
-
- writeln('Adding DemoU4.DBF Records');
- AddTestData(@MyFile, 50);
- writeln('DemoU4.DBF Records Added');
-
- {save index structures to ascii files}
-
- MyFile.dbfNdxTbl[1]^.KeyList('list1.txt');
- MyFile.dbfNdxTbl[2]^.KeyList('list2.txt');
-
- i := 0;
- MyFile.GetRec(Top_Record);
- while (not MyFile.File_EOF) do
- begin
- inc(i);
- if (i mod 23) = 0 then
- begin
- write('Press any key to continue.');
- c := ReadKey;
- writeln;
- end;
- writeln(MyFile.RecNumber:8,' ',MyFile.FieldGet('LASTNAME'),i:6);
- MyFile.GetRec(Next_Record);
- end;
-
- writeln('End of File, Now to check date sequence...');
- writeln('Press any key to continue.');
- c := ReadKey;
-
- MyFile.SetIndexMaster(2);
-
- i := 0;
- MyFile.GetRec(Top_Record);
- while (not MyFile.File_EOF) do
- begin
- inc(i);
- if (i mod 23) = 0 then
- begin
- write('Press any key to continue.');
- c := ReadKey;
- writeln;
- end;
- writeln(MyFile.RecNumber:8,' ',
- GS_Date_View(MyFile.DateGet('BIRTHDATE')),i:6);
- MyFile.GetRec(Next_Record);
- end;
-
- MyFile.Close;
- end.
-