简体   繁体   中英

Getting Result from a Prolog Query in C# using SWI-Prolog C#

I am writing a GUI for a prolog file using C# using SWI-Prolog, however I don't know how to get the solution from a query into some strings.

The query direct_evening_flight(london,edinburgh) in pl returns the some days of the week for instance Monday, Tuesday, Thursday.

If I execute the query in C#

PlQuery q = new PlQuery("direct_evening_flight(london,edinburgh).")

It automatically print the result into the console. However I want to receive the result one by one into a string variable instead. How can I do that?

You have to turn your direct_evening_flight/2 predicate into a direct_evening_flight/3 predicate where the last variable will hold the results from your query. This way the query won't output to the standard output but to this variable instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM