Question: Saving facts 
Author Message
 Question: Saving facts

Is it possible to get a list of the asserted (dynamic) facts? I'd also like
to save/restore them from a file. I'm working with XSB and BProlog.

Help on this would be appreciated.

Cheers,

Kroly

______________________________________________________________________________
Posted Via Binaries.net = SPEED+RETENTION+COMPLETION = http://www.*-*-*.com/



Sun, 30 May 2004 23:56:51 GMT  
 Question: Saving facts

Quote:
> Is it possible to get a list of the asserted (dynamic) facts? I'd also
like
> to save/restore them from a file. I'm working with XSB and BProlog.

> Help on this would be appreciated.

> Cheers,

> Kroly

I don't know XSB or BProlog,
but I can tell you the normal way to do it.

The predicate you want, to list all facts, is "listing/0".

I'm not sure if it will also list static facts.
Try it and see.

To save facts to a file,
open the file, then use "listing" to list all the facts,
then close the file.

To read facts back from the file,
use "consult/1".

I can't remember the standard predicate to open a file.
Its called somethink like "open_file/2".
The rule to save facts to a file is something like this :

save_to_file :-
    open_file( 'myfile.pro', N, write ),
    tell( N ),
    listing,
    told.

To fetch facts back :

?- consult( 'myfile.pro' ).

"listing/0" lists all facts, but also lists all rules.
You may prefer to use "listing/1"
to list some facts only :

list_all_my_facts :
    listing( myfact1 ),
    listing( myfact2 ),
    listing( myfact3 ).

Where your facts are like this :

myfact1( abc ).
myfact1( fds ).
myfact2( adse, def, fdes ).
myfact3( ews ).
myfact3( rsd ).
etc.

--
Martin Sondergaard.



Mon, 31 May 2004 05:28:31 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Updating Facts question

2. Saving a file -> Save as type

3. F90: to SAVE or not to SAVE?

4. Save/Save As Problem

5. Saved / Not saved variable?

6. A "Saving" box during saving

7. SAVE doesn't save PC

8. XF is has problems saving and save as'ing

9. save and save as in xf

10. Question about script for saving lots of stuff

11. newbie question: saving variables by value

12. Can't Save Memo Question

 

 
Powered by phpBB® Forum Software