Copyright ® (1999-2005) EDMGROUP Pty Ltd - EZY Prolog Reference

 file_str

[This is preliminary specification and subject to change.]

Group

Prolog predicates  (more...)

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)Thereforefile_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 StringVariableIn 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 listFor this purpose you can use

(i, i)    A new text fileOSFileName, 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).

Copyright © 1997-2005 EDMGROUP (Australia)