Progress
External Program
Interfaces


Closing DDE Conversations

You can close a DDE conversation in one of three ways:

Regardless of how you close a DDE conversation, once closed, the channel number for that conversation is no longer available for further exchanges. Terminating the conversation with the DDE TERMINATE statement has no effect on other conversations open for the same DDE server or frame. They continue without interruption.

In general, if your Progress client creates and manages a server environment for the conversation, it should also clean up that environment when closing the conversation. For example, the following code fragment cleans up a Microsoft Excel server environment when the user presses a QUIT button. The client removes an advise link to the worksheet and closes the conversation for that worksheet topic (sheet). Then using the System conversation (sys), it executes server commands that close the documents opened for the conversation, clear Excel error checking, and instruct the server to shut itself down:

DEFINE VARIABLE sys AS INTEGER.
DEFINE VARIABLE sheet AS INTEGER.

DEFINE BUTTON bq LABEL "Quit".
                    .
                    .
                    .
ON CHOOSE OF bq IN FRAME MainFrame  
DO:
                    .
                    .
                    .
  DDE ADVISE sheet STOP ITEM "r4c2".
  DDE TERMINATE sheet.
  DDE EXECUTE sys COMMAND "[activate(~"sheet1~")]".
  DDE EXECUTE sys COMMAND "[close(0)]" 0).
  DDE EXECUTE sys COMMAND "[activate(~"chart1~")]".
  DDE EXECUTE sys COMMAND "[close(0)]".
  DDE EXECUTE sys COMMAND "[error(0)]".
  DDE EXECUTE sys COMMAND "[quit()]".
END.
                    .
                    .
                    . 

Note the tilde (~) used to escape embedded quotes in strings—for example, ~"sheet1~".


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