file_str_read (var handle,STRING* string)
file_str_readto(var handle, STRING* string, char *delimiter, var length)
file_str_readtow(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.
A7.84 file_str_readtow reads 16-bit characters for displaying Unicode text.
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 ASCII characters into a STRING*,
1..5000 for reading Unicode characters
, and 1..999999 for reading into a buffer).
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 bytes. This limit does not apply for reading into a buffer using a char* pointer.
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_str_write, txt_load, delimit_str
► latest
version online