home *** CD-ROM | disk | FTP | other *** search
- /*
- Function: GFReadLine()
- System: GRUMPFISH LIBRARY
- Author: Greg Lief
- Copyright (c) 1990 Grumpfish, Inc. - All Rights Reserved
- Clipper 5.x Version
- Compile instructions: clipper readline /n/w/a
- Syntax: GFReadLine(@<string>, <handle>)
- Returns: Logical value: .T. if successful, .F. if EOF()
- */
-
- //───── begin preprocessor directives
-
- #include "fileio.ch"
- #include "grump.ch"
-
- //───── end preprocessor directives
-
- function gfreadline(mstring, handle)
- local ret_val := .t., buffer, ptr, bytes, bufsize := 255, tempstring
- mstring := []
- buffer := space(bufsize)
- do while .t.
- bytes := fread(handle, @buffer, bufsize)
- tempstring := left(buffer, bytes)
- if ( ptr := at(CRLF, tempstring) ) > 0
- mstring += substr(tempstring, 1, ptr - 1)
- fseek(handle, -(bytes - (ptr + 1)), FS_RELATIVE)
- exit
- else
- mstring += tempstring
- if bytes < bufsize
- ret_val := .f.
- exit
- endif
- endif
- enddo
- return ret_val
-
- * end function GFReadLine()
- *--------------------------------------------------------------------*
-
- * eof readline.prg
-