A LispWorks client can open a conversation by using dde-connect, which takes a service designator and a topic designator as its arguments. If successful, a conversation object is returned which can be used to refer to the conversation. Conversations are closed by the LispWorks client at the end of a transaction by using dde-disconnect.
Another method for managing conversations uses with-dde-conversation to bind a conversation with a server across a body of code. If no conversation is available for with-dde-conversation, then one is automatically opened. The code is executed and the conversation is closed after the body of code exits.
There is an alternative to manually establishing a conversation and then disconnecting it once all transactions between server and client are concluded: the automatically managed conversation. Client functions that end with a
* conduct automatically managed conversations.
A function handling an automatically managed conversation takes a service designator and topic designator as two of its arguments, and either automatically establishes a conversation with a server responding to the service designator/topic designator pair, or uses an existing equivalent conversation. For the purpose of brevity, functions conducting automatically managed conversations are only briefly mentioned in this chapter. For the details see dde-advise-start*, dde-advise-stop*, dde-execute*, dde-execute-command*, dde-execute-string*, dde-item*, dde-poke* and dde-request*.
A LispWorks client can set up an advise loop across a conversation using dde-advise-start, which takes a conversation (or a service designator/topic designator pair in the case of an automatically managed conversation using dde-advise-start*), an item, and a key as its main arguments. The key argument defaults to the conversation name, and can be used to distinguish between multiple advise loops established on the same service/topic/item group.
Whenever the data monitored by the advise loop changes, a function is called to inform the client. By default this function is the generic function dde-client-advise-data. You can add methods to dde-client-advise-data specialized on the key or the client conversation class. Alternatively, you can supply a different function in the call to dde-advise-start.
The macro define-dde-client can now be used to define a specific instance of the
my-conv class for referring to a server application that responds to the service name "
(define-dde-client :foo :service "FOO" :class my-conv)
The next step defines a method on dde-client-advise-data which returns a string stating that the item has changed.
(dde-advise-start* :foo "file1" "slot1")
When the value of the item specified by "
slot1"" changes, the server calls dde-client-advise-data which returns a string, as described above.
The function argument of dde-advise-start and dde-advise-start* specifies the function called by the advise loop when it notices a change to the item it is monitoring. The function is dde-client-advise-data by default. A different function can be provided, and should have a lambda list similar to the following:
key item data &key conversation &allow-other-keys
LispWorks clients can issue request and poke transactions across a conversation using dde-request and dde-poke, which take a conversation (or a service designator/topic designator pair in the case of an automatically managed conversation), and an item as their main arguments. In the case of a poke transaction, data to be poked into item must also be provided.
A client can issue an execute transaction across a conversation, or in the case of an automatically established conversation, to a recognized server. There is no need to specify a topic, as an execute transaction instructs the server application to execute a command.
The command and its arguments are issued to the server in the form of a string in a standard format (see Execute transactions). LispWorks provides two ways of issuing an execute transaction, namely dde-execute-string and dde-execute-command (and the corresponding
* functions that automatically manage conversations).
The following example shows how dde-execute-string* can issue a command to a server designated by
:excel on the topic
:system, in order to open a file called
(dde-execute-string* :excel :system "[open(\"foo.xls\")]")
The function dde-execute-command takes the command to issue, and its arguments, and marshals these into an appropriate string for you. The following example shows how dde-execute-command* can issue the same command as in the previous example:
(dde-execute-command* :excel :system `open `("foo.xls"))
LispWorks User Guide and Reference Manual - 20 Sep 2017