Home > Archive > Prolog > April 2005 > Adding Clauses using Assert(a/z)
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]
| Author |
Adding Clauses using Assert(a/z)
|
|
| kalden 2005-03-17, 8:57 am |
| Hi All,
I have a problem where I am adding clauses to the knowledge base using
assertz. This works fine, but I lose the clauses when I exit the
SWI-Prolog program. Is there a save method I should be using to save
these new clauses ready for viewing next time I run the program?
Thanks in advance for your help
| |
| Bart Demoen 2005-03-23, 8:57 am |
| kalden wrote:
> Hi All,
>
> I have a problem where I am adding clauses to the knowledge base using
> assertz. This works fine, but I lose the clauses when I exit the
> SWI-Prolog program. Is there a save method I should be using to save
> these new clauses ready for viewing next time I run the program?
>
> Thanks in advance for your help
listing/0 listing/1 see manual
Cheers
Bart Demoen
| |
| kalden 2005-03-30, 3:58 pm |
| Listing only lists the clauses on screen. This is not what I'm looking at
achieving.
What I want to achieve is adding clauses that are stored in the prolog
file, so that if the computer is shut down, restarted, and the program
reloaded, the clauses are still in the prolog file.
| |
| kalden 2005-03-30, 3:58 pm |
| Listing only lists the clauses on screen. This is not what I'm looking at
achieving.
What I want to achieve is adding clauses that are stored in the prolog
file, so that if the computer is shut down, restarted, and the program
reloaded, the clauses are still in the prolog file.
| |
| Bart Demoen 2005-03-30, 8:58 pm |
| kalden wrote:
> Listing only lists the clauses on screen. This is not what I'm looking at
> achieving.
listing(/1) writes to current output.
If you want to save things in a file, first redirect the current output
to that file - see tell/1.
> What I want to achieve is adding clauses that are stored in the prolog
> file, so that if the computer is shut down, restarted, and the program
> reloaded, the clauses are still in the prolog file.
That might be a bit too much to ask, depending on what you meant
exactly, but come back when you have tried the above and are not
satisfied.
Cheers
Bart Demoen
| |
| tmp123 2005-04-06, 12:44 pm |
| kalden wrote:
> Hi All,
>
> I have a problem where I am adding clauses to the knowledge base
using
> assertz. This works fine, but I lose the clauses when I exit the
> SWI-Prolog program. Is there a save method I should be using to save
> these new clauses ready for viewing next time I run the program?
>
> Thanks in advance for your help
If the subject is only to save the clauses at program exit, before to
exit, use listing, or clause+write, or similars to SWI "qsave", to save
the state.
If the subject is to write a "critical mission" application, things are
more complex. Some posibilities are:
- There are prologs that allows store the rules in usual databases like
"sql", ... .
- Backup the dinamic knowledgment each "n" time (using the same method
than at exit) and write the following assert/retracts operations to a
file. On recovery, first load the latest backup, and second update
reading the file of assert/retract.
- My favorite: send the assert/retracts via RPC/TPC/IP to a second
instance of the prolog application, in another computer. In this way
you have always an active/passive configuration, that allows fast warm
swith-over at any time.
Probably some other readers knows more options.
|
|
|
|
|