Overview of using DDE
Dynamic data exchange (DDE) enables two applications running on the same machine to exchange information. DDE can be used to automatically update data used by one application whenever data changes in another application. Not only can the DDE feature be used to exchange data between two VA Smalltalk applications, it can also be used to enable a VA Smalltalk application to communicate with commercial software programs, such as spreadsheet or graphics packages.
For example, you can use DDE to send data from a VA Smalltalk application to a spreadsheet. As users of your VA Smalltalk application change data values, these changes can be automatically reflected in the spreadsheet. Or, DDE can be used to bring information such as up-to-the-minute international exchange rates into a VA Smalltalk application.
The following information is also available:
Creating DDE clients and servers
A DDE client application requests and receives data from server applications. In contrast, a DDE server application uses DDE to send data to applications that have registered an interest in that data. Because DDE provides two-way communication between client and server applications, the distinctions can be somewhat vague, but here are some differences to note:
• A DDE Server part makes your VA Smalltalk application a DDE server application. Likewise, a DDE Client part makes your VA Smalltalk application a DDE client application. These parts do not represent other DDE client or server applications.
• A DDE server application can send values to several DDE client applications.
If you want to provide information to many different applications, create a DDE server application.
• A DDE server application must be started before the client application can communicate with it.
If you want your VA Smalltalk application to start another application, create a DDE client application.
• A DDE client application typically cannot send values to multiple applications.
VA Smalltalk DDE Client parts can communicate with only one server about one topic. However an application can use any number of DDE Client parts, and any number of DDE Server parts.
Identifying information to DDE
DDE uses four strings to identify all of the information you want to exchange:
Server name
The name of the server as identified by the server application. It is recommended that the server name be the same as the name of the server application. For example, the server name for the Microsoft Excel product is "Excel."
Topic
A logical grouping of the items that the server can provide. You can choose any grouping you want.
A server can have an unlimited number of topics.
Item
The name of a value that the server can provide.
Topics can have an unlimited number of items.
Format
The name of the
data formats of the items that the server can provide. For example, the server can provide a string item or a Smalltalk object item.
Items can have multiple formats.
Data formats for DDE
For both DDE Client and DDE Server parts, the following list explains some commonly used data formats:
string
Both DDE Client and DDE Server applications can send and receive strings. When in doubt, use string as your data format, such as when connecting from Text parts or connecting to commercial applications.
Smalltalk object
Any Smalltalk object can be used. For this format to be effective, however, the client and server applications must be VA Smalltalk applications and must contain the classes of all objects being transferred. For DBCS strings, use Smalltalk object. The Smalltalk object cannot be larger than 64K bytes in order for it to be transferred successfully.
all other formats
Must be an instance of the class ByteArray. Some Smalltalk objects respond to asBytes to create these instances. If you have a server application that uses a bitmap format, then it must represent that bitmap as a ByteArray for it to be used with a VA Smalltalk application. VA Smalltalk applications send bitmaps as a block of memory containing the contents of the ByteArray.
Size limitations
DDE permits the transfer of many kinds of data. One limitation of DDE, however, is that the size of the data must be less than 64K bytes. Because each data transfer adds some additional header information to the data you are sending, the maximum object sizes are as follows:
• For a Windows application, approximately 65529 bytes.
The transfer of data will fail if your application tries to transfer an object larger than 64K bytes in size. The value of the lastTransferError attribute will change when an application tries to send an object larger than 64K bytes in size.
Connections and links with DDE
For applications to exchange data using DDE, the following must occur:
1. The DDE server application must be running before the DDE client application attempts to exchange data with it.
There are several attributes on the DDE Client part that enable you to start the DDE server application with the appropriate parameters, such as startProgramName and startServerExectuteString.
2. A communication connection must be made to establish which applications communicate with one another and what topic they will use.
A communication connection is made for a single topic and a single server name. Within VA Smalltalk, you specify the server name and topic in the Settings window for the DDE Client or DDE Server part.
The DDE client application must make the communication connection. You can use the connect action of a DDE Client part to make the connection. If an application needs to communicate on more than one topic, you need to make at least one connection for each DDE Client part.
3. A link must be made to transfer the actual data items.
When you make attribute-to-attribute connections between the items of a DDE Client or DDE Server part and the visual parts of your window, VA Smalltalk automatically creates the links necessary to transfer the data.