wxCLIP function groups: Server, Connection, Client.
wxCOOL classes: wxServer, wxConnection, wxClient.
The following describes how wxCLIPS implements DDE. The following three classes are central.
Messages between applications are usually identified by three variables: connection object, topic name and item name. A data string is a fourth element of some messages. To create a connection (a conversation in Windows parlance), the client application sends the message client-make-connection to the client object, with a string service name to identify the server and a topic name to identify the topic for the duration of the connection. Under UNIX, the service name must contain an integer port identifier.
The server then responds and either vetos the connection or allows it. If allowed, a connection object is created which persists until the connection is closed. The connection object is then used for subsequent messages between client and server.
To create a working server, the programmer must:
To create a working client, the programmer must:
Data transfer
Connection overview
Examples
These are the ways that data can be transferred from one application to another.
The default data type is wxCF_TEXT (ASCII text), and the default data size is the length of the null-terminated string. Windows-specific data types could also be used on the PC.
Interprocess communication overview
A connection object has no creation function, since it is implicitly created when a connection is requested (one object at each side of the connection).
A connection object id is used for initiating DDE commands and requests using functions such as connection-execute, and it also has event handlers associated with it to respond to commands from the other side of the connection.
The callbacks you can define for a connection (using window-add-callback) are as follows.
See the sample programs ddeserv.clp, ddeclien.clp in the examples directory. Run the server, then the client (you'll have to copy wxclips.exe to wxclips2.exe to run two copies simulataneously).
The sample ddetest.clp shows a simple example of accessing the Program Manager using DDE (Windows only).
;;; Demo of DDE functions: chatting to PROGMAN ;;; (defglobal ?*progman-server* = 0) (defglobal ?*progman-server-name* = "PROGMAN") (defglobal ?*progman-host-name* = "none") (defglobal ?*progman-topic-name* = "PROGMAN") (defglobal ?*progman-client* = 0) (defglobal ?*progman-connection* = 0) ;;; Convert a multifield list of strings to one string (deffunction many-strings-to-one ($?strings) (bind ?counter 1) (bind ?string "") (while (<= ?counter (length $?strings)) do (bind ?string (str-cat ?string (nth ?counter $?strings))) (bind ?counter (+ ?counter 1)) ) (return ?string) ) (deffunction progman-demo () ;; Get a group name from the user (bind ?new-group-name (get-text-from-user "New PROGMAN group name")) (if (neq ?new-group-name "") then ;; Form create group command (bind ?command (many-strings-to-one (mv-append "[CreateGroup(" ?new-group-name ")]"))) ;; Construct a client object (bind ?*progman-client* (client-create)) ;; Construct a connection object (bind ?*progman-connection* (client-make-connection ?*progman-client* ?*progman-host-name* ?*progman-server-name* ?*progman-topic-name*)) ;; Execute a command to create a group (bind ?exe (connection-execute ?*progman-connection* ?command)) ;; Request a list of groups (bind ?req (connection-request ?*progman-connection* "PROGMAN")) (format t "%nProgram Manager Groups:%n") (format t "%s%n%n" ?req) ;; Disconnect (connection-disconnect ?*progman-connection*) ) ) ;;; Automatically called when running application from command line ;;; e.g. wxclips -start -clips ddetest.clp ;;; Also runnable from the Application: Run application. (deffunction app-on-init () (progman-demo) )