Progress
External Program
Interfaces


Demand-driven Exchanges

In a demand-driven exchange, the Progress client sends data to or requests data from the server, and waits for each exchange to complete before continuing. The DDE EXECUTE, DDE REQUEST, and DDE SEND statements all invoke demand-driven exchanges.

Execute Exchanges

You can use the DDE EXECUTE statement to send commands for the DDE server to execute, as shown previously in the "Initiating a Conversation" section. Typically, you send server commands in a conversation opened for the System topic of the server application. However, the server might support commands for any topic that it provides. For example, Excel lets you select a range of cells (data items) in a worksheet topic. In effect, server commands are data items that it executes when sent with the DDE EXECUTE statement. For a more complete example of this type of exchange, see the "Closing DDE Conversations" section.

The System topic for your server application might also provide other data items that you can read or set using request and send exchanges. These data items typically provide server options or status information to the client.

Request and Send Exchanges

You can use the DDE REQUEST statement to retrieve any server data item as a character string value. If you plan to convert the string value to another Progress data type (for example, DATE), you must convert the string to the correct format.

You can use the DDE SEND statement to send a character string value to any server data item. You must ensure that the string conforms to a format acceptable to the server data item.

You might use request and send exchanges to create new database records from the rows of a worksheet, or iteratively read a Progress database and fill out worksheet rows from selected records. For example, the following code fragment fills out an Excel worksheet using three fields from the customer table of the sports database:

DEFINE VARIABLE rowi AS INTEGER.
DEFINE VARIABLE sheet AS INTEGER.
DEFINE VARIABLE itemn AS CHARACTER.
              .
              .
              .
DDE SEND sheet SOURCE "Name" ITEM "r1c1".
DDE SEND sheet SOURCE "Balance" ITEM "r1c2".
DDE SEND sheet SOURCE "State" ITEM "r1c3".
rowi = 2.
FOR EACH customer WHERE balance > 10000 BY balance:
  itemn = "R" + STRING(rowi) + "C1".
  DDE SEND sheet SOURCE customer.name ITEM itemn.
  itemn = "R" + STRING(rowi) + "C2".
  DDE SEND sheet SOURCE STRING(customer.balance) ITEM itemn.
  itemn = "R" + STRING(rowi) + "C3".
  DDE SEND sheet SOURCE STRING(customer.state) ITEM itemn.
   
  rowi = rowi + 1.
END. 

In the example, the first three DDE statements send column titles to the first three columns of the first row of the worksheet. Then, for each customer record showing more than $10,000 in payables, the DDE statements send the customer’s name, balance, and state of residence to the appropriate columns of the next row in the worksheet.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095