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