are you sure pl2wam.exe is in your PATH variable (pl2wam is called by
consult/1 to compile the Prolog file before loading) ?
You can also use Pl_Get_Exception() to obtain the term associated to
the exception raised by consult/1. You can for instance display it on
the stdout using:
for Pl_Write_Simple() you can add the following
void Pl_Write_Simple(PlTerm term_word);
If you cannot solve the problem give us the message of the exception.
josh b a écrit :
I'm trying to access Prolog from within my C++ code (Using Visual C++
2008 Express). I have it mostly working now. I am able to successfully
write a C++ program, build it (In MSVC, not using glpc) and call
predicates like write/1 and absolute_file_name/2. However, I have my
own Prolog files I wish to consult from within the C ++code.
I figured I'd just call the consult/1 predicate with the name of the
.pl file. But the Pl_Query_Call returns a PL_EXCEPTION. I even tried using absolute_file_name/2
to construct the filename for consult/1 (To be 100% sure I was using
the right name). Sure enough, absolute_file_name/2 can find the file,
but consult/1 still fails.
Here is an excerpt from my code:
//This correctly unifies arg with the absolute file name of
func = Pl_Find_Atom("absolute_file_name");
arg = Pl_Mk_String("new_main.pl");
arg = Pl_Mk_Variable();
res = Pl_Query_Call(func, 2, arg);
//This should load in all predicates in the file new_main.pl
func = Pl_Find_Atom("consult");
arg = arg;
res = Pl_Query_Call(func, 1, arg);
Yet, it just returns and exception. Even if I try to proceed and try to
Pl_Find_Atom on any of the predicates from the file, they just fail.
I also tried adding the argument "--init-goal
consult('e:/new_main.pl')" to argv in Pl_Start_Prolog. No dice there
I'd really like to do my work from with the MSVC IDE, so any help with
programmatically consulting the prolog file would be much appreciated.
Meet local singles online. Browse
profiles for FREE!
Ce message a été vérifié par
pour des virus ou des polluriels et rien de
suspect n'a été trouvé.
Users-prolog mailing list