home *** CD-ROM | disk | FTP | other *** search
- program DemoU005;
- {-----------------------------------------------------------------------------
- DBase Status Checker
- Useless Examples
- Demo Program
-
- Copyright (c) Richard F. Griffin
-
- 10 February 1992
-
- 102 Molded Stone Pl
- Warner Robins, GA 31088
-
- -------------------------------------------------------------
-
- Demonstrates use of status checking for long duration operations
-
- Several functions in GS_dBase can take some time to complete
- (e.g., IndexTo and Pack). For this reason, a virtual method
- StatusUpdate has been added to the GS_dBFld unit to allow the user
- to gain access and track progress. The StatusUpdate method in
- GS_dBFld does nothing--it is there as the default if the user chooses
- not to take advantage of the capability by adding his or her own
- virtual StatusUpdate method.
-
- This sample program demonstrates the how this procedure may be
- installed in a user's program. Note a StatusUpdate method is
- implemented through a child object of GS_dBFld. All calls to
- StatusUpdate anywhere in the object's heirarchy will come through
- this 'hook'.
-
- Constants passed as arguments are contained in the GS_dBFld unit,
- they are:
-
- StatusStart = -1; Passed to indicate a routine will be passing
- status update information.
-
- StatusStop = 0; Signals termination by a routine, cancelling
- status update processing.
-
- StatusIndexTo = 1; Token for identifying IndexTo as the routine
- passing status information.
-
- StatusPack = 2; Token for identifying Paack as the routine
- passing status information.
-
- The structure of a StatusUpdate call is:
-
- StatusUpdate(statword1, statword2, statword3);
-
- where the statword* values are type longint and will vary depending on
- the contents of statword1. For example:
-
- if statword1 = StatusStart
- then: statword2 = the calling routine token (StatusIndexTo or
- StatusPack.
- statword3 = the number of records to be processed.
-
- if statword1 = StatusStop
- then: statword2 = 0
- statword3 = 0
-
- if statword1 = StatusIndexTo or StatusPack
- then: statword2 = current record number being processed
- statword3 = 0
-
- ------------------------------------------------------------------------------}
-
- uses
- CRT,
- DOS,
- GS_dBFld,
- GS_dBase,
- GS_GenF;
-
- type
- Talk_Obj = object(GS_dBFld_Objt)
- procedure StatusUpdate(stat1,stat2,stat3 : longint); virtual;
- end;
-
- var
- MyFile : Talk_Obj;
-
- procedure Talk_Obj.StatusUpdate(stat1,stat2,stat3 : longint);
- begin
- case stat1 of
- StatusStart : begin
- GotoXY(2,1);
- case stat2 of
- StatusPack : write('[ Pack Progress ]');
- StatusIndexTo : write('[ Index Progress ]');
- end;
- GotoXY(26,2);
- write('Total Records to Process = ',stat3);
- end;
- StatusStop : begin
- GoToXY(2,3);
- Writeln('Finished');
- end;
- StatusPack,
- StatusIndexTo : begin
- GoToXy(2,2);
- write('Record Number ',stat2,' ');
- end;
- end;
- end;
-
- begin
- ClrScr;
-
- writeln('Creating DemoU5.DBF');
- MakeTestData('DemoU5', 100, false);
- writeln('DemoU5.DBF Created');
-
- ClrScr;
- MyFile.Init('DEMOU5');
- MyFile.Open;
- MyFile.IndexTo('DEMOU5','LASTNAME');
- MyFile.Index('DEMOU5');
- MyFile.GetRec(Top_Record);
- while not MyFile.File_EOF do
- begin
- writeln(MyFile.FieldGet('LASTNAME'),' ',
- MyFile.FieldGet('FIRSTNAME'));
- MyFile.GetRec(Next_Record);
- end;
- MyFile.Close;
- end.
-