Prolog and VB 
Author Message
 Prolog and VB

Hello everyone,

I have a small problem on hand. I have to rewrite an old Prolog for DOS
application (Borland), this time to run in a Win9X environment.
Additionally, it would be better if the whole project be under a Visual
Basic umbrella, i.e. using a Prolog ActiveX, COM or DLL to interpret
existing rules.
Does this sound like asking too much? There are Prolog environments which, I
believe, could call VB libraries, but can that also be done the other way
around.

Thanks in advance,
Bruno VOISIN

(Please copy any reply to my personal email above)



Tue, 08 Jul 2003 17:51:31 GMT  
 Prolog and VB
"Bruno VOISIN"  wrote

Quote:
> ...
> There are Prolog environments which, I believe,
> could call VB libraries, but can that also be done the other way
> around.

Amzi Prolog is designed to interface with other languages,
including Delphi, C++, and Java.  I think that one of these
languages is Visual Basic, which is what you want.

I use Amzi Prolog in combination with Delphi.
I use an ".exe" file written in Delphi,
which calls a ".dll" containing the Amzi prolog interpreter.

Amzi gives me a bi-directional interface.
That is, I can call a Prolog prodedure from within Delphi,
and this Prolog procedure is able to call Delphi procedures.

So I start my Delphi program, which displays the GUI part
of my program.  When it needs to call Prolog, it does so.
If the Prolog procedure needs to display text
in a text-window displayed by the Delphi program,
then it calls a Delphi procedure to display the text.

I also found that its reasonably easy to learn how to combine these
languages using Amzi.

I expect that it can do the same sort of thing
using Visual Basic instead of Delphi.

Amzi is at http://www.amzi.com/

--
Martin Sondergaard,
London.



Wed, 09 Jul 2003 02:45:28 GMT  
 Prolog and VB
take XSB Prolog !
http://xsb.sourceforge.net/
there is a doc "How to Use XSB DLL from Visual Basic "

http://www.lambda-systems.com


Quote:
> Hello everyone,

> I have a small problem on hand. I have to rewrite an old Prolog for DOS
> application (Borland), this time to run in a Win9X environment.
> Additionally, it would be better if the whole project be under a Visual
> Basic umbrella, i.e. using a Prolog ActiveX, COM or DLL to interpret
> existing rules.
> Does this sound like asking too much? There are Prolog environments which,
I
> believe, could call VB libraries, but can that also be done the other way
> around.

> Thanks in advance,
> Bruno VOISIN

> (Please copy any reply to my personal email above)



Wed, 09 Jul 2003 08:04:17 GMT  
 Prolog and VB
Dear mr. Sondergaard (sounds quite Dutch),

I'm using Delphi and SWI-prolog, I need to use the DDE in that case but it
is horrible to get things done!

Do you have a simple example for me on how to let Delphi and AMZI work
together and do you know wether SWI-prolog and Amzi are compatible?

Greetz Johan



Quote:
> "Bruno VOISIN"  wrote

> > ...
> > There are Prolog environments which, I believe,
> > could call VB libraries, but can that also be done the other way
> > around.

> Amzi Prolog is designed to interface with other languages,
> including Delphi, C++, and Java.  I think that one of these
> languages is Visual Basic, which is what you want.

> I use Amzi Prolog in combination with Delphi.
> I use an ".exe" file written in Delphi,
> which calls a ".dll" containing the Amzi prolog interpreter.

> Amzi gives me a bi-directional interface.
> That is, I can call a Prolog prodedure from within Delphi,
> and this Prolog procedure is able to call Delphi procedures.

> So I start my Delphi program, which displays the GUI part
> of my program.  When it needs to call Prolog, it does so.
> If the Prolog procedure needs to display text
> in a text-window displayed by the Delphi program,
> then it calls a Delphi procedure to display the text.

> I also found that its reasonably easy to learn how to combine these
> languages using Amzi.

> I expect that it can do the same sort of thing
> using Visual Basic instead of Delphi.

> Amzi is at http://www.amzi.com/

> --
> Martin Sondergaard,
> London.



