In article <
867ea78a-57f9-49b9...@googlegroups.com>
DELIMITED WITH refers to the string delimiter (usually "), not the
field separator (which is a comma).
A long time ago I had the need to read a text file a line at a time
(variable length lines) and S'87 has no such function, so I wrote one.
(OK, you can read one char at a time looking for a CR or LF but that
is very inefficient.)
I include the source below -- all you need to do is to change the LF,
CHR(10), for FF, CHR(12), and the returned string should contain a
whole "page" of data. You can then MEMOWRITE() this. It would also
be sensible to change the 'linesize' default to something more
representative of a 'pagesize' and perhaps rewrite for Clipper 5.x.
-------- start code ---------
*
* freadln() - read a line of text from a file up to and including
* the LF delimiter
* params: handle: obtained from a previous call to fopen()
* linesize: the "ideal" or estimated line length of the
* file in question. This param is optional and defaults
* to 256 if not specified.
* Returns: CHARACTER; a line of text from the file or an empty
* string [""] on EOF or error. Use DOSERROR() to decide
* which.
* Notes: the ideal value for 'linesize' is slightly longer than
* the length of the majority of lines in the file, ideal
* in the sense of performance. The default value of 256
* ought to be OK for "most" text files.
*
* Usage: cTextLine = freadln (handle [,opt_line_length])
*
function freadln
parameters handle, linesize
private string
private lf
private nbytes
*-- S87 doesn't like this:
*-- if pcount() < 2 .or. linesize <= 0
*-- SO...
if pcount() < 2
linesize = 256
elseif linesize <= 0
linesize = 256
endif
string = space (linesize)
lf = chr(10)
nbytes = fread (handle, @string, linesize)
if nbytes <= 0
return ""
endif
pos = at (lf, string)
if pos == 0
return string + freadln (handle, linesize)
else
string = substr (string, 1, pos)
fseek (handle, pos - nbytes, 1)
endif
return string
-------- end code ---------
Just trying to help,
Pete
--
Believe those who are seeking the truth.
Doubt those who find it. - Andr� Gide