How to Create a General-Purpose Thermometer Bar in FoxProLast reviewed: June 1, 1996Article ID: Q93587 |
The information in this article applies to:
The code samples below demonstrate how to generate general-purpose user- defined functions (UDFs) that graphically reflect the progress of three types of operations: sequential, report, and indexing.
Sample Code for FoxPro for MS-DOS
SET TALK OFF SET CURSOR OFF USE C:\<foxpro directory>\tutorial\customer =display_border() * The next three commands are examples of using the thermometer bar * with the DISPLAY_BAR and DISPLAY_BORDER commands. * 1. Sequential operations. * The DISPLAY_BAR function displays a bar graph to represent the * progress of a sequential operation. PRIVATE rec_number rec_number = 1 SCAN && Perform database operation =display_bar() = .T. rec_number = rec_number + 1 ENDSCAN * 2. Report operations. * The DISPLAY_BAR function displays a bar graph to represent the * progress of a report being printed. In the Report Writer, when an * index is active, create a memory variable called REC_NUMBER. * From the Report menu, choose Variables. Then choose Add. Choose * the Count option button. Then create a variable name of * REC_NUMBER and store the value 0. When no index is active, * replace the memory variable REC_NUMBER in the DISPLAY_BAR * function with RECNO(). Then issue the following command: REPORT FORM cust NOCONSOLE TO PRINTER FOR display_bar()=.T. * 3. Indexing operations. * The DISPLAY_BAR function displays a bar graph to represent the * progress of an index operation using a .CDX index. Once the INDEX * ON command is used with the DISPLAY_BAR function, it must be * accessed whenever the database is open. Also, replace the * REC_NUMBER memory variable in DISPLAY BAR with RECNO(). Then * issue the following command: INDEX ON company TAG company FOR display_bar()=.T. * The following function displays a bar graph to represent the * the progress of a sequential, report, or indexing operation. FUNCTION display_bar pct = rec_number * 100 / RECCOUNT() @ 18,14 SAY REPLICATE(CHR(219),(pct/2)+1) RETURN .T. * The following function displays the background screen for the * bar graph function. FUNCTION display_border @ 14,10 TO 19,69 DOUBLE @ 17,11 TO 17,68 DOUBLE @ 17,10 SAY CHR(204) @ 17,69 SAY CHR(185) @ 15,24 SAY "P E R C E N T C O M P L E T E" @ 16,14 SAY "0 10 20 30 40 50" @ 16,44 SAY "60 70 80 90 100" RETURN .T.NOTE: If you use CHR(219) with the default FixedSys font, it represents the letter "U" with an umlaut.
Sample Code for FoxPro for Windows
SET TALK OFF SET CURSOR OFF USE C:\foxprow\tutorial\customer =display_border() * The next three commands are examples of using the * thermometer bar with the DISPLAY_BAR and DISPLAY_BORDER commands. * 1. Sequential operations. * The DISPLAY_BAR function displays a bar graph * to represent the progress of a sequential operation. PRIVATE rec_number rec_number = 1 SCAN && Perform database operation =display_bar() = .T. rec_number = rec_number + 1 ENDSCAN * 2. Report operations. * The DISPLAY_BAR function displays a bar graph to represent the * progress of a report being printed. In the Report Writer, when an * index is active, create a memory variable called REC_NUMBER. * From the Report menu, choose Variables. Then choose Add. Choose * the Count option button. Then create a variable name of * REC_NUMBER and store the value 0. When no index is active, * replace the memory variable REC_NUMBER in the DISPLAY_BAR * function with RECNO(). Then issue the following command: REPORT FORM cust NOCONSOLE TO PRINTER FOR display_bar()=.T. * 3. Indexing operations. * The DISPLAY_BAR function displays a bar graph to represent the * progress of an index operation using a .CDX index. Once the INDEX * ON command is used with the DISPLAY_BAR function, the DISPLAY_BAR * function must be accessed whenever the database is open. Also, * replace the REC_NUMBER memory variable in DISPLAY BAR with * RECNO(). Then issue the following command: INDEX ON company TAG company FOR display_bar()=.T. * The following function displays a bar graph to represent * the progress of a sequential, report, or indexing operation. FUNCTION display_bar pct = rec_number * 100 / RECCOUNT() x = 14 + (pct/2+1) @ 1,4 FILL TO 2,x COLOR W/N* RETURN .T. * The following function displays the background screen for the bar * graph function. FUNCTION display_border DEFINE WINDOW therm FROM 14,10 TO 17,80 HALFHEIGHT ; TITLE "Percent Complete" FONT "arial",10 ACTIVATE WINDOW therm @ 1,4 TO 2,65 PEN 2 COLOR 0,0,0 @ 0,4 SAY "0 10 20 30 40 50" @ 0,38 SAY "60 70 80 90 100" RETURN .T. |
Additional reference words: VFoxMac 3.00b VFoxWin 3.00 FoxDos FoxWin 2.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |