home *** CD-ROM | disk | FTP | other *** search
- *****************************************************************
- FUNCTION FREADLINE (handle, line_len)
- *****************************************************************
-
- * Read a line from a text file (from current pointer position)
-
- * Copyright(c) 1991 -- James Occhiogrosso
-
- # define MAXLINE 512
-
- LOCAL buffer, line_end, num_bytes
-
- * If line length not passed, default to MAXLINE
- IF VALTYPE(line_len) != 'N'
- line_len = MAXLINE
- ENDIF
-
- * Define temporary buffer to hold specified line length
- buffer = SPACE(line_len)
-
- * Read from current position to specified line length
- num_bytes = FREAD(handle, @buffer, line_len)
-
- * Find carriage return/line feed combination
- line_end = AT(CHR(13)+CHR(10), buffer)
-
- IF line_end = 0
- * No carriage return/line feed. Pointer is at the end of
- * file, or line is too long. Rewind pointer and return
- FSEEK(handle, 0)
- RETURN('')
-
- ELSE
- * Move pointer to beginning of next line
- FSEEK(handle, (num_bytes * -1) + line_end + 1, 1)
- * And return current line
- RETURN( SUBSTR(buffer, 1, line_end - 1) )
-
- ENDIF
-
-
-