Home > Archive > Prolog > May 2006 > Save Datatbase ?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| newser.bbs@bbs.ee.ncu.edu.tw 2006-05-07, 7:12 pm |
| In the Turbo Prolog , there is a predicate "save" ,
which can save all the database into a file.
Is there such a predicate in gprolog or swi-prolog ?
For clear illustration of the predicate I asked ,
here is an example:
assertz(db_1(this)).
assertz(db_1(is)).
assertz(db_1(an)).
assertz(db_1(example)).
save('database.txt').
And the last clause makes the contents of the file ,'database.txt',
becomes :
db_1(this).
db_1(is).
db_1(an).
db_1(example).
My question is " Is there such a predicates as the above 'save'
in gprolog or SWI-prolog?"
If the answer is NO , how can I do the same thing in gprolog or
SWI-prolog?
Thank You .
| |
|
| newser.bbs@bbs.ee.ncu.edu.tw ha scritto:
> In the Turbo Prolog , there is a predicate "save" ,
> which can save all the database into a file.
> Is there such a predicate in gprolog or swi-prolog ?
>
> For clear illustration of the predicate I asked ,
> here is an example:
>
> assertz(db_1(this)).
> assertz(db_1(is)).
> assertz(db_1(an)).
> assertz(db_1(example)).
>
> save('database.txt').
>
> And the last clause makes the contents of the file ,'database.txt',
> becomes :
> db_1(this).
> db_1(is).
> db_1(an).
> db_1(example).
>
> My question is " Is there such a predicates as the above 'save'
> in gprolog or SWI-prolog?"
> If the answer is NO , how can I do the same thing in gprolog or
> SWI-prolog?
>
> Thank You .
>
update_file(ToFile) :-
telling(Old),
tell(ToFile),
listing(db_1/1),
told,
tell(Old).
| |
| Cesar Rabak 2006-05-07, 7:12 pm |
| Marco escreveu:
> newser.bbs@bbs.ee.ncu.edu.tw ha scritto:
>
[snipped]
[color=darkred]
>
> update_file(ToFile) :-
> telling(Old),
> tell(ToFile),
> listing(db_1/1),
> told,
> tell(Old).
This way using the traditional "Edinburgh Style" worksą, but I recommend
you stick for the ISO Standard, so please check in the above Prolog
documentation for the predicates open/3, set_output/1, current_output/1.
HTH
--
Cesar Rabak
[1] OK, DEC-10 compatibility!
| |
| newser.bbs@bbs.ee.ncu.edu.tw 2006-05-08, 4:05 am |
|
Cesar Rabak wrote:
> Marco escreveu:
>
> This way using the traditional "Edinburgh Style" works=B9, but I recommend
> you stick for the ISO Standard, so please check in the above Prolog
> documentation for the predicates open/3, set_output/1, current_output/1.
But for a 15 y/r Turbo Prologer as me , tell telling and told is more
comfortable . Because in Turbo Prolog , there are similar predicates
openwrite/2 and writedevice/1.
|
|
|
|
|