contrib-swiplcs
contrib-swiplcs copied to clipboard
writeln/1 issue on monogame
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.
Can you give a reproducible example? Can you explain what "monogame" is?
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.
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
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.