Setting up swiplserver for the first time. Help needed

You have an old version. Please uninstall it first, and then install the new version from here:

https://www.swi-prolog.org/download/devel/bin/swipl-8.5.3-1.x64.exe.envelope

Check the box “I understand” and download the binary.

Make sure to uninstall the old version first.

Then run

$ swipl --quiet -g mqi_start -t halt -- --write_connection_values=true

To make sure you are getting a port.

please erase any mqi.pl file that you have downloaded; start with a clean environment.

Hi,
The line where I call the consult statement works now.
I am getting error in the assertz call…

    with PrologMQI(port=4242, password="debugnow") as mqi:
        mqi.start()
        with mqi.create_thread() as prolog_thread:
            prolog_thread.query("consult(\'./graph_traversal.pl\')")
            print("AAA")
            for edge in selected_graph_attack_paths:
                command = "assertz(\"arc('" + edge[0] + "','" + edge[1] + "')\")"

                print(command)
                prolog_thread.query(command)
                print("BBB")

{ “args”: [ {“args”: [“callable”, “arc(‘A’,‘1’)” ], “functor”:“type_error”} ], “functor”:“exception” }

You are querying this in prolog:

assertz("arc('A','1')").

and you need to use this:

assertz(arc('A','1')).

EDIT: Use Python String Interpolation so you don’t get confused with all the quoting.

2 Likes

Hi Again,
I am able to assertz now, and I tried a simple query. It also works from the web interface :slight_smile: I will update the rest of the queries later. Quite an improvement for today. It is already after midnight. Thank you all the supporters :smiling_face_with_three_hearts: :smiling_face_with_three_hearts:.

Yes, you are right, I should be using the python string interpolation. However, the problem was also caused using the assertz in a different way (previously I was using the prolog class method).

Kind Regards,
Ferda