|
Copyright ® (1999-2005) EDMGROUP Pty Ltd - EZY Prolog Reference |
[This is preliminary specification and subject to change.]
Group
Type
determ
Syntax
file_str( STRING FILENAME, STRING DATA)
Flow patterns
(i,i),(i,o)
Description:
Read or write a whole disk text file to or from a string
Sample:
(i, o) The whole file OSFileName (64K maximum on 16 bit platforms) 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. For this purpose you can use
(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).