I’m using: SWI-Prolog version 7.6.4, 64 bit, threaded
I want the code to:
Open two files (AAA and BBB) and write to them sequentially.
But what I’m getting is:
File BBB is not created
My code looks like this:
go :- tell('aaa'),
write('First line of AAA'),nl,
write('First line of BBB'),nl,
write('This goes on the screen'),nl,
write('Second line of AAA'),nl,
This code is an example from Michael A Covington’s Prolog Programming in Depth with copyright date 1997. I assume that this functionality is not available in SWI-Prolog but can’t seem to find the answer by searching the web. I am a newbie to Prolog.
open(aaa, write, AAA),
open(bbb, write, BBB),
format(AAA, 'First line of AAA~n', ),
format(BBB, 'First line of BBB~n', ),
format(user, 'This goes on the screen~n', ),
format(AAA, 'Second line of AAA~n', ),
Also, write('...'), nl can be written more compactly as writeln('...').
Thank you for your help. As a Prolog newbie it’s really nice for two such eminent people to respond to my questions. I’ll do some research to learn the more modern methods of writing to files.