file_str_read (var handle,STRING* string)
file_str_readto(var handle, STRING* string, char *delimiter, var length)
Reads content from the file with the given handle into the given
string
or buffer, until a size or
delimiter is reached.
This way, comma separated strings
from a database file can be read. The file must be open for reading.
Parameters:
handle - File handle.
string -
STRING* or A7.79 char*
pointer
to receive the read content, or
A7.20 NULL for just skipping content of the file.
delimiter - STRING* or char*, used as end mark for the text, or NULL
for using the delimit_str, or "" (empty string)
for no end mark.
length - maximum number of characters to be read (1..10000 for reading into a STRING*,
1..999999 for reading into a char* buffer of the given size).
Returns:
Number of characters read, or -1 when the end of file was reached.
Remarks:
- The file must be open for reading.
- The delimiter for file_str_read is either a '0' byte in
the file, or
any control character (f.i. a line feed),
or the content of the delimit_str variable
(default: comma ','). The delimiter for file_str_readto is
either a '0' byte in the file, or the delimiter parameter if it was
nonzero.
- The maximum string
size to be read is 10000 characters. This limit does not apply for reading into a char* buffer.
Example:
STRING* sTest = " ";
...
fhandle = file_open_read("test.txt"); // test.txt contains "this,is,a,test"
file_str_read(fhandle,sTest); // sTest now contains "this"
file_close(fhandle);
See also:
file_open_read,
file_close,
file_var_read,
file_str_write, file_chr_read,
file_asc_write, file_asc_read, txt_load, delimit_str
► latest
version online