NAME
dde - Execute a Dynamic Data Exchange command
SYNOPSIS
ppaacckkaaggee rreeqquuiirree ddddee 11..22
ddddee servername ?topic?
ddddee execute ?-async? service topic ?data?
ddddee poke service topic item data
ddddee request ?-binary? service topic ?data?
ddddee services service topic ?data?
ddddee eval ?-async? service topic ?data?
DESCRIPTION
This command allows an application to send Dynamic Data Exchange (DDE) command when running under Microsoft Windows. Dynamic Data Exchange isa mechanism where applications can exchange raw data. Each DDE transac-
tion needs a service name and a topic. Both the service name and topic are application defined; Tcl uses the service name TTccllEEvvaall, while thetopic name is the name of the interpreter given by ddddee sseerrvveerrnnaammee.
Other applications have their own service names and topics. For instance, Microsoft Excel has the service name EExxcceell.The eevvaall and eexxeeccuuttee commands accept the option -aassyynncc:
DDDDEE CCOOMMMMAANNDDSS The following commands are a subset of the full Dynamic Data Exchange set of commands.ddddee sseerrvveerrnnaammee ?topic?
ddddee sseerrvveerrnnaammee registers the interpreter as a DDE server with
the service name TTccllEEvvaall and the topic name specified by topic.If no topic is given, ddddee sseerrvveerrnnaammee returns the name of the
current topic or the empty string if it is not registered as a service.ddddee eexxeeccuuttee ?-async? service topic data
ddddee eexxeeccuuttee takes the data and sends it to the server indicated
by service with the topic indicated by topic. Typically, service is the name of an application, and topic is a file to work on. The data field is given to the remote application. Typically, the application treats the data field as a script, and thescript is run in the application. The -async option requests
asynchronous invocation. The command returns an error messageif the script did not run, unless the -aassyynncc flag was used, in
which case the command returns immediately with no error.ddddee ppookkee service topic item data
ddddee ppookkee passes the data to the server indicated by service
using the topic and item specified. Typically, service is the name of an application. topic is application specific but can be a command to the server or the name of a file to work on. The item is also application specific and is often not used, butit must always be non-null. The data field is given to the
remote application.ddddee rreeqquueesstt ?-binary? service topic item
ddddee rreeqquueesstt is typically used to get the value of something; the
value of a cell in Microsoft Excel or the text of a selection in Microsoft Word. service is typically the name of an application,topic is typically the name of the file, and item is applica-
tion-specific. The command returns the value of item as defined
in the application. Normally this is interpreted to be a stringwith terminating null. If -binary is specified, the result is
returned as a byte array.ddddee sseerrvviicceess service topic
ddddee sseerrvviicceess returns a list of service-topic pairs that cur-
rently exist on the machine. If service and topic are both nullstrings ({}), then all service-topic pairs currently available
on the system are returned. If service is null and topic is not,then all services with the specified topic are returned. If ser-
vice is not null and topic is, all topics for a given serviceare returned. If both are not null, if that service-topic pair
currently exists, it is returned; otherwise, null is returned.ddddee eevvaall ?-async? topic cmd ?arg arg ...?
ddddee eevvaall evaluates a command and its arguments using the inter-
preter specified by topic. The DDE service must be the TTccllEEvvaallservice. The -async option requests asynchronous invocation.
The command returns an error message if the script did not run,unless the -aassyynncc flag was used, in which case the command
returns immediately with no error. This command can be used to replace send on Windows. DDDDEE AANNDD TTCCLL A Tcl interpreter always has a service name of TTccllEEvvaall. Each different interpreter of all running Tcl applications must be given a unique namespecified by ddddee sseerrvveerrnnaammee. Each interp is available as a DDE topic
only if the ddddee sseerrvveerrnnaammee command was used to set the name of the
topic for each interp. So a ddddee sseerrvviicceess TTccllEEvvaall {{}} command will return
a list of service-topic pairs, where each of the currently running
interps will be a topic.When Tcl processes a ddddee eexxeeccuuttee command, the data for the execute is
run as a script in the interp named by the topic of the ddddee eexxeeccuuttee
command.When Tcl processes a ddddee rreeqquueesstt command, it returns the value of the
variable given in the dde command in the context of the interp named by
the dde topic. Tcl reserves the variable $$TTCCLLEEVVAALL$$EEXXEECCUUTTEE$$RREESSUULLTT for
internal use, and ddddee rreeqquueesstt commands for that variable will give
unpredictable results. An external application which wishes to run a script in Tcl should havethat script store its result in a variable, run the ddddee eexxeeccuuttee com-
mand, and the run ddddee rreeqquueesstt to get the value of the variable.
When using DDE, be careful to ensure that the event queue is flushed using either uuppddaattee or vvwwaaiitt. This happens by default when using wwiisshh unless a blocking command is called (such as eexxeecc without adding the && to place the process in the background). If for any reason the event queue is not flushed, DDE commands may hang until the event queue is flushed. This can create a deadlock situation.SEE ALSO
tk(n), winfo(n), send(n) KKEEYYWWOORRDDSSapplication, dde, name, remote execution
dde 1.2 dde(n)