next up previous
Next: Miscellaneous Up: Windows DDE interface Previous: DDE client interface

DDE server mode

The (autoload) library dde.pl defines primitives to realise simple DDE server applications in SWI-Prolog. These features are provided as of version 2.0.6 and should be regarded prototypes. The C-part of the DDE server can handle some more primitives, so if you need features not provided by this interface, please study the library dde.pl.

dde_register_service( +Template, +Goal)

  Register a server to handle DDE request or DDE execute requests from other applications. To register a service for a DDE request, Template is of the form:
+Service(+Topic, +Item, +Value)
Service is the name of the DDE service provided (like progman in the client example above). Topic is either an atom, indicating Goal only handles requests on this topic or a variable that also appears in Goal. Item and Value are variables that also appear in Goal.

The example below registers the Prolog feature/2 predicate to be accessible from other applications. The request may be given from the same Prolog as well as from another application.

?- dde_register_service(prolog(feature, F, V),
			feature(F, V)).

?- open_dde_conversation(prolog, feature, Handle),
   dde_request(Handle, home, Home),
   close_dde_conversation(Handle).

Home = '/usr/local/lib/pl-2.0.6/'

Handling DDE execute requests is very similar. In this case the template is of the form:

+Service(+Topic, +Item)

Passing a Value argument is not needed as execute requests either succeed or fail. If Goal fails, a `not processed' is passed back to the caller of the DDE request.

dde_unregister_service( +Service)

  Stop responding to Service. If Prolog is halted, it will automatially call this on all open services.
dde_current_service( -Service, -Topic)

  Find currently registered services and the topics served on them.
dde_current_connection( -Service, -Topic)

  Find currently open conversations.



Passani Luca
Tue Nov 14 08:58:33 MET 1995