The idea of the application, topic, and item is best approached with an example. In this chapter, I'll show you how to write a Windows DDE server program called DDEPOP. This program contains population data of the United States from the 1970 census and 1980 census. Based on a linear extrapolation, the program can calculate the instantaneous (”at this moment“) population of any state or of the United States as a whole. (A linear extrapolation is not quite accurate, of course, but then again, this is only a sample program.)
Anybody who writes a DDE server program should document how this data is identified using three character strings:
The server application name: In this example, this is simply ”DDEPOP.“ Each server has only one application name, the name of the program.
The topic name: All DDE servers support at least one topic. In the case of DDEPOP, only one topic is supported, which is identified by the string ”US_Population.“ Conceivably, the DDEPOP program could be expanded to include data concerning the square-mile areas of the states, in which case the program would support a second topic named ”US_Area.“
The item name: Within each topic, a DDE server supports one or more data items. In DDEPOP, the item identifies the state using the standard two-character post-office abbreviation, such as ”NY“ for New York, ”CA“ for California, and ”US“ for the total. DDEPOP supports 52 items—the 50 states, the District of Columbia (”DC“), and the total.
This documentation is sufficient to use the DDEPOP server with another Windows program that can act as a client, for example, Microsoft Excel. To use DDEPOP with Microsoft Excel, you can type the following into a spreadsheet cell:
=DDEPOP|US_Population!US
These three strings indicate the application, topic, and item (in this case, the total United States population). If DDEPOP.EXE is not already running, Microsoft Excel will attempt to execute it. (DDEPOP must be in the current directory or in a directory listed in the PATH environment variable.) If successful, Excel will initiate a DDE conversation with DDEPOP, obtain the population data, and display the population as a number in the cell. These population figures can be formatted, graphed, or used in calculations.
What's most interesting is that the population figures will be periodically updated in the spreadsheet. This is known as a ”hot link“ or (in a slight variation) ”warm link.“ Every 5 seconds, DDEPOP recalculates the population data and notifies a client when an item has changed. In the case of the total U.S. population, you'll see the figure increase by 1 about every 15 seconds.