home *** CD-ROM | disk | FTP | other *** search
- program DemoB003;
- {------------------------------------------------------------------------------
- DBase File Lister
- Sample 3
- 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 listed 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, and
- proceeds to list selected fields from each record.
-
- The NumberGet, DateGet, and StringGet commands are shown in the
- example. This is intended to contrast them with the basic FieldGet
- command used to get the field image directly from disk.
-
- The ValueGet Procedure returns the actual numeric value in the field.
- This should be used on Number fields only as it returns a real value.
-
- The DateGet Function is used to retrieve a longint Julian Date from
- the date field. See GS_DATE.PAS for an explanation of Julian Dates.
-
- The StringGet Function returns the trimed string.
-
- GS_Date_View is used to display a 'viewable' date from the longint
- Julian Date value retrieved by DateGet.
-
- -------------------------------------------------------------------------------}
-
- uses
- CRT,
- DOS,
- GS_Date,
- GS_dBase,
- GS_DBFld,
- GS_FileH;
- var
- MyFile : GS_dBFld_Objt;
- rnum : real;
- dnum : longint;
- ftest : file;
- begin
- GS_Date_Century := true; {Gives full century on date display (YYYY)}
- {default is false for YY only.}
- 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}
- MyFile.GetRec(Top_Record); {Get the first record in the file}
- while not MyFile.File_EOF do {Repeat until end-of-file}
- begin
- rnum := MyFile.NumberGet('PAYMENT'); {use for math later}
- dnum := MyFile.DateGet('BIRTHDATE'); {use for conversion later}
-
- writeln(MyFile.StringGet('LASTNAME'),', ',
- MyFile.StringGet('FIRSTNAME'),' ',
- GS_Date_View(dnum),' [',
- MyFile.StringGet('PAYMENT'),']',
- rnum/12:8:2); {PAYMENT / 12}
- MyFile.GetRec(Next_Record); {Get the next sequential record}
- end;
- MyFile.Close;
- write('Press any Key to continue:');
- repeat until KeyPressed;
- end.
-