Wed, 09 Jul 2003 18:40:11 GMT  
 Prolog and VB


Quote:
> Dear mr. Sondergaard (sounds quite Dutch),

Its Danish.

Quote:
> I'm using Delphi and SWI-prolog, I need to use the DDE in that case but it
> is horrible to get things done!

> Do you have a simple example for me on how to let Delphi and AMZI
> work together ...

Yes, fairly simple.

Amzi gives you a Delphi component
that you add to the Delphi Visual Component Library.
They tell you how to put it there.
Then you add the component to the Delphi application you are writing,
just like a normal Delphi component.
You need to add the word "Amzi" to your "uses" clause.

This makes some extra functions available,
to allow you to call the Amzi Logic Server
from Delphi.
The Logic Server calls your Prolog program.

I started to explain this at length,
but my computer crashed,
so I'm having to re-write this e-mail!  :-(

Once your Amzi component is added to your
application, you can use a few functions
starting with "LS", which stands for "Logic Server".

You compile your Prolog program using the Amzi compiler,
to make a file with the extension ".xpl",
which is the compiled Prolog program.
Then from Delphi you tell the Logic Server to read in
the compiled program, using this line of code :

     ls.LoadXPL( 'MyProlog' ) ;  {Load "MyProlog.xpl".}

Then you can call any prolog procedure that you want,
at any time in your Delphi program.
For example :

     tf := ls.ExecPStr( t, 'initialise' ) ; {Initialise prolog program.}

In the example above, the prolog predicate being called is "initialise/0".
"tf" is a boolean variable.
If the prolog predicate succeeds then "tf" becomes true,
otherwise it becomes false.

"ExecPStr" stands for "Execute PString".
You use it to send a string to the Prolog interpreter,
to call a prolog procedure.

Here are some examples :

1.
     tf := ls.ExecPStr( t, 'initialise' ) ; {Initialise prolog program.}
     if not tf
             then MessageDlg( 'Prolog program has an error.', mtWarning,
                     [mbOk], 0 ) ;

2.
     tf := ls.ExecPStr( t, 'test_prolog( abc, def )' ) ;

3.
     Parameter1 := 'abc' ;
     Parameter2 := 'def' ;
     tf := ls.ExecPStr( t, 'test_prolog( '  + Parameter1 + ','
            + Parameter2 + ')'    ) ;

4.
     Parameter1 := 'abc' ;
     Parameter2 := RichEdit1.Lines[0] ;
     tf := ls.ExecPStr( t, 'test_prolog( '  + Parameter1 + ','
            + Parameter2 + ')'    ) ;

              ---------------------

Amzi's Help is written as HTML pages.
You can look in their Help files to see how to use
the "ls" functions.  Their Help is unfortunately
rather brief when describing these functions.
    Luckily Amzi include a few simple example
programs showing how to use them.
Thats how I found out how to use them.

Amzi Prolog used to be free for personal use,
and you pay for it if you use it for commercial use.
It probably still is.
So you can try it out for free.

              ---------------------

To call a Delphi procedure from Prolog...

First write the Delphi procedure.
Suppose that its named "my_delphi_proc".

Then use the following line of code to tell the Amzi Logic Server
that it should call this Delphi procedure
whenever it runs the Prolog predicate "my_prolog_proc" :

        ls.AddPred( 'my_prolog_proc', 2, my_delphi_proc ) ;

This line of code is all you need to make it
run "my_delphi_proc" whenever you run "my_prolog_proc".
The second parameter, "2", indicates that "my_prolog_proc" has
two parameters, so its "my_prolog_proc/2".

You only need to define this procedure in Delphi,
there is no need to define it in your Prolog source code file.

           ---------------

Here's a real example of a Delphi procedure
that I call from Prolog.
The predicate is called "x_writeln/1"
and it calls a Delphi procedure to display a string
by adding it to a RichEdit box, RichEdit1.

The Delphi procedure and the Prolog predicate
are both called "x_writeln".

uses ... Amzi ;

     ...
     ls.AddPred( 'x_writeln', 1, x_writeln );
     ls.LoadXPL( 'MyProlog' ) ;   {Load "MyProlog.xpl".}
     ...

