LispWorks User Guide and Reference Manual > 18 Dynamic Data Exchange > 18.2 Client interface > 18.2.3 Advise loops

NextPrevUpTopContentsIndex

18.2.3.1 Example advise loop

The example shows you how to set up an advise loop. The code assumes that win32 package symbols are visible.

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 ".

(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 
&allow-other-keys)
  (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 ".

(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

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*.


LispWorks User Guide and Reference Manual - 22 Dec 2009

NextPrevUpTopContentsIndex