Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prolog: adding text to the end of a file

Tags:

prolog

I want to add text to a database in prolog. Something like

adding :- tell('a.txt'), write('abc'), told.

but not overwriting the a.txt. I've tried using append like this:

append('a.txt'),write('abc'), told.

but it didn't work. The listener just give a 'no' response and file is not changed. I'm using Amzi Prolog, btw.

Any help will be appreciated.

like image 462
Hearty Avatar asked Jun 23 '11 14:06

Hearty


1 Answers

You have to use these IO predicates: open/3, write/2, close/1.

adding :- open('a.txt', append, Handle), write(Handle, 'abc'), close(Handle).

Check here

like image 118
gusbro Avatar answered Sep 27 '22 21:09

gusbro