home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Aktiv 1 / CDA1_96.ISO / clipper / progmetr.prg < prev    next >
Text File  |  1996-01-06  |  2KB  |  68 lines

  1. /*********************************************************progmetr.prg
  2. *  Function prog_meter(nCount,nTotal,nColorCode,lDisplay,cDisplaycolor)
  3. *
  4. *  Purpose: Display horizontal progress meter on line 25
  5. *           non-destructively to allow messages to display on same line.
  6. *
  7. *           Modeled after similar function by Artful Applications
  8. *           written in "C".  This one is rewritten in pure Clipper.
  9. *
  10. *
  11. *  Paramenters:
  12. *                        nCount       ->        Current item in progress
  13. *                        nTotal        ->        Total to be processed
  14. *                        nColorcode    ->        Color number
  15. *                        lDisplay      ->        Boolean to control display of "(xx%)"
  16. *                                   completion dispaly in column 75
  17. *                 cDispcolor  ->    Color string for lDisplay
  18. *
  19. *
  20. *
  21. * Written by Rick Newton CIS 75517,2410
  22. *
  23. * Placed into the public domain.  Drop me a line and tell me what you
  24. * think.
  25. *
  26. *********************************************************************/
  27.  
  28.  
  29. // Demo calling function below:
  30.  
  31.  
  32. SET CURSOR OFF
  33. @ 0,0,maxrow(),maxcol() BOX REPL(CHR(176),9) COLOR "b/w"
  34. @ MAXROW(),0 SAY PADR("Counting...please wait",80," ") COLOR "gr+/bg"
  35. FOR i = 1 to 10000
  36.     prog_meter(i,10000,,,"gr+/bg")
  37. NEXT i
  38.  
  39. /*
  40.   Will also work with INDEX ON in EVAL clause
  41. */
  42.  
  43.  
  44.  
  45.  
  46. FUNCTION prog_meter(nCount,nTotal,nColorCode,lDisplay,cDispcolor)
  47. LOCAL nCol    := nCount/nTotal*80
  48. LOCAL nMaxRow := MAXROW()
  49.  
  50. ldisplay   := IIF(lDisplay==NIL,.f.,ldisplay)
  51. nColorCode := IIF(nColorCode==NIL,79,nColorCode)
  52. IF lDisplay
  53.     @ nMaxrow,74   SAY "(   %)" COLOR cDispcolor
  54.     @ nMaxrow,75 SAY TRAN(nCount/nTotal*100,"999") COLOR cDispcolor
  55. ENDIF
  56.  
  57. // This is what does all the work.  We save the screen, change the
  58. // color attribute to the nColorcode passed, then restore it.
  59. // The rectangle saved and restored changes size based on the
  60. // value of nCol, which is a LOCAL calculated from first 2 parameters
  61. // passed in.  It is very similar to a the window shadow functions
  62. // you see all over the place.
  63.  
  64. RESTSCREEN(nMaxrow,0,nMaxrow,nCol,;
  65.       TRANSFORM( SAVESCREEN(nMaxrow,0,nmaxrow,nCol), ;
  66.       REPLICATE("X"+CHR(nColorCode), ncol-0+1 ) ) )
  67. RETURN .t.
  68.