ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ DB/C Newsletter ³ ³ October 1993 ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ Editor's Notes Subject, Wills & Company is investigating the possibility of moving the DB/C BBS to the Internet. If we do this, we will still offer a dial-up line in our Oak Brook offices, but the interface will not be the existing BBS. If there is interest, we might also offer access into the Internet (there would be a fee for this service). Another aspect of moving to the Internet is that E-mail could originate anywhere that can send mail to the Internet and SWC could send mail back to your electronic address (which might be on Compuserve, America Online, etc.). What do you think? Please send your thoughts to the Sysop on the DB/C BBS. The topic for this month's newsletter is Windows Dynamic Data Exchange. DDE is the protocol by which many client/server software products communicate. It is currently available on Windows, Windows NT and OS/2. The only version of DB/C that currently supports DDE is the Windows 3.1 version, but support for other platforms will be added in the future. I hope that this discussion helps you understand DDE a little better. DNW Dynamic Data Exchange Microsoft Windows provides a program-to-program communications facility known as Dynamic Data Exchange (DDE). DDE provides a way for Windows programs to exchange data and execute procedures in other programs. These exchanges are implemented with a client/server arrangement where the DDE server provides data and other services based upon requests from the DDE client program. I. A DDE server provides the following services to a DDE client: 1. send data as a response to a query (DATA) 2. notify a client that a change in data has occurred (ADVISE) 3. send data to a client containing changed values (ADVISE) 4. allow a client to change the value of items 5. execute a series of instructions given by a client II. A DDE client can issue the following instructions to a DDE server: 1. request the value of a particular data item (REQUEST) 2. request to be notified whenever a data item's value changes (WARMLINK) 3. request to be sent the new value of a data item whenever it changes (HOTLINK) 4. instruct a server to discontinue notification messages for a data item (UNLINK) 5. request that a server execute a series of commands (EXECUTE) 6. instruct the server to change the value of a data item (DATA) Connections between a DDE server and a DDE client are based upon an application name and a topic name. The application name is usually related to the name of the server program. For instance, the application name for the program Microsoft Excel is 'Excel'. The topic name for a DDE conversation refers to the category of information that will be exchanged. In the case of Microsoft Excel, the topic could be the name of the worksheet or data file. The DB/C code to establish a DDE connection is a follows: For a DDE server: dde device prep dde,"DDESERVER!appname!topicname" For a DDE client: dde device prep dde,"DDECLIENT!appname!topicname" where 'appname' is the application name and 'topicname' is the topic name. When a connection has been established between the client and server based on an application name and topic name, the client can obtain information about data items or cause the server to execute a series of commands. The client refers to specific data item by an item name. For our Excel example, one use for the item name would be to refer to a specific cell in the worksheet. The item name 'r5c6' refers to value in the worksheet cell in row 5, column 6. The following code establishes a DDE connection to an Excel worksheet named 'Sheet1' and queries the value of the cell 'B9' (row 9, column 2). dde device data char 20 msgq queue size=120 msgdata list header char 8 function char 4 appname char 32 topicname char 32 item char 22 data char 20 listend prep dde, "DDECLIENT!Excel!Sheet1" link dde, msgq change dde, "REQUEST.r9c2" wait msgq get msgq; msgdata close dde A DDE client can also request the DDE server to change the value of a data item. The DDE client does this by sending a DATA message for a specific item. In other documentation, this operation is referred to as a POKE operation. This sample code changes the value in row 9, column 2 in 'Sheet1' to "123": dde device prep dde, "DDECLIENT!Excel!Sheet1" change dde, "DATA.r9c2"; "123" As mentioned earlier, a DDE client can also request to be notified when a data value changes. The DDE client accomplishes this by establishing a warm or hot link. When a warm link is active, the server to notifies the client whenever data has changed. A hot link is the same as a warm link except that the notification message includes the new data value. DB/C stores the notification messages resulting from warm links and hot links in a DB/C queue variable. The following code sets up a hot link with cell 'A1' (row 1, column 1) of the Excel worksheet named 'Sheet1'. Whenever the value of this cell changes, the new value is printed. The code uses the data variables declared in the examples above. prep dde, "DDECLIENT!Excel!Sheet1" link dde, msgq change dde, "HOTLINK.r1c1" loop wait dde get dde; msgdata print "DDE Message ", data repeat A DDE client can request a DDE server to execute a series of commands. For example, a DDE client connected to Excel might want to cause Excel to open an existing worksheet. The following example causes Excel to open a worksheet named 'datafile.xls' by using the special topic name 'System'. prep dde, "DDECLIENT!Excel!System" change dde, "EXECUTE"; "[open(#"datafile.xls#")]" DB/C programs can also be DDE servers. A DDE server program may receive a variety of requests from one or more DDE clients. A typical DDE server must keep track of warm and hot links. Additionally, a server must be able to respond to requests for item values, to changes to item values, and to execute commands given by the client. The only type of messages that can be returned to a client program from a DDE server are DATA and ADVISE messages. A DATA message return the value of an item. An ADVISE message that notify the client that an item value has changed. Refer back to the sample code that defines the 'msgdata' list variable. The variable named 'header' will always contain the string "DDEMSG ". The variable named 'function' will contain a value appropriate to the message being sent. The variable named 'item' contain the item name, if applicable. For a server, the values of the variable 'function' may be: "REQU" client requests the value 'item' "DATA" client requests server to change value of 'item' to the value in 'data' "HOTL" client requests establishment of a hot link with 'item' "WARM" client requests establishment of a warm link with 'item' "NOLI" client requests discontinuance of a warm or hot link with 'item' "EXEC" client requests server to execute the commands in 'data' For a client, the values of the variable 'function' may be: "DATA" server is returning requested information about 'item' in 'data' "ADVI" notification that 'item' value has changed, 'data' is value if hot link There are two limitations in the current implementation of DDE in DB/C: 1. DB/C does not support timeout values for DDE operations. 2. DB/C attempts to automatically acknowledge most DDE messages received by clients and servers. Therefore, a DDE server or client has no opportunity to notify or be notified if a referenced item does not exist. DB/C Class Schedule The next DB/C classes scheduled for January. The classes are held in the Oak Brook, Illinois office of Subject, Wills & Company. For more information, contact Judi Tamkevic at (708) 572-0240.