SWI-Prolog / contrib-swiplcs

Interface from C# to SWI-Prolog
http://www.lesta.de/Prolog/SwiPlCs/Generated/Index.html
24 stars 10 forks source link

writeln/1 issue on monogame #5

Open SchroterQuentin opened 7 years ago

SchroterQuentin commented 7 years ago

It seems that when I use writeln/1 on my program, the predicate fail. This behavior appear only on monogame, I try the same example on console application and it works fine.

wouterbeek commented 7 years ago

Can you give a reproducible example? Can you explain what "monogame" is?

SchroterQuentin commented 7 years ago

After some research, the problem seems to be between execution mode and not monogame (which is a graphic framewok for game development). Here is a reproductible example

static void Main(string[] args)
{
    if (!PlEngine.IsInitialized)
    {
        String[] param = { "-q" };
        PlEngine.Initialize(param);
        PlQuery q = new PlQuery("write('Hi'), X is 1");
        foreach (PlQueryVariables v in q.SolutionVariables)
        {
            Console.WriteLine(v["X"].ToString());
        }
        PlEngine.PlCleanup();
        Console.ReadKey();
    }
}

On "execution with debug" mode, nothing appear on the console and on "execution without debug" 'Hi' and 1 appear.

Now if we execute the same code with write/1 instead of writeln/1 with debug : only 1 appear and without debug : 1 and 'Hi' appear.

wouterbeek commented 7 years ago

That looks like Java code to me. You're probably using the Java/Prolog API called JPL. There's a separate issue tracker for that over at: https://github.com/SWI-Prolog/packages-jpl/issues

JanWielemaker commented 7 years ago

All I can say is that, unless someone redefined I/O, write/1 writes to user_output, which is initially bound to stdout. This is a line-buffered stream, so to see something you need a newline or call flush_output/0. I don't think this has to do much with the interface, more the OS and how it is embedded.