Hello
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:
Pl_Write_Simple(Pl_Get_Exception());
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.
Daniel
josh b a écrit :
Hey,
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:
int func;
PlTerm arg[10];
int res;
Pl_Start_Prolog(argc, argv);
//This correctly unifies arg[1] with the absolute file name of
new_main.pl, e:/new_main.pl
func = Pl_Find_Atom("absolute_file_name");
Pl_Query_Begin(PL_TRUE);
arg[0] = Pl_Mk_String("new_main.pl");
arg[1] = Pl_Mk_Variable();
res = Pl_Query_Call(func, 2, arg);
Pl_Query_End(PL_RECOVER);
//This should load in all predicates in the file new_main.pl
func = Pl_Find_Atom("consult");
Pl_Query_Begin(PL_TRUE);
arg[0] = arg[1];
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
either.
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.
Cheers,
Josh
Meet local singles online. Browse
profiles for FREE!
--
Ce message a été vérifié par
MailScanner
pour des virus ou des polluriels et rien de
suspect n'a été trouvé.
_______________________________________________
Users-prolog mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/users-prolog
|