file_str/2
file_str (STRING OSFileName, STRING StringVariable)
Flow patterns (i, o), (i, i)
Read or write a whole disk text file to or from a string
Remarks
(i, o) The whole file OSFileName will be read into the string StringVariable.
Note that in Visual Prolog the STRING domain is a sequence of characters, implemented
as a pointer to a zero-terminated byte array (as in language C). Therefore, file_str
writes the whole contents of the file into the memory block beginning from the byte
pointed by the StringVariable and adds terminating zero byte. From the other side,
the file itself can contain zero bytes (NULL characters) and file_str copies these
internal zero bytes into the memory block pointed by the StringVariable. In this
case, Visual Prolog (according to the STRING format) interprets the StringVariable
as the memory block beginning from the byte pointed by the StringVariable and terminating
by the first encountered zero byte. Hence, remember that if an input file can contain
zeros then it usually should be converted into a string list.
(i, i) A new text file, OSFileName, containing the string StringVariable will be
created. If a file OSFileName already exists, file_str renames it with the .BAK extension
and then creates the new file OSFileName (without any notification to the user).
Errors
OS file errors.
1110 File too big, or not enough memory for file.
See sample: 50