home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 8 / CDASC08.ISO / VRAC / STATWIN.ZIP / README.TXT < prev    next >
Encoding:
Text File  |  1993-09-02  |  5.3 KB  |  135 lines

  1. *** New Note ***
  2.  
  3. I didn't really expect this thing to go over so well!  As a result I have
  4. found myself fine tuning it due to a number of performance questions raised.
  5.  
  6. I guess I better start with the version numbers!
  7.  
  8. Um, lets call this one 2.5.  What the hell.
  9.  
  10. *** End Note ***
  11.  
  12. The purpose of STATWIN is to display a "percentage processed," or "status" 
  13. window, complete with visual indicator bar.  I applaud Jim Schaffner for 
  14. implementing this idea using Clipper.
  15.  
  16. However, as is usually the case when I stumble across good code, I found some 
  17. elements aesthetically lacking.  With apologies to Jim, I have hacked up the
  18. code a bit to help satisfy my desire to produce a more beautiful and robust
  19. utility.
  20.  
  21. There are many enhancements to the original, but I will spare you the details.
  22. Just try it out.  If you have used the original, the differences will be
  23. readily apparent.  The gist of the code is still Jim's, though.
  24.  
  25. I have also included a better TEST program, which shows all the features
  26. available from STATWIN.
  27.  
  28. Compile both TEST.PRG and STATWIN.PRG, then link.  Have fun!  I hope you
  29. enjoy this great little utility!  If you have any other ideas to improve
  30. the code (either functionally or aesthetically) I'd be glad to hear from you.
  31.  
  32. Cai Campbell
  33. Compuserve ID 72622,1771
  34.  
  35. *
  36. *   One problem inherent in a utility such as StatWin is its inability to
  37. *   report progress on "internal" processes such as indexing or appending.
  38. *
  39. *   The following code demonstrates a method I have included to circumvent 
  40. *   this problem.  However, since it utilizes a couple of public variables,
  41. *   purists may frown on this approach.
  42. *
  43. *   The philosophy behind this approach may be applied to a number of other
  44. *   situations where "internal" processes are being used.
  45. *
  46.  
  47. *
  48. *  Procedure: ShowIndex
  49. *
  50. *  Demonstrates the method needed to use StatWin to display percent bar while
  51. *  a large DBF file is being indexed or reindexed.
  52. *
  53.  
  54. PROCEDURE ShowIndex
  55.  
  56.    USE BigFile NEW      // Open the DBF file
  57.    StatInit ( 8, 25 )   // Initialize the Status Window
  58.    
  59.    cStatMsg := "Indexing:"  // Public variable to store Status Window Message
  60.                             // (optional)
  61.  
  62.    INDEX ON INDEXKEY + StatWin ( LASTREC(), nStatCounter, cStatMsg ) TO IndexFile
  63.  
  64.    //  The above index command is the key to making the status bar work.
  65.    //  StatWin is tied directly to your index.  As such, every time BigFile is 
  66.    //  reindexed (or processed in any way, for that matter), the Status
  67.    //  Window will be displayed (If you forget to reinitialize the Status
  68.    //  Window with StatInit, the resulting window will be less than pleasing.)
  69.    //  You can stop display of the Status Window by explicitly reindexing the 
  70.    //  file without making StatWin part of the index.
  71.    //
  72.    //  nStatCounter is a Public variable definded in STATWIN.PRG.  It keeps
  73.    //  track of the current state of the process.
  74.  
  75.    StatExit()
  76.              
  77.    StatInit ( 8, 25 )       // This section is similar to that above, but shows
  78.    cStatMsg := "Reindexed:" // how you would go about reindexing the file while
  79.    REINDEX                  // showing the Status Window.  This assumes that the
  80.    StatExit()               // the file has been indexed once before using the
  81.                             // process outlined above.  Note that cStatMsg can
  82.                             // be changed to display a different message every
  83.                             // time you reindex the file.
  84.    CLOSE BigFile
  85.  
  86. RETURN
  87.  
  88. *
  89. *  Procedure: ShowAppend
  90. *
  91. *  Demonstrates the method needed to display a Status Window while appending
  92. *  from a large file.
  93. *
  94.    
  95.    LOCAL nFileSize      // Size of source file (in number of records)
  96.  
  97.    cStatMsg := "Appending:"  // Public variable declared in STATWIN.PRG
  98.  
  99.    USE TargFile NEW     // Open the DBF file
  100.    ZAP                  // Assuming you want to clear the target file
  101.    StatInit ( 8, 25 )   // Initialize the Status Window
  102.  
  103.    nFileSize := // If appending from an ASCII SDF file, nFileSize equals the 
  104.                 // size of file (in bytes) divided by line length (including
  105.                 // carriage return and linefeed.)  This gives the total number
  106.                 // of records to be appended.  
  107.                 //
  108.                 // If appending from an ASCII delimited file, nFileSize will be
  109.                 // more difficult to compute.  One solution is to search the
  110.                 // source file for the total # of carriage return/linefeeds, 
  111.                 // thus giving you the total number of records to be appended.
  112.                 // (See accompanying LINCOUNT.PRG)
  113.                 //
  114.                 // If appending from another DBF file, nFilSize simply 
  115.                 // equals the number of records in the source file.
  116.    
  117.    INDEX ON StatWin ( nFileSize, nStatCounter, cStatMsg ) TO IndexFil
  118.  
  119.    //  The above index command is the key to making the status bar work.  The
  120.    //  function StatWin is directly tied to the index.
  121.    //
  122.    //  Here, IndexFile is temporary and is used only to allow displaying of the
  123.    //  Status Window.
  124.  
  125.    APPEND FROM ( "SOURCE.TXT" ) SDF  // assuming ASCII System Data Format
  126.  
  127.    StatExit()  
  128.  
  129.    CLOSE TargFile INDEXES           // close the temporary index
  130.  
  131.    FERASE ( "INDEXFIL.NTX" )        // erase the temporary index
  132.  
  133.    CLOSE TargFile
  134.  
  135.