17.2.3 Advise loops

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.



dde-advise-start conversation
 &key key

The dde-advise-start function sets up an advise loop for the data item specified by item on the specified conversation .


Generic Function

dde-client-advise-data key item data &key &allow-other-keys

The generic function dde-client-advise-data is the default function called when an advise loop informs a client that the data monitored by the loop has changed. By default it does nothing, but it may be specialized on the object used as the key in dde-advise-start or dde-advise-start* , or on a client conversation class if the default key is used.



define-dde-client name &key service class

The macro define-dde-client defines a mapping from the symbol name to the DDE service name with which to establish a conversation, and the conversation class to use for this conversation. The argument service is a string which names the DDE service. It defaults to the print-name of name . The argument class is a subclass of dde-client-conversation which is used for all conversations with this service. It defaults to dde-client-conversation . Specifying a subclass allows various aspects of the behavior of the conversation to be specialized.

The following is an example of how to set up an advise loop. The first step defines a client conversation class, called my-conv .

(defclass my-conv (dde-client-conversation)

The function 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 " FOO ".

(win32: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.

(defmethod dde-client-advise-data ((self my-conv) item data &key 
  (format t "~&Item ~s changed to ~s~%" item data))

Finally, the next command starts the advise loop on the server foo , with the topic name " file1 ", to monitor the item " slot1 ".

(win32: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-start 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

The arguments key and item identify the advise loop, or link. The argument data contains the new data for hot links; for warm links it is nil .

Advise loops are closed using dde-advise-stop or dde-advise-stop* .



dde-advise-stop conversation
 &key key

The function dde-advise-stop removes a particular link from conversation specified by item , format and key . If key is the last key for the item / format pair, the advise loop for the pair is terminated.

LispWorks User Guide - 8 Apr 2005