home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 15 / CD_ASCQ_15_070894.iso / vrac / stread.zip / README.TXT < prev    next >
Text File  |  1994-05-14  |  5KB  |  143 lines

  1.              Stream Line Read Function Version 1.0 for Clipper 5
  2.              ---------------------------------------------------
  3.  
  4.                      Written By Chris Murray, April 1994
  5.  
  6. The Library has two Functions, StrmBufReset and StrmLineRead.  The routines
  7. have been written to increase the speed of low level file reading.
  8.  
  9. I wrote the routines to create database's from large print files downloaded
  10. from the mainframe where I work.  These files were typically upwards of 20
  11. meg, and in one example on a IBM model 56 OBA it reduced the processing time
  12. to ten minutes from a five hours (that's about 650 lines a second).
  13.  
  14. I would welcome any comments via compuserve.  I have written some routines to
  15. buffer Fwrite, but it only speeds things up writing to slow drives (ie Floppy
  16. drives, LAN drives or LAN printer devices ).  I guess Clipper buffers all
  17. writes pretty well already.
  18.  
  19. Feel free to copy and distribute all the files, I would be interested in any
  20. comments and I can be reached on compuserve mail (100043,2247).
  21.  
  22. I would be appreciate $25, for my time and effort from people that are going
  23. to continue using the routines, (especially companies).
  24.  
  25. I will admit that the $25 is purely to feed my compuserve addiction, currently
  26. runnning at $100 a month. Thats a lot of money compared to my salary !
  27.  
  28. For that fee I will do all the normal stuff, like sending updates when needed
  29. and online support via compuserve.
  30.  
  31. Even if you are an unregistered user, feel free to contact me via Compuserve
  32. if you have any questions.
  33.  
  34. Note : if the file you are dealing with ends without CRLF the function will
  35.        return FALSE but the buffer will be filled with the remaining characters.
  36.        I haven't come across this yet in a text file. The obvious way round it
  37.        would be to use a repeat/until loop and process the buffer if the
  38.        function returns FALSE, but the buffer is not empty, and of course when
  39.        the function returns TRUE.
  40.  
  41. My mail address is :
  42.  
  43.     Chris Murray
  44.     12 Cotham Hill
  45.     Cotham
  46.     Bristol
  47.     BS6 6LF
  48.     Avon
  49.     England
  50.  
  51. Or I can be reached on Compuserve 100043,2247.
  52.  
  53. StrmBufReset()
  54. Inialise buffer or clear buffer.
  55.  
  56. Syntax
  57. ------
  58.  
  59.         StrmBufReset( nHandle , nBufferSize ) --> NIL
  60.  
  61. Arguments
  62. ---------
  63.  
  64.         <nHandle> is the file handle returned by Fopen.
  65.  
  66.         <nBufferSize> is the requested buffersize.
  67.  
  68. Description
  69. -----------
  70.  
  71.         StrmBufReset must be called to initialize the buffer and when called
  72.         with no parameters clears the buffer.  nBufferSize is stored as a
  73.         Clipper Static with a maxium of 32k, so be careful if you're using any
  74.         3rd party Librarys (these typically use a lot of statics) as Statics
  75.         are stored in the Dgroup which has a limit of 64k (please Email me if
  76.         my understanding is incorrect).
  77.  
  78.         The buffersize HAS TO BE larger than the longest line, or StrmLineRead
  79.         will think it got to the end of the file.
  80.  
  81.         It is important to reset the buffer once you have finished using the
  82.         routines to free up the Static memory area to other routines.
  83.  
  84. Files: Library is StrmRead.Lib
  85.  
  86. StrmlineRead()
  87. Get next line from file
  88.  
  89. Syntax
  90. ------
  91.  
  92.         StrmlineRead( @cBuf ) --> lSucces
  93.  
  94. Arguments
  95. ---------
  96.  
  97.         <cBuf> is passed by reference and filled with the next line.
  98.  
  99. Returns
  100. -------
  101.  
  102.         StrmLineRead() returns True or False depending whether it can find
  103.         another line, therefore it will return False when it gets to the end
  104.         of the file. I would recommend using a repeat/until loop over a
  105.         do/while loop, just in case a file might be terminated EOF instead of
  106.         CR+LF+EOF, in this case StrmlineRead will return False but still fill
  107.         cBuf with the remainder of the line. Of course this means your program
  108.         processed a null string when you get to the end of the file. I haven't
  109.         come across a text file like this yet !
  110.  
  111. Description
  112. -----------
  113.  
  114.         StrmLineRead() will fill cBuf with the next line in the buffer if it
  115.         is passed by reference. The function is written to work as fast as
  116.         possible, if you try to compare it to Fread( nHandle , @cBuf , 1 ) you
  117.         will be amazed.
  118.  
  119. Example
  120. -------
  121.  
  122.         nHandle := Fopen( "testfile.txt" , FO_READ )
  123.  
  124.         If nHandle == F_ERROR
  125.            ? "File open error :", FERROR()
  126.         Else
  127.            // accept default buffer of 32k
  128.            StrmBufReset( nHandle )
  129.  
  130.            nCounter := 0
  131.  
  132.            Do While StrmLineRead( @cBuf )
  133.               @ 10 , 10 Say Str( ++nCounter , 6 , 0 )
  134.            Enddo
  135.  
  136.            // close stream
  137.            StrmBufReset()
  138.  
  139.         Endif
  140.         FClose( nHandle )
  141.  
  142. Files: Library is StrmRead.Lib
  143.