function x_writeln ;
var
   t: TTerm ;
begin
              {Get the parameter of x_writeln/1
              and put it in variable "t".  }

              {Convert "t" to a string
              then add it to RichEdit1. }
          RichEdit1.Lines.Add( ls.TermToPStr( t ) ) ;
     end;
     Result := lsTrue ;
end;

    To use it from Prolog :

/* This code is in the file "MyProlog.xpl". */

/* Write some text. */
my_prolog_procedure1 :-
    x_writeln( 'This is line 1.' ),
    x_writeln( 'This is line2.' ),
    x_writeln( 'End.' ).

Note that some normal prolog commands like "write"
and "writeln" are not available from a prolog program
called from Delphi !  This is because there is no console
for the Prolog interpreter to write the text on.
So I have to use my own procedures to write text,
e.g. "x_writeln".

Quote:
> ... and do you know wether SWI-prolog and Amzi are compatible?

Yes, they are.
I converted a big program that I wrote
from SWI Prolog to Amzi Prolog.

The only significant difference that I noticed
is that SWI Prolog allows you to use nested comments,
but Amzi does not.
E.g. in SWI you can use "/* ...  /* ... */   */".
You will have to remove all your nested comments.
This took me quite some time,
because I removed a lot of code by commenting it out,
so I had many nested comments.

And as I mentioned above,
words like "writeln", "write" "nl" and "print"
do not work in prolog code called from Delphi.
You have to write your own procedures
like "x_writeln" to do the same job.

These words lead to a Delphi error-message.

--
Martin Sondergaard,
London.



Wed, 09 Jul 2003 23:54:53 GMT  
 Prolog and VB
LPA (Logic Programming Associate) provide a PROLOG implementation with and
add-on toolkit (Intelligence Sever) which provides a simple text based
interface between PROLOG and a number of Visual IDE including VB, Delphi,
Java and C++.


Quote:
> Hello everyone,

> I have a small problem on hand. I have to rewrite an old Prolog for DOS
> application (Borland), this time to run in a Win9X environment.
> Additionally, it would be better if the whole project be under a Visual
> Basic umbrella, i.e. using a Prolog ActiveX, COM or DLL to interpret
> existing rules.
> Does this sound like asking too much? There are Prolog environments which,
I
> believe, could call VB libraries, but can that also be done the other way
> around.

> Thanks in advance,
> Bruno VOISIN

> (Please copy any reply to my personal email above)



Thu, 10 Jul 2003 01:04:56 GMT  
 Prolog and VB
Thanks a lot for your interesting messages.

Bruno


Quote:
> Hello everyone,

> I have a small problem on hand. I have to rewrite an old Prolog for DOS
> application (Borland), this time to run in a Win9X environment.
> Additionally, it would be better if the whole project be under a Visual
> Basic umbrella, i.e. using a Prolog ActiveX, COM or DLL to interpret
> existing rules.
> Does this sound like asking too much? There are Prolog environments which,
I
> believe, could call VB libraries, but can that also be done the other way
> around.

> Thanks in advance,
> Bruno VOISIN

> (Please copy any reply to my personal email above)



Fri, 11 Jul 2003 22:28:40 GMT  
 Prolog and VB
LPA offers a 'simple' bi-directional interface to VB/Delphi/Java etc
using its Intelligence Server - check out:

http://www.lpa.co.uk/int.htm

Clive

Quote:

> Dear mr. Sondergaard (sounds quite Dutch),

> I'm using Delphi and SWI-prolog, I need to use the DDE in that case but it
> is horrible to get things done!

> Do you have a simple example for me on how to let Delphi and AMZI work
> together and do you know wether SWI-prolog and Amzi are compatible?

> Greetz Johan



> > "Bruno VOISIN"  wrote

> > > ...
> > > There are Prolog environments which, I believe,
> > > could call VB libraries, but can that also be done the other way
> > > around.

> > Amzi Prolog is designed to interface with other languages,
> > including Delphi, C++, and Java.  I think that one of these
> > languages is Visual Basic, which is what you want.

