XPCE windows freeze with swipl but not swipl-win

I’m using Windows 10.

I have a program using XPCE that works fine as long as I open up swipl-win and then launch the program from there. However, if I run swipl from the command line I run into problems. First, the program had problems with the use_module(library(pce)) load, but I fixed this by copying the swipl-win.rc file in the installation directory file to my user directory and renaming it to swipl.rc. Great, the XPCE program actually runs now.

However, although the window boots up when I run the program from swipl, it freezes and stops responding as soon as I click any part of the window (a button, or just the background). I am sure this is not a problem with my program, but I recreated the issue by running several of the demo XPCE programs that are installed with SWI-Prolog.

Is there a way around this, or is this a legitimate bug?

In the meantime, the main reason I want to run swipl instead of swipl-win is that I want to load my script from the command line with command line parameters, and this doesn’t seem possible with swipl-win.

swipl.exe is a windows console application and cannot do full Win32 GUI. swipl-win.exe is the gui equivalent. swipl.exe is mostly provided for scripting and server applications, swipl-win.exe for interactive development.

P.s. note that both are just a thin layer around libswipl.dll that provides the core of SWI-Prolog.


Welcome to the forum!

You can always use current_prolog_flag(argv,Args) or current_prolog_flag(os_argv,Args) to get the command line arguments.

The documentation is here:

For some reason, I foolishly thought that swipl-win wasn’t accepting command line parameters the same way swipl was, but I just had to fiddle with it more. I would still prefer not to open up the whole swipl-win console in the background of my XPCE GUI window, but using swipl-win from the command line is definitely an acceptable solution.

Out of curiosity, is it possible to send write(“Text”) output to the actual launching console instead of the Prolog console?

Also, if someone wanted to run my code on Mac or UNIX, would they simply be able to use swipl or would they have to launch a different program? I’ve seen mention online of launching code with xpce from the command line, but the Windows version of SWI-Prolog doesn’t have an executable for this.

You can hide the swipl-win console using [win_window_pos/1](https://www.swi-prolog.org/pldoc/doc_for?object=win_window_pos/1

At the moment, no. I’m not sure this can be done from a Windows perspective. Surely a GUI app can open an console, but I doubt this console will be the one that launched the app.

The Unix and Mac versions of swipl can run graphics, provided the environment has access the X11. On MacOS there is also a Qt based swipl-win that behaves almost the same as swipl-win.exe.

1 Like