dmh_dde Tcl Command

NAME

dmh_dde - dynamic data exchange support for Win32

SYNOPSIS

::dmh::dmh_dde help

::dmh::dmh_dde init ?service?

::dmh::dmh_dde end

::dmh::dmh_dde connect service topic

::dmh::dmh_dde disconnect hconv

::dmh::dmh_dde execute hconv command ?timeout_msecs?

::dmh::dmh_dde poke hconv item data ?timeout_msecs?

::dmh::dmh_dde query ?service? ?topic?

::dmh::dmh_dde request hconv item ?timeout_msecs?

::dmh::dmh_dde service ?hconv?


DESCRIPTION

The dmh_dde command is implemented in Win32 versions of the Tcl/Tk software provided by Hume Integration Software. The command pre-dates the recent addition of the dde command to the publically available Tcl/Tk version. The command can be used to integrate commercially available Windows software such as web browsers, fax applications, databases, spreadsheets, or speech applications with your Tcl applications.

The command dmh_dde help returns a short usage summary of the dmh_dde command.

The command dmh_dde init is called to initialize the dde package and enable external DDE communication between the interpreter and other DDE applications. The interpreter becomes a DDE server for the service name argument. If no service name is supplied, the package uses the name of the program from the program's command line. With the usual Hume Integration Software installation for Windows, the startup file $dmh_library/init.tcl executes dmh_dde init. This is done to enable the Tk send command, and the winfo interps command. In the role of a DDE server, the interpreter's topic name is tcl74. The send command interoperates with earlier releases of the Tcl/Tk software starting with Tcl 7.4.

The command dmh_dde end is used to recover all resources allocated for DDE and disable DDE functionality. Calling dmh_dde end will disable the send command.

The command dmh_dde query is used to determine the DDE servers on your computer that are online and responsive. The command returns a list of pairs where each pair is the DDE server's service and topic names. DDE is insensitive to the case of these names. Not all DDE servers respond to a poll. Also, the interpreter does not include itself in the list, because it does not allow self-connections. For example:

% dmh_dde query

{Shell AppIcon} {Excel System}{Excel {[FUNCRES.XLA]RES}} {hub81 tcl74} {WinWord E:\ECH_HELP\MANN\DDE.RTF}} {WinWord System} {tkinspect tcl74}

% dmh_dde query winword

{winword {E:\ECH_HELP\MANN\LSET.RTF}} {winword E:\ECH_HELP\MANN\DDE.RTF}} {winword System}

The optional service and topic arguments to dde query are used to restrict the scope of the polling to those servers which implement the service and or topic. Use an empty argument ("" or {}) or a missing argument to represent a wildcard. This feature seems to work well when the topic is wildcarded but currently if you specify a specific topic and wildcard the service, nothing is returned. We'll see if this starts working in future versions of Win32....

Most of the dde functions require that a conversation or communication connection be established between the communicating partners. Use dmh_dde connect to establish a conversation to a DDE server on the indicated service and topic names. The connect command returns a connection handle hconv which is used in the execute, poke and request actions. Use dmh_dde disconnect when communication with a server is no longer desired.

The command dmh_dde service when used with no argument indicates the service and topic that the interpreter supports for external clients. If DDE functionality has not been initialized or has been ended, an empty string is returned. An optional hconv argument can be given to dde service. With this usage, the service and topic of the server that is being conversed with is returned. This usage is also a way to test the validity of the conversation connection. If the external application has disconnected, an empty string is returned.

The command dmh_dde execute invokes the DDE execute action with an external server. Most servers will try to execute the command argument as a macro invocation or an interpreted command; check your vendor's documentation. It is a design limit of DDE that the execute action cannot return data; only a success or failure flag is returned. The command is executed synchronously with an optional timeout period indicated in milliseconds. The Tcl interpreter responds to an execute request by executing the command argument as Tcl code. You have to get clever to workaround the inability of dde execute to return data. We implement Tk send by asking the remote interpreter to perform a nested dmh_dde execute back to us. It isn't pretty but it works. The source code is in $dmh_library/dde.tcl.

The dmh_dde poke command performs the DDE Poke action with an external DDE application. The command is usually used to asynchronously send unsolicited data. An example use would be to write data values into a spreadsheet.

The dmh_dde request command is used to request a data item. The command executes synchronously with an optional timeout indicated in milliseconds. It is an undocumented aspect of DDE that the item string is limited to 200 bytes or so. The returned data can be large. The Tcl interpreter responds to the request command by executing the item string as a Tcl command and returning the result. This command can be used with Excel to read data values from a spreadsheet.

You should be cautious in basing CIM applications on synchronous RPC-like calls such as dmh_dde request or dmh_dde execute. Without message queuing, the system can unexpectely fail with timeouts during processing peaks. In general it is safer to use message queues such as provided with the mbx command.

AUTHOR

Ed Hume, Hume Integration Software, Austin TX

KEYWORDS

DDE, Win32, Windows, IPC