Discussions related to Visual Prolog
l_jam
Posts: 3
Joined: 30 May 2013 13:42

Calling Visual Prolog from C

Unread post by l_jam »

Hello! I have a programme written in Visual Prolog that I would like to use with a robot that understands only C. How can I call a Visual Prolog programme from C?
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

I suppose that you want to do more than just start the Visual Prolog program?

Which interaction do you want/need between the two programs?
Do you have the sources for the Visual Prolog program or just the program?
Regards Thomas Linder Puls
PDC
User avatar
George
Active Member
Posts: 47
Joined: 19 Sep 2011 8:54

Unread post by George »

Kind Regards,
George Ananth. S | Prolog Developer
georgeananth.prolog@gmail.com
+91 9791499282
l_jam
Posts: 3
Joined: 30 May 2013 13:42

Re:

Unread post by l_jam »

Thomas Linder Puls wrote:I suppose that you want to do more than just start the Visual Prolog program?

Which interaction do you want/need between the two programs?
Do you have the sources for the Visual Prolog program or just the program?
The prolog program receives some input data (a .txt file), processes it, then returns the result (as a different .txt file). So, the C program has to send the input data to Prolog and then recieve the output from it.
I have all the sources.
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

l_jam wrote:
Thomas Linder Puls wrote:I suppose that you want to do more than just start the Visual Prolog program?

Which interaction do you want/need between the two programs?
Do you have the sources for the Visual Prolog program or just the program?
The prolog program receives some input data (a .txt file), processes it, then returns the result (as a different .txt file). So, the C program has to send the input data to Prolog and then recieve the output from it.
I have all the sources.
In that case, it is actually C problems not Visual Prolog problem:
  1. Write the data to the txt file
  2. Start the Visual Prolog program
  3. Wait for termination of the Visual Prolog program
  4. Read the resulting txt file
I believe it is number 2 and 3 that cause problems.

In Visual Prolog (in useExe and syncObject) 2 and 3 are implemented by means of:
  • CreateProcess which is not exactly the simplest function imaginable.
  • The last argument contains a process handle that can be used with for example WaitForSingleObject to wait for program termination.
But there may be other mwans awailable in your C libraries.
Regards Thomas Linder Puls
PDC
l_jam
Posts: 3
Joined: 30 May 2013 13:42

Unread post by l_jam »

Thomas, George, thank you for your replies. I will try your advice.
Post Reply