1dde(n) Tcl Bundled Packages dde(n)
2
3
4
5______________________________________________________________________________
6
8 dde - Execute a Dynamic Data Exchange command
9
11 package require dde 1.2
12
13 dde eval ?-async? service cmd ?arg ...?
14
15 dde execute ?-async? service topic data
16
17 dde poke service topic item data
18
19 dde request ?-binary? service topic data
20
21 dde servername ?topic?
22
23 dde services service topic
24_________________________________________________________________
25
26
28 This command allows an application to send Dynamic Data Exchange (DDE)
29 command when running under Microsoft Windows. Dynamic Data Exchange is
30 a mechanism where applications can exchange raw data. Each DDE transac‐
31 tion needs a service name and a topic. Both the service name and topic
32 are application defined; Tcl uses the service name TclEval, while the
33 topic name is the name of the interpreter given by dde servername.
34 Other applications have their own service names and topics. For
35 instance, Microsoft Excel has the service name Excel.
36
37 The eval and execute commands accept the option -async:
38
39
41 The following commands are a subset of the full Dynamic Data Exchange
42 set of commands.
43
44 dde servername ?topic?
45 dde servername registers the interpreter as a DDE server with
46 the service name TclEval and the topic name specified by topic.
47 If no topic is given, dde servername returns the name of the
48 current topic or the empty string if it is not registered as a
49 service.
50
51 dde execute ?-async? service topic data
52 dde execute takes the data and sends it to the server indicated
53 by service with the topic indicated by topic. Typically, service
54 is the name of an application, and topic is a file to work on.
55 The data field is given to the remote application. Typically,
56 the application treats the data field as a script, and the
57 script is run in the application. The -async option requests
58 asynchronous invocation. The command returns an error message
59 if the script did not run, unless the -async flag was used, in
60 which case the command returns immediately with no error.
61
62 dde poke service topic item data
63 dde poke passes the data to the server indicated by service
64 using the topic and item specified. Typically, service is the
65 name of an application. topic is application specific but can
66 be a command to the server or the name of a file to work on.
67 The item is also application specific and is often not used, but
68 it must always be non-null. The data field is given to the
69 remote application.
70
71 dde request ?-binary? service topic item
72 dde request is typically used to get the value of something; the
73 value of a cell in Microsoft Excel or the text of a selection in
74 Microsoft Word. service is typically the name of an application,
75 topic is typically the name of the file, and item is applica‐
76 tion-specific. The command returns the value of item as defined
77 in the application. Normally this is interpreted to be a string
78 with terminating null. If -binary is specified, the result is
79 returned as a byte array.
80
81 dde services service topic
82 dde services returns a list of service-topic pairs that cur‐
83 rently exist on the machine. If service and topic are both null
84 strings ({}), then all service-topic pairs currently available
85 on the system are returned. If service is null and topic is not,
86 then all services with the specified topic are returned. If ser‐
87 vice is not null and topic is, all topics for a given service
88 are returned. If both are not null, if that service-topic pair
89 currently exists, it is returned; otherwise, null is returned.
90
91 dde eval ?-async? topic cmd ?arg arg ...?
92 dde eval evaluates a command and its arguments using the inter‐
93 preter specified by topic. The DDE service must be the TclEval
94 service. The -async option requests asynchronous invocation.
95 The command returns an error message if the script did not run,
96 unless the -async flag was used, in which case the command
97 returns immediately with no error. This command can be used to
98 replace send on Windows.
99
100
102 A Tcl interpreter always has a service name of TclEval. Each different
103 interpreter of all running Tcl applications must be given a unique name
104 specified by dde servername. Each interp is available as a DDE topic
105 only if the dde servername command was used to set the name of the
106 topic for each interp. So a dde services TclEval {} command will return
107 a list of service-topic pairs, where each of the currently running
108 interps will be a topic.
109
110 When Tcl processes a dde execute command, the data for the execute is
111 run as a script in the interp named by the topic of the dde execute
112 command.
113
114 When Tcl processes a dde request command, it returns the value of the
115 variable given in the dde command in the context of the interp named by
116 the dde topic. Tcl reserves the variable $TCLEVAL$EXECUTE$RESULT for
117 internal use, and dde request commands for that variable will give
118 unpredictable results.
119
120 An external application which wishes to run a script in Tcl should have
121 that script store its result in a variable, run the dde execute com‐
122 mand, and the run dde request to get the value of the variable.
123
124 When using DDE, be careful to ensure that the event queue is flushed
125 using either update or vwait. This happens by default when using wish
126 unless a blocking command is called (such as exec without adding the &
127 to place the process in the background). If for any reason the event
128 queue is not flushed, DDE commands may hang until the event queue is
129 flushed. This can create a deadlock situation.
130
131
133 This asks Internet Explorer (which must already be running) to go to a
134 particularly important website:
135 package require dde
136 dde execute iexplore WWW_OpenURL http://www.tcl.tk/
137
138
140 tk(n), winfo(n), send(n)
141
142
144 application, dde, name, remote execution
145
146
147
148dde 1.2 dde(n)