home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a067 / 1.img / GRUMP501.EXE / READLINE.PRG < prev    next >
Encoding:
Text File  |  1991-04-23  |  1.1 KB  |  44 lines

  1. /*
  2.     Function: GFReadLine()
  3.     System:   GRUMPFISH LIBRARY
  4.     Author:   Greg Lief
  5.     Copyright (c) 1990 Grumpfish, Inc. - All Rights Reserved
  6.     Clipper 5.x Version
  7.     Compile instructions: clipper readline /n/w/a
  8.     Syntax:   GFReadLine(@<string>, <handle>)
  9.     Returns:  Logical value: .T. if successful, .F. if EOF()
  10. */
  11.  
  12. //───── begin preprocessor directives
  13.  
  14. #include "fileio.ch"
  15. #include "grump.ch"
  16.  
  17. //───── end preprocessor directives
  18.  
  19. function gfreadline(mstring, handle)
  20. local ret_val := .t., buffer, ptr, bytes, bufsize := 255, tempstring
  21. mstring := []
  22. buffer := space(bufsize)
  23. do while .t.
  24.    bytes := fread(handle, @buffer, bufsize)
  25.    tempstring := left(buffer, bytes)
  26.    if ( ptr := at(CRLF, tempstring) ) > 0
  27.       mstring += substr(tempstring, 1, ptr - 1)
  28.       fseek(handle, -(bytes - (ptr + 1)), FS_RELATIVE)
  29.       exit
  30.    else
  31.       mstring += tempstring
  32.       if bytes < bufsize
  33.          ret_val := .f.
  34.          exit
  35.       endif
  36.    endif
  37. enddo
  38. return ret_val
  39.  
  40. * end function GFReadLine()
  41. *--------------------------------------------------------------------*
  42.  
  43. * eof readline.prg
  44.