Microsoft KB Archive/93587

{|
 * width="100%"|

-

The information in this article applies to:


 * Microsoft Visual FoxPro for Windows, version 3.0
 * Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a
 * Microsoft FoxPro for Windows, versions 2.5, 2.5a
 * Microsoft Visual FoxPro for Macintosh, version 3.0b

-

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:\ \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 &quot;P E R C E N T  C O M P L E T E&quot; @ 16,14 SAY &quot;0  10   20   30   40   50&quot; @ 16,44 SAY &quot;60 70   80   90   100&quot; RETURN .T. NOTE: If you use CHR(219) with the default FixedSys font, it represents the letter &quot;U&quot; 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 &quot;Percent Complete&quot; FONT &quot;arial&quot;,10 ACTIVATE WINDOW therm @ 1,4 TO 2,65 PEN 2 COLOR 0,0,0 @ 0,4 SAY &quot;0    10     20     30     40     50&quot; @ 0,38 SAY &quot;60   70     80     90     100&quot; RETURN .T. Additional query words: VFoxMac VFoxWin FoxDos FoxWin thermometer gauge indicator RWriter

Keywords         : kbcode FxtoolRwriter Version          : 2.00 2.50 2.50a | 2.50 2.50a 3.0 Platform         : MACINTOSH MS-DOS WINDOWS Issue type       :
 * }