>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help User

# DDE Overview

Dynamic Data Exchange allows Windows programs to communicate with each other.

DDE allows two Windows programs to exchange data by posting messages to each other using a standard protocol. J provides a comprehensive set of DDE commands so that you can communicate between J and any other Windows program supporting DDE, including another copy of J. You may have up to 20 DDE conversations at a time.

For example, with DDE you could set up J as a calculation server, so that another Windows program could send it a sentence for evaluation and receive back the result.

The DDE interface uses the Window Driver. Messages are sent with Window Driver commands, for example:

       wd 'ddereq jserver calc res'

Messages are received as a Windows event, and require handlers, named `sys_eventname`, for each event.

For example, here is a typical result of `wd'q'`, following a ddepoke event:

       wdq
    +----------+-----------+
    |syshandler|sys_handler|
    +----------+-----------+
    |sysevent  |sys_ddepoke|
    +----------+-----------+
    |sysdefault|sys_default|
    +----------+-----------+
    |systopic  |top        |
    +----------+-----------+
    |sysitem   |item       |
    +----------+-----------+
    |sysdata   |+/\i.10    |
    +----------+-----------+

To respond to a `ddepoke`, you define a handler named `sys_ddepoke`, for example the following is used in file `system\packages\dde\server2.ijs`:

    sys_ddepoke=: 3 : 0
    sysdata=: sysdata -. CRLF,TAB
    write0 sysdata
    if. sysdata -: 'exit' do. return. end.
    if. sysdata -: 'off' do.
      delay 1
      signoff ''
    end.
    try. val=: ".sysdata
    catch. val=: 'unable to execute: ',sysdata end.
    if. FORMAT do. val=: ":val end.
    write1 val
    topitem=: topitem,systopic;sysitem;<val
    )

Most Windows applications support DDE in some form or another. However, not all applications support the complete set of DDE commands, and in some cases the command usage is not standard. With J, you write programs to handle the DDE interface, and therefore you can tailor the J side of the protocol to fit the other application's requirements.

In this chapter we discuss general principles of DDE with examples of a J to J DDE link, and then discuss a link between J and Microsoft Word for Windows. Several other examples, including a link to Microsoft Visual Basic will be found in the directory: system\examples\dde.

>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help User