public static void Main(string [] args)
        {
            PrologEngine e = null;

              try
              {
            e = new PrologEngine (new DosIO ());

            // ProcessArgs -- for batch processing. Can be left out if not used
            if (e.ProcessArgs (args, false)) return;

            SetPreferredConsoleProperties (e);
            Console.Title = "C#Prolog command window";
            Console.WriteLine (PrologEngine.IntroText);
            Console.WriteLine ("\r\n--- Enter !! for command history, help for a list of all commands");

            //if (Engine.ConfigSettings.InitialConsultFile != null)   // set in CSProlog.exe.config
            //  e.Consult (Engine.ConfigSettings.InitialConsultFile); // any additional initialisations

            while (!e.Halted)
            {
              Console.Write (e.Prompt);
              e.Query = ReadQuery ();

              // Use e.GetFirstSolution instead of the loop below if you want the first solution only.
              //Console.Write (e.GetFirstSolution (e.Query));

              foreach (PrologEngine.ISolution s in e.SolutionIterator)
              {
            // In order to get the individual variables:
            //foreach (Engine.IVarValue varValue in s.VarValuesIterator)
            // { Console.WriteLine (varValue.Value.To<int> ()); } // or ToString () etc.
            Console.Write (s);

            if (s.IsLast || !UserWantsMore ()) break;
              }

              Console.WriteLine ();
            }
              }
              catch (Exception x)
              {
            Console.WriteLine ("Error while initializing Prolog Engine. Message was:\r\n{0}",
              x.GetBaseException ().Message + Environment.NewLine + x.StackTrace);
            Console.ReadLine ();
              }
              finally
              {
            if (e != null) e.PersistCommandHistory (); // cf. CSProlog.exe.config
              }
        }
Exemple #2
0
        static void Main(string [] args)
        {
            if (args.Length > 0) // batch processing assumed if arguments supplied
            {
                Prolog.MainForm.BatIO batIO = null;

                try
                {
                    PrologEngine e = new PrologEngine(batIO = new Prolog.MainForm.BatIO());
                    e.ProcessArgs(args, true);
                    Application.Exit();

                    return;
                }
                finally
                {
                    if (batIO != null)
                    {
                        batIO.Close();
                    }
                }
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
Exemple #3
0
        public static void Main(string [] args)
        {
            PrologEngine e = null;

            try
            {
                e = new PrologEngine(new DosIO());

                // ProcessArgs -- for batch processing. Can be left out if not used
                if (e.ProcessArgs(args, false))
                {
                    return;
                }

                SetPreferredConsoleProperties(e);
                Console.Title = "C#Prolog command window";
                Console.WriteLine(PrologEngine.IntroText);
                Console.WriteLine("\r\n--- Enter !! for command history, help for a list of all commands");

                //if (Engine.ConfigSettings.InitialConsultFile != null)   // set in CSProlog.exe.config
                //  e.Consult (Engine.ConfigSettings.InitialConsultFile); // any additional initialisations

                while (!e.Halted)
                {
                    Console.Write(e.Prompt);
                    e.Query = ReadQuery();

                    // Use e.GetFirstSolution instead of the loop below if you want the first solution only.
                    //Console.Write (e.GetFirstSolution (e.Query));

                    foreach (PrologEngine.ISolution s in e.SolutionIterator)
                    {
                        // In order to get the individual variables:
                        //foreach (Engine.IVarValue varValue in s.VarValuesIterator)
                        // { Console.WriteLine (varValue.Value.To<int> ()); } // or ToString () etc.
                        Console.Write(s);

                        if (s.IsLast || !UserWantsMore())
                        {
                            break;
                        }
                    }

                    Console.WriteLine();
                }
            }
            catch (Exception x)
            {
                Console.WriteLine("Error while initializing Prolog Engine. Message was:\r\n{0}",
                                  x.GetBaseException().Message + Environment.NewLine + x.StackTrace);
                Console.ReadLine();
            }
            finally
            {
                if (e != null)
                {
                    e.PersistCommandHistory();     // cf. CSProlog.exe.config
                }
            }
        }
        static void Main(string [] args)
        {
            if (args.Length > 0) // batch processing assumed if arguments supplied
              {
            Prolog.MainForm.BatIO batIO = null;

            try
            {
              PrologEngine e = new PrologEngine (batIO = new Prolog.MainForm.BatIO ());
              e.ProcessArgs (args, true);
              Application.Exit ();

              return;
            }
            finally
            {
              if (batIO != null) batIO.Close ();
            }
              }

              Application.EnableVisualStyles ();
              Application.SetCompatibleTextRenderingDefault (false);
              Application.Run (new MainForm ());
        }