Next: Consulting Files
Up: Files and I/O
Previous: Writing to file
get0(X)
get(X)
put(X)
copy_sentence(Input,Output) :-
see(Input),
tell(Output),
copy,
seen,
told.
copy :-
get0(Ch),
put(Ch),
treat([Ch]).
treat(".").
treat( _) :-
copy.
- copy_sentence copies from a file Input to a
file Output - until terminated by a period
- Instead of procedures seen and told, also possible
to close the input/output stream with close(Filename)
- When reading, if end of file reached, in the read(X)
goal, X is instantiated to end_of_file, and the next
read(X) fails
- get0(X) fails immediately if end of file is reached
Omer F Rana
Mon Mar 17 12:47:04 GMT 1997