public static string executeAddProlog() { String s; try { LPA.IntServer prolog = new LPA.IntServer("", 0, 0, 0); //LPA.IntServer prolog = new LPA.IntServer("/H1024",0,0,0); // carrega o programa em prolog ('teste.pl') s = prolog.InitGoal("load_files(prolog(teste)).\n"); s = prolog.CallGoal(); prolog.ExitGoal(); // executa um predicado s = prolog.InitGoal("run3. \n"); s = prolog.CallGoal(); Console.WriteLine(s); prolog.ExitGoal(); } catch (Exception ex) { Console.WriteLine(ex.Message); return ex.Message; } return s; }
static void Main(string[] args) { try { // inicia o motor do prolog LPA.IntServer prolog = new LPA.IntServer("", 0, 1, 0); //LPA.IntServer prolog = new LPA.IntServer("/H1024",0,0,0); String s; // carrega o programa em prolog ('teste.pl') s = prolog.InitGoal("load_files(prolog(teste)).\n"); s = prolog.CallGoal(); prolog.ExitGoal(); // executa um predicado s = prolog.InitGoal("run1.\n"); s = prolog.CallGoal(); Console.WriteLine(s); while (s.StartsWith("T")) { Console.WriteLine(s.Substring(8)); s = prolog.CallGoal(); } prolog.ExitGoal(); // executa um predicado s = prolog.InitGoal("run2.\n"); Console.WriteLine(s); s = prolog.CallGoal(); Console.WriteLine(s); s = prolog.TellGoal("def.\n"); Console.WriteLine(s); prolog.ExitGoal(); Console.WriteLine("Add..."); // executa um predicado s = prolog.InitGoal("run3. \n"); s = prolog.CallGoal(); Console.WriteLine(s); prolog.ExitGoal(); Console.WriteLine("Sucesso..."); Console.ReadLine(); } catch(Exception ex) { Console.WriteLine(ex.Message); Console.ReadLine(); } }