Discussions related to Visual Prolog
dcgreenwood
Posts: 24 Joined: 16 Jan 2021 1:33
Post
by dcgreenwood » 1 Apr 2021 0:13
I want to write a series of facts to a file, but I can't find any explanation about how to write facts to a file in any of the documentations. Only a few vague references that you can do it. Here is just a simple example of what I am trying to do
Code: Select all
class facts
testDB : ( string Name ) .
class predicates
filltestDB : ( ) .
clauses
filltestDB( ) :-
assert( testDB( "Name1" ) ) ,
assert( testDB( "Name2" ) ) ,
file:: save ( "TestFile" , testDB( _ ) ) .
but this gives me
error c504 :The expression has type 'main::main@classDB', which is incompatible with the type '::factDB'
Can you point me to a good explanation of writing to files, or give me some basics here?
Vitaly Markov
Active Member
Posts: 40 Joined: 30 Nov 2003 0:01
Post
by Vitaly Markov » 1 Apr 2021 10:37
Code: Select all
class facts - dbName
testDB : ( string Name ) .
class predicates
filltestDB : ( ) .
clauses
filltestDB( ) :-
assert( testDB( "Name1" ) ) ,
assert( testDB( "Name2" ) ) ,
file:: save ( "TestFile" , dbName) .
dcgreenwood
Posts: 24 Joined: 16 Jan 2021 1:33
Post
by dcgreenwood » 1 Apr 2021 13:48
Thanks!