home *** CD-ROM | disk | FTP | other *** search
- program DemoB005;
- {------------------------------------------------------------------------------
- DBase File Lister
- Sample 5
- Demo Program
-
- Copyright (c) Richard F. Griffin
-
- 10 February 1992
-
- 102 Molded Stone Pl
- Warner Robins, GA 31088
-
- -------------------------------------------------------------
- This program demonstrates how dBase files may be appended using
- Griffin Solutions units.
-
- If the DEMOB1.DBF file does not exist, the program will display a
- a message that the file was not found and to run DEMOB001 to make
- the file.
-
- The program initializes a dBase file object, opens the file, appends
- a record, and proceeds to list selected fields from each record.
-
- -------------------------------------------------------------------------------}
-
- uses
- CRT,
- DOS,
- GS_Date,
- GS_dBase,
- GS_DBFld,
- GS_FileH,
- GS_Strng;
-
- const
- s1 = 'The Last';
-
- var
- MyFile : GS_dBFld_Objt;
- ftest : file;
- s2 : string[8];
- begin
- ClrScr;
- if not GS_FileExists(ftest, 'DEMOB1.DBF') then
- begin
- writeln('File DEMOB1.DBF not found. Run DEMOB001 to create.');
- halt;
- end;
- {The 'Real' example starts here}
-
- MyFile.Init('DEMOB1'); {Initialize object using the dBase III}
- {file DEMOB1. DBF Extension assumed}
- MyFile.Open; {Open the object's file}
-
- {Insert a record}
-
- MyFile.Blank;
- MyFile.StringPut('LASTNAME',s1);
- s2 := Unique_Field;
- MyFile.StringPut('FIRSTNAME',s2);
- MyFile.DatePut('BIRTHDATE',GS_Date_Curr);
- MyFile.Append;
-
- {Now read the records}
-
- MyFile.GetRec(Top_Record); {Get the first record in the file}
- while not MyFile.File_EOF do {Repeat until end-of-file}
- begin
- writeln(MyFile.FieldGet('LASTNAME'),' ',
- MyFile.FieldGet('FIRSTNAME'),' ',
- MyFile.FieldGet('BIRTHDATE'));
- MyFile.GetRec(Next_Record); {Get the next sequential record}
- end;
- MyFile.Close;
- write('Press any Key to continue:');
- repeat until KeyPressed;
- end.
-