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:

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