*----------------------- * THERM.PRG * * Emulates a thermometer * In 1.02 can be used in a REPORT FORM, SCAN etc. * In 2.0 will be used in INDEX as well * * Parameters: * lcMessage - Message to print on top line of the thermometer * Not needed. Ignored if not sent * * Sample Calls: * 1. Place therm() in a report and call it with * REPORT FORM TEST TO FILE TEMP.REP OFF * 2. =Therm("This is a message") * * NOTE: * If lcScope exists, it is used to automatically adjust for a * scoped command, such as FOR/WHILE etc. * * Thanks to Lisa Slater and Chip Doolittle for CIS thread *----------------------- FUNCTION therm PARAMETERS lcMessage IF TYPE("lnPercDone") = "U" PUBLIC lnRecsDone, lnRecsToDo, lnWinLngth, lnStartRec, lnPercDone, lnDonFirst lnStartRec = RECNO() STORE .F. TO lnDonFirst DEFINE WINDOW wTherm FROM 11,4 TO 16,76 SHADOWS DOUBLE; TITLE 'Processing Records' GOTO lnStartRec IF TYPE("lcScope") = "U" lcScope = "ALL" ENDIF (TYPE("lcScope") = "U" && Didn't add a scope) COUNT TO lnRecsToDo &lcScope GOTO lnStartRec STORE 0 TO lnRecsDone, lnPercDone ACTIVATE WINDOW wTherm lnWinLngth = WCOLS()-4 lnPercent = INT(WCOLS()/5) @ 1,1 SAY '0%' @ 1,lnPercent-1 SAY '20%' @ 1,(lnPercent-1)*2 SAY '40%' @ 1,(lnPercent-1)*3 SAY '60%' @ 1,(lnPercent-1)*4 SAY '80%' @ 1,(lnPercent-1)*5 SAY '100%' ENDIF (TYPE("lnPercDone") = "U") IF PARAMETERS() = 1 @ 0,0 SAY PADC(lcMessage,WCOLS()," ") ENDIF (PARA() = 1) lnTempPerc = lnRecsDone / lnRecsToDo IF (INT(lnPercDone*lnWinLngth) <> INT(lnTempPerc*lnWinLngth)) .OR. ; RECNO() = lnStartRec @ 2,1 SAY REPLICATE(CHR(177),INT(lnTempPerc*lnWinLngth)) lnPercDone = lnTempPerc ENDIF ((INT(lnPercDone*lnWinLngth) <> INT(lnTempPerc*lnWinLngth)) .OR. ;) lnRecsDone = lnRecsDone + 1 IF lnRecsDone = lnRecsToDo RELEASE WINDOW wTherm RELEASE lnPercDone, lnRecsDone, lnRecsToDo, lnWinLngth, lnStartRec ENDIF (lnRecsDone = lnRecsToDo) RETURN ""