************************************************** *-- Class: cprogress *-- ParentClass: custom *-- BaseClass: custom *-- Time Stamp: 02/15/00 07:30:00 PM * DEFINE CLASS cprogress AS custom *-- mnRecords - number of records to process mnrecords = 0 *-- miRecord - iteration counter mirecord = 0 *-- mtStart - time process started mtstart = {^1999/01/01 00:00:00} *-- mnDisplayInterval - number of records before display updates mndisplayinterval = 1000 *-- mlIncludeDate - set to .t. if you want the estimated completion time to include the date mlincludedate = .F. Name = "cprogress" *-- Iterate - called for each record processed PROCEDURE update with this .miRecord = .miRecord + 1 if ( ( .miRecord % .mnDisplayInterval ) = 0 ) local lnPerRecord lnPerRecord = ( datetime() - .mtStart ) / .miRecord @$,17 say str( lnPerRecord, 9, 5 ) if ( .mlIncludeDate ) @$,52 say ttoc( datetime() + ( .mnRecords - .miRecord ) * lnPerRecord ) + ; " it is now: " + time() else @$,52 say ttoc( datetime() + ( .mnRecords - .miRecord ) * lnPerRecord, 2 ) + ; " it is now: " + time() endif endif endwith ENDPROC *-- FinalStatistics - provide final run statistics PROCEDURE finalstatistics local lnElasped, lcRetVal lnElasped = datetime() - this.mtStart lcRetVal = "Total time:" + ttoc( {^1999-01-01, 00:00:00} + lnElasped, 2 ) + ; " Seconds/per record" + str( lnElasped / this.miRecord, 9, 5 ) return lcRetVal ENDPROC PROCEDURE Init lparameter pnDisplayInterval with this .miRecord = 0 .mtStart = datetime() .mnRecords = reccount() if ( pcount() > 0 ) .mnDisplayInterval = pnDisplayInterval endif endwith ? && make sure we are on a blank line to start @$,1 say "Seconds/record:" @$,27 say "Estimated finish time:" ENDPROC ENDDEFINE * *-- EndDefine: cprogress **************************************************It's usage is like:
select TheTable loProgress = createobject( "cProgress" ) scan loProgress.Update() ... endscan ? loProgress.FinalStatistics()