Microsoft Windows makes it easy to exchange data between different applications. (The familiar clipboard is the simplest of these means.) Dynamic Data Exchange (DDE) is the most flexible method when there is a need to transfer data automatically.
DDE is a Microsoft Windows protocol that lets two or more programs running under Windows exchange data simultaneously. Windows for Workgroups has furthered DDEs reach by introducing the protocol into NetDDE communications, where getting black boxes to communicate with one another is often a struggle. NetDDE is a kind of universal super software glue. It lets MathViews cooperate with other Windows applications over the network. Thus enabling a building block approach to software.
DDE allows you to set up applications to pass both data and commands from one to the other. Normally one application requests the transfer and the other responds. The application that does the requesting is called the client application, and the application that responds is called the server. (This is not to be confused with the terms client and server as they are used internally within a database program or in a network of computers.) The information passing between client and server is called the conversation.
MathViews fully supports DDE both as a client and as a server. MathViews can pass commands to other applications, instructing them do such things as open files, select records, or transfer data to MathViews in various formats.
By "linking," you can arrange to have the other application inform MathViews whenever the linked data changes, or even have it automatically update MathViews whenever the linked data changes. Note that MathViews can be a DDE client and a DDE server simultaneously while still allowing you to perform normal user interface functions!
A DDE conversation establishes a relationship between applications that require a sustained communication, in which both data and commands are passed repetitively for long periods. MathViews is capable of acting as either client or server, and can even act as client in one conversation and simultaneously act as server in another.
A typical conversation follows a standard pattern:
Client requests information. Server supplies information. (This is a "cold link." It does not provide for updating of the transferred data.) Client requests data and also requests to be notified whenever the data changes. Server supplies the data and also notifies client, without having to be asked again, whenever the data changes. (This is a "warm link." It allow updates, but only if, and when, the DDE client application approves the transfer.) Client requests data and also requests automatic updates whenever the data changes. Server supplies information and updates that data, without having to be asked again, whenever the data changes. (This is a "hot link." It ensure that any updates in the source data, made after the transfer is complete, are automatically and immediately changed in the DDE client application also.)
Client successfully sends information, unsolicited, to the server. (This is a "poke.")
Client requests server to issue a server-specific command. Server carries out the command. (When information is identified as a command, it is interpreted literally, as instructions rather than as data.)
Because MathViews, and other advanced Windows applications are programmable, you will be able to write macros and programs which use specialized DDE commands to carry out these three activities.
If you want to transfer data dynamically from another application into MathViews, you make MathViews the DDE client. As described above, MathViews supports the three basic activities: Initiation, Exchange, and Termination.
These activities are supported by the five MathViews commands, which are described next. The "channel" over which the conversation takes place is "conv" in the syntax used by MathViews. Conv is a channel ID number. It must be obtain by the ddeconn command before any other commands can be used. The ID number is invalidated by the call to ddedisconn.
Syntax: conv = ddeconn(server,topic)
Description: The argument, conv, is the ID of the channel you are establishing. The argument, server, must be a string. It is the DDE name (as defined by the application itself) of the application from which you are requesting data. The argument, topic, must be a string. It describes the information to be transferred. See the DDE section of the server application for a list of available topics.
Returns: conv, a positive number. In case of error the return value is 1.
Syntax: ddereq (conv,item)
Description: The argument, conv, must have already been obtained by call to ddeconn. The argument, item, must be a string. It describes the information desired from the server application. See the DDE section of the server application for a list of available items.
Returns: data
Syntax: ddepoke (conv,item,data)
Description: The argument, conv, must have already been initiated by ddeconn. The argument, item, must be a string. It describes the location where the data is to be stored. The argument, data, is an expression containing the data to be sent. See the DDE section of the server application for a list of available items.
Syntax: ddeexec (conv,command)
Description: The argument, conv, must have already been initiated by ddeconn. The argument, command, must be a string. It contains the command to be sent to the other application. Some target applications can accept a series of commands within command
Syntax: ddedisconn (conv)
Description: The argument, conv, must have already been initiated by ddeconn. This call terminates the conversion/channel. You should not reference conv after this call.
The following examples shows how MathViews might be used to establish a conversation with the Microsoft Excel spreadsheet. In this example, MathViews is the client and Excel is the server. Details on how to use Excel as a server are contained in the Excel documentation.
_loaddll mathvdde load the MathViews DDE library
!f:\excel\excel f:\excel\sheet1.xls have MathViews start the Excel application
hconvs=ddeconn('excel','System') name server (excel), conversation (through System)
hconv=ddeconn('excel','Sheet1.xls') name server (excel) and topic
x=ddereq(hconvs,'Formats') request information on formats
x=ddereq(hconv,'R3C4') request item
x=ddereq(hconv,'R3C2:R3C4') request another item
ddeadvise(hconv,'R3C4','x') request update or notification if change in item (link)
When MathViews is operating as the DDE server, the conversation is initiated by the other application, which acts as the client. The specific commands depend on the client's programming, but they should follow DDE conventions generally, and we shall assume here that they do.
To set up a conversation with MathViews, the client must know the following things about MathViews: MathViews' application name (MathViews) A Topic name such as "MathViews."
After the channel is set up, there are four ways to pass information to MathViews:
MathViews supplies the following Topics support:
The demo directory of MathViews contains an example of a Microsoft Excel macro to communicate with MathViews.
Maximizing Windows
Jim Boyce
Dynamic Data Exchange
New
Writers Publishing
Windows Software Development Kit
Dynamic Data Exchange
Microsoft
Corporation
Programing Windows
Charles Petzold
Microsoft Press
Windows Programming Guide To OLE/DDE
Jeffrey Clark
Sams