Excel VBA - SWI Prolog

405 views
Skip to first unread message

Carlos Diogo

unread,
Nov 10, 2014, 11:21:17 AM11/10/14
to swi-p...@googlegroups.com
Is that possible to connecto Excel VBA to SWI Prolog ?
I want to know if there's a connection that can allow to input a value (question) and define a rule in excel so anybody can do it (without knowing Prolog language), the excel vba code sends the information (question) to SWI Prolog and it answers the Excel VBA, filling other cells with the answer.

Anne Ogborn

unread,
Nov 10, 2014, 8:10:13 PM11/10/14
to Carlos Diogo, swi-p...@googlegroups.com
There are several ways to do this.

1. SWI-Prolog has DDE support.

http://swi-prolog.org/pldoc/man?section=DDE

I haven't done it in years, forget the details, but talking to Excel over DDE is easy, and either end can push data.

http://office.microsoft.com/en-us/excel-help/create-a-link-using-dynamic-data-exchange-dde-HP003066210.aspx



2. Use shell in Excel to start prolog and pipe data to it


3. Have SWI-Prolog listen on a localhost socket and use VBA to send data back and forth

4. use swicli to connect your SWI-Prolog program to C# and make a control in C#


I'd say #1 is the best solution.







________________________________
From: Carlos Diogo <cdio...@gmail.com>
To: swi-p...@googlegroups.com
Sent: Monday, November 10, 2014 8:21 AM
Subject: [SWIPL] Excel VBA - SWI Prolog



Is that possible to connecto Excel VBA to SWI Prolog ?
I want to know if there's a connection that can allow to input a value (question) and define a rule in excel so anybody can do it (without knowing Prolog language), the excel vba code sends the information (question) to SWI Prolog and it answers the Excel VBA, filling other cells with the answer.
--
You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+...@googlegroups.com.
Visit this group at http://groups.google.com/group/swi-prolog.
For more options, visit https://groups.google.com/d/optout.

Carlos Diogo

unread,
Mar 4, 2015, 6:48:01 PM3/4/15
to swi-p...@googlegroups.com, cdio...@gmail.com, anni...@yahoo.com
Hello Anne,

Thank you for your answer. I was unable to work on the project I'm doing for a few months but now I'm back on track.
Can you help me with some more information about the connection between Excel and Prolog with DDE ?
Can you give a simple example ?

Thanks in advance,

Cdiogo

Anne Ogborn

unread,
Mar 4, 2015, 7:39:08 PM3/4/15
to Carlos Diogo, swi-p...@googlegroups.com
This page

http://www.swi-prolog.org/pldoc/man?section=DDE


has an example for talking with program manager.

The example there is pretty straightforward.

Here's one for using Excel as a DDE server:

1. Start Excel without a document, (the default workbook is called Book1)
2. click in cell A1 and enter howdy
3. Click above in the named cell space and name the cell onions
4. start SWI-Prolog and do
6 ?- open_dde_conversation('Excel', '[Book1]Sheet1', C).
C = 3.to start a DDE conversation

make a request for the value in onions:

8 ?- dde_request(3, 'onions', X).
X = "howdy\r\n".

and close the conversation:
9 ?- close_dde_conversation(3).




________________________________
From: Carlos Diogo <cdio...@gmail.com>
To: swi-p...@googlegroups.com
Cc: cdio...@gmail.com; anni...@yahoo.com
Sent: Wednesday, March 4, 2015 3:48 PM
Subject: Re: [SWIPL] Excel VBA - SWI Prolog
Reply all
Reply to author
Forward
0 new messages