Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/dde.n @ 35

Last change on this file since 35 was 25, checked in by landauf, 18 years ago

added tcl to libs

File size: 7.2 KB
RevLine 
[25]1'\"
2'\" Copyright (c) 1997 Sun Microsystems, Inc.
3'\" Copyright (c) 2001 ActiveState Corporation.
4'\"
5'\" See the file "license.terms" for information on usage and redistribution
6'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7'\"
8'\" RCS: @(#) $Id: dde.n,v 1.24 2008/01/18 15:59:22 dkf Exp $
9'\"
10.so man.macros
11.TH dde n 1.3 dde "Tcl Bundled Packages"
12.BS
13'\" Note:  do not modify the .SH NAME line immediately below!
14.SH NAME
15dde \- Execute a Dynamic Data Exchange command
16.SH SYNOPSIS
17.sp
18\fBpackage require dde 1.3\fR
19.sp
20\fBdde servername\fR ?\fB\-force\fR? ?\fB\-handler \fIproc\fR? ?\fB\-\|\-\fR? ?\fItopic\fR?
21.sp
22\fBdde execute\fR ?\fB\-async\fR? \fIservice topic data\fR
23.sp
24\fBdde poke\fR \fIservice topic item data\fR
25.sp
26\fBdde request\fR ?\fB\-binary\fR? \fIservice topic item\fR
27.sp
28\fBdde services \fIservice topic\fR
29.sp
30\fBdde eval\fR ?\fB\-async\fR? \fItopic cmd \fR?\fIarg arg ...\fR?
31.BE
32
33.SH DESCRIPTION
34.PP
35This command allows an application to send Dynamic Data Exchange (DDE)
36command when running under Microsoft Windows. Dynamic Data Exchange is
37a mechanism where applications can exchange raw data. Each DDE
38transaction needs a \fIservice name\fR and a \fItopic\fR. Both the
39\fIservice name\fR and \fItopic\fR are application defined; Tcl uses
40the service name \fBTclEval\fR, while the topic name is the name of the
41interpreter given by \fBdde servername\fR. Other applications have their
42own \fIservice names\fR and \fItopics\fR. For instance, Microsoft Excel
43has the service name \fBExcel\fR.
44.PP
45.SH "DDE COMMANDS"
46.PP
47The following commands are a subset of the full Dynamic Data Exchange
48set of commands.
49.TP
50\fBdde servername \fR?\fB\-force\fR? ?\fB\-handler \fIproc\fR? ?\fB\-\|\-\fR? ?\fItopic\fR?
51.
52\fBdde servername\fR registers the interpreter as a DDE server with
53the service name \fBTclEval\fR and the topic name specified by \fItopic\fR.
54If no \fItopic\fR is given, \fBdde servername\fR returns the name
55of the current topic or the empty string if it is not registered as a
56service. If the given \fItopic\fR name is already in use, then a
57suffix of the form
58.QW " #2"
59or
60.QW " #3"
61is appended to the name to make it
62unique. The command's result will be the name actually used. The
63\fB\-force\fR option is used to force registration of precisely the
64given \fItopic\fR name.
65.RS
66.PP
67The \fB\-handler\fR option specifies a Tcl procedure that will be called to
68process calls to the dde server. If the package has been loaded into a
69safe interpreter then a \fB\-handler\fR procedure must be defined. The
70procedure is called with all the arguments provided by the remote
71call.
72.RE
73.TP
74\fBdde execute\fR ?\fB\-async\fR? \fIservice topic data\fR
75.
76\fBdde execute\fR takes the \fIdata\fR and sends it to the server indicated
77by \fIservice\fR with the topic indicated by \fItopic\fR. Typically,
78\fIservice\fR is the name of an application, and \fItopic\fR is a file to
79work on.  The \fIdata\fR field is given to the remote application.
80Typically, the application treats the \fIdata\fR field as a script, and the
81script is run in the application.  The \fB\-async\fR option requests
82asynchronous invocation.  The command returns an error message if the
83script did not run, unless the \fB\-async\fR flag was used, in which case
84the command returns immediately with no error.
85.TP
86\fBdde poke \fIservice topic item data\fR
87.
88\fBdde poke\fR passes the \fIdata\fR to the server indicated by
89\fIservice\fR using the \fItopic\fR and \fIitem\fR specified.  Typically,
90\fIservice\fR is the name of an application.  \fItopic\fR is application
91specific but can be a command to the server or the name of a file to work
92on.  The \fIitem\fR is also application specific and is often not used, but
93it must always be non-null.  The \fIdata\fR field is given to the remote
94application.
95.TP
96\fBdde request\fR ?\fB\-binary\fR? \fIservice topic item\fR
97.
98\fBdde request\fR is typically used to get the value of something; the
99value of a cell in Microsoft Excel or the text of a selection in
100Microsoft Word. \fIservice\fR is typically the name of an application,
101\fItopic\fR is typically the name of the file, and \fIitem\fR is
102application-specific. The command returns the value of \fIitem\fR as
103defined in the application.  Normally this is interpreted to be a
104string with terminating null.  If \fB\-binary\fR is specified, the
105result is returned as a byte array.
106.TP
107\fBdde services \fIservice topic\fR
108.
109\fBdde services\fR returns a list of service-topic pairs that
110currently exist on the machine. If \fIservice\fR and \fItopic\fR are
111both empty strings ({}), then all service-topic pairs currently
112available on the system are returned. If \fIservice\fR is empty and
113\fItopic\fR is not, then all services with the specified topic are
114returned. If \fIservice\fR is non-empty and \fItopic\fR is, all topics
115for a given service are returned. If both are non-empty, if that
116service-topic pair currently exists, it is returned; otherwise, an
117empty string is returned.
118.TP
119\fBdde eval\fR ?\fB\-async\fR? \fItopic cmd \fR?\fIarg arg ...\fR?
120.
121\fBdde eval\fR evaluates a command and its arguments using the interpreter
122specified by \fItopic\fR. The DDE service must be the \fBTclEval\fR
123service.  The \fB\-async\fR option requests asynchronous invocation.  The
124command returns an error message if the script did not run, unless the
125\fB\-async\fR flag was used, in which case the command returns immediately
126with no error.  This command can be used to replace send on Windows.
127.SH "DDE AND TCL"
128A Tcl interpreter always has a service name of \fBTclEval\fR.  Each
129different interpreter of all running Tcl applications must be
130given a unique
131name specified by \fBdde servername\fR. Each interp is available as a
132DDE topic only if the \fBdde servername\fR command was used to set the
133name of the topic for each interp. So a \fBdde services TclEval {}\fR
134command will return a list of service-topic pairs, where each of the
135currently running interps will be a topic.
136.PP
137When Tcl processes a \fBdde execute\fR command, the data for the
138execute is run as a script in the interp named by the topic of the
139\fBdde execute\fR command.
140.PP
141When Tcl processes a \fBdde request\fR command, it returns the value of the
142variable given in the dde command in the context of the interp named by the
143dde topic. Tcl reserves the variable \fB$TCLEVAL$EXECUTE$RESULT\fR for
144internal use, and \fBdde request\fR commands for that variable will give
145unpredictable results.
146.PP
147An external application which wishes to run a script in Tcl should have
148that script store its result in a variable, run the \fBdde execute\fR
149command, and the run \fBdde request\fR to get the value of the
150variable.
151.PP
152When using DDE, be careful to ensure that the event queue is flushed
153using either \fBupdate\fR or \fBvwait\fR.  This happens by default
154when using \fBwish\fR unless a blocking command is called (such as \fBexec\fR
155without adding the \fB&\fR to place the process in the background).
156If for any reason the event queue is not flushed, DDE commands may
157hang until the event queue is flushed.  This can create a deadlock
158situation.
159.SH EXAMPLE
160This asks Internet Explorer (which must already be running) to go to a
161particularly important website:
162.CS
163package require dde
164\fBdde execute\fR iexplore WWW_OpenURL http://www.tcl.tk/
165.CE
166.SH "SEE ALSO"
167tk(n), winfo(n), send(n)
168.SH KEYWORDS
169application, dde, name, remote execution
Note: See TracBrowser for help on using the repository browser.