NextPrevUpTopContentsIndex

19.3.1 Starting a DDE server

To provide a LispWorks application with a DDE server, the following three steps should be followed: define a specialized server class using define-dde-server , provide the server class with the functionality it requires by specializing methods on it and/or using define-dde-server-function , and finally, start an instance of the server using start-dde-server

define-dde-server

Macro

define-dde-server class-name service-name

The macro define-dde-server defines a class for a Lisp DDE server. The class inherits from dde-server .

define-dde-server-function

Macro

define-dde-server-function name-and-options
 transaction
 (binding
*) 
                           form
*

The macro define-dde-server-function is used to define a server function, called name , which is called when a specific transaction occurs.

The defined function may either be attached to a server object (possibly only for a particular topic class) or to a dispatching topic object.

start-dde-server

Function

start-dde-server name

The function start-dde-server creates an instance of a server of the class specified by name which then starts accepting transactions. If successful the function returns the server, otherwise nil is returned.

You need to call start-dde-server in a thread that will process Windows messages. This can either be done by using capi:execute-with-interface to run it in the thread of an application's main window (if there is one) or by running it in a dedicated thread as in the example in the LispWorks Reference Manual . DDE callbacks will happen in this thread.

The next command line shows how to use define-dde-server to define a server class called foo-server that has the service name " FOO ".

(win32:define-dde-server foo-server "FOO")

It is usual to provide the new server class with some functionality. The next command illustrates how to define a server function called test , which takes a string as an argument, and prints this to the standard output. For convenience, the system topic is used, though usually it is better to define your own topic.

(win32:define-dde-server-function (bar :topic :system)
    :execute
    ((x string))
  (format t "~&~s~%" x)
  t)

Finally, a foo-server can be started using start-dde-server

(win32:start-dde-server `foo-server)

This function returns the server object, which responds to requests for conversations with the service name " FOO ", and accepts execute transactions for the function test in the "System" topic.


LispWorks User Guide - 11 Mar 2008

NextPrevUpTopContentsIndex