> > I use Amzi Prolog in combination with Delphi.
> > I use an ".exe" file written in Delphi,
> > which calls a ".dll" containing the Amzi prolog interpreter.

> > Amzi gives me a bi-directional interface.
> > That is, I can call a Prolog prodedure from within Delphi,
> > and this Prolog procedure is able to call Delphi procedures.

> > So I start my Delphi program, which displays the GUI part
> > of my program.  When it needs to call Prolog, it does so.
> > If the Prolog procedure needs to display text
> > in a text-window displayed by the Delphi program,
> > then it calls a Delphi procedure to display the text.

> > I also found that its reasonably easy to learn how to combine these
> > languages using Amzi.

> > I expect that it can do the same sort of thing
> > using Visual Basic instead of Delphi.

> > Amzi is at http://www.amzi.com/

> > --
> > Martin Sondergaard,
> > London.



Mon, 14 Jul 2003 22:00:46 GMT  
 Prolog and VB

"Clive Spenser" wrote :

Quote:
> LPA offers a 'simple' bi-directional interface to VB/Delphi/Java etc
> using its Intelligence Server - check out:

> http://www.lpa.co.uk/int.htm

> Clive

Clive Spenser works for LPA.
He should have mentioned that.

Last time I looked at LPA's prolog, it was very expensive.
You had to pay once for LPA Prolog,
and once for their interface to VB/Delphi/Java etc.

Amzi have only one price for their Prolog,
and this includes their interface to VB/Delphi/Java etc.
Also, its free for non-commercial use,
so some people are able to use it for free.

--
Martin Sondergaard,
London.



Tue, 15 Jul 2003 02:34:37 GMT  
 Prolog and VB
Yes !!! there is a way !!!

I made some programs using prolog and VB, the easieset way (I think) is
using swiprolog, it has a lot of tutorials on how to use swiprolog with
other progrmming languages such as VB, C++, java and so on.

Javier Porras



Quote:
> Hello everyone,

> I have a small problem on hand. I have to rewrite an old Prolog for DOS
> application (Borland), this time to run in a Win9X environment.
> Additionally, it would be better if the whole project be under a Visual
> Basic umbrella, i.e. using a Prolog ActiveX, COM or DLL to interpret
> existing rules.
> Does this sound like asking too much? There are Prolog environments which,
I
> believe, could call VB libraries, but can that also be done the other way
> around.

> Thanks in advance,
> Bruno VOISIN

> (Please copy any reply to my personal email above)



Fri, 08 Aug 2003 09:05:43 GMT  
 Prolog and VB
Sorry - I thought it was obvious from my email address:


Thnx for pointing it out, Martin.

Clive

Quote:

> "Clive Spenser" wrote :

> > LPA offers a 'simple' bi-directional interface to VB/Delphi/Java etc
> > using its Intelligence Server - check out:

> > http://www.lpa.co.uk/int.htm

> > Clive

> Clive Spenser works for LPA.
> He should have mentioned that.

> Last time I looked at LPA's prolog, it was very expensive.
> You had to pay once for LPA Prolog,
> and once for their interface to VB/Delphi/Java etc.

> Amzi have only one price for their Prolog,
> and this includes their interface to VB/Delphi/Java etc.
> Also, its free for non-commercial use,
> so some people are able to use it for free.

> --
> Martin Sondergaard,
> London.



Tue, 02 Sep 2003 21:18:44 GMT  
 
 [ 13 post ] 

 Relevant Pages 

1. SWI-Prolog - VB

2. Prolog & VB

3. Amzi!Prolog + VB onto Web ?

4. VB & PROLOG

5. Clearwin vs GINO vs Winteracter vs VB was: Fortran Conversion to MicroSoft VB

6. call vb dll (will pop up vb form) form python

7. PDC prolog and prolog++ (object-prolog)

8. Prolog Comparison Charts; Prolog Embeddings

9. SWI Prolog Vs GNU Prolog

10. SICStus Prolog + Java/Prolog + Jasper

11. A good free/trial prolog IDE for compiling and loading wordnet prolog database

12. Prolog Development Center - Visual Prolog

 

 
Powered by phpBB® Forum Software