signal107
signal107

Reputation: 43

Is it possible to run prolog from C#?

I want to call a prolog program from C#. Is that possible? I process the user input by c# and write into a file. I then want to call a prolog program which uses that file, then I want to show the content of the file to the user by c#.

Upvotes: 2

Views: 624

Answers (2)

joel76
joel76

Reputation: 5605

If you use SWI-Prolog, you should google SWI-Prolog interface to C# and F#

Upvotes: 1

Marged
Marged

Reputation: 10953

Yes, if you don't want to link the two programs to a single binary but simply have one (C#) call the other (prolog) this can be done. And for any other language you can run on your computer too.

If you base your data exchange on files you need one file to send data from C#->prolog and perhaps a second one to return the result (prolog->C#)

You will find lots of examples to make C# call an external program here on SO (for example Launching an application (.EXE) from C#?)

If prolog does not allow you to pass the filename as parameter when you call it you will have to work with fixed filenames:

C# writes a request.txt C# calls prolog program Prolog reads request.txt and creates response.txt

Reading from files should be covered by the language, depending on the "dialect" even reading command line parameters should be.

Upvotes: 1

Related Questions