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
_________________________________________________________________
Browse profiles for FREE! Meet local singles online.
http://clk.atdmt.com/NMN/go/150855801/direct/01/_______________________________________________
Users-prolog mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/users-prolog