OSDN Git Service

Initial revision
[pf3gnuchains/pf3gnuchains3x.git] / tcl / doc / dde.n
1 '\"
2 '\" Copyright (c) 1997 Sun Microsystems, Inc.
3 '\"
4 '\" See the file "license.terms" for information on usage and redistribution
5 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6 '\" 
7 '\" RCS: @(#) $Id$
8 '\" 
9 .so man.macros
10 .TH dde n 8.1 Tcl "Tcl Built-In Commands"
11 .BS
12 '\" Note:  do not modify the .SH NAME line immediately below!
13 .SH NAME
14 dde \- Execute a Dynamic Data Exchange command
15 .SH SYNOPSIS
16 .sp
17 \fBpackage require dde 1.1\fR
18 .sp
19 \fBdde \fIservername \fR?\fItopic\fR?
20 .sp
21 \fBdde ?\-async?\fR \fIcommand service topic \fR?\fIdata\fR?
22 .BE
23
24 .SH DESCRIPTION
25 .PP
26 This command allows an application to send Dynamic Data Exchange (DDE)
27 command when running under Microsoft Windows. Dynamic Data Exchange is
28 a mechanism where applications can exchange raw data. Each DDE
29 transaction needs a \fIservice name\fR and a \fItopic\fR. Both the
30 \fIservice name\fR and \fItopic\fR are application defined; Tcl uses
31 the service name \fBTclEval\fR, while the topic name is the name of the
32 interpreter given by \fBdde servername\fR. Other applications have their
33 own \fIservice names\fR and \fItopics\fR. For instance, Microsoft Excel
34 has the service name \fBExcel\fR.
35 .PP
36 The only option to the \fBdde\fR command is:
37 .TP
38 \fB\-async\fR
39 Requests asynchronous invocation.  This is valid only for the
40 \fBexecute\fR subcommand. Normally, the \fBdde execute\fR subcommand
41 waits until the command completes, returning appropriate error
42 messages. When the \fB\-async\fR option is used, the command returns
43 immediately, and no error information is available.
44 .SH "DDE COMMANDS"
45 .PP
46 The following commands are a subset of the full Dynamic Data Exchange
47 set of commands.
48 .TP
49 \fBdde servername \fR?\fItopic\fR?
50 \fBdde servername\fR registers the interpreter as a DDE server with
51 the service name \fBTclEval\fR and the topic name specified by \fItopic\fR.
52 If no \fItopic\fR is given, \fBdde servername\fR returns the name
53 of the current topic or the empty string if it is not registered as a service.
54 .TP
55 \fBdde execute \fIservice topic data\fR
56 \fBdde execute\fR takes the \fIdata\fR and sends it to the server
57 indicated by \fIservice\fR with the topic indicated by
58 \fItopic\fR. Typically, \fIservice\fR is the name of an application,
59 and \fItopic\fR is a file to work on.  The \fIdata\fR field is given
60 to the remote application. Typically, the application treats the
61 \fIdata\fR field as a script, and the script is run in the
62 application. The command returns an error if the script did not
63 run. If the \fB\-async\fR flag was used, the command
64 returns immediately with no error.
65 .TP
66 \fBdde poke \fIservice topic item data\fR
67 \fBdde poke\fR passes the \fIdata\fR to the server indicated by
68 \fIservice\fR using the \fItopic\fR and \fIitem\fR specified.  Typically,
69 \fIservice\fR is the name of an application.  \fItopic\fR is application
70 specific but can be a command to the server or the name of a file to work
71 on.  The \fIitem\fR is also application specific and is often not used, but
72 it must always be non-null.  The \fIdata\fR field is given to the remote
73 application.
74 .TP
75 \fBdde request \fIservice topic item\fR
76 \fBdde request\fR is typically used to get the value of something; the
77 value of a cell in Microsoft Excel or the text of a selection in
78 Microsoft Word. \fIservice\fR is typically the name of an application,
79 \fItopic\fR is typically the name of the file, and \fIitem\fR is
80 application-specific. The command returns the value of \fIitem\fR as
81 defined in the application.
82 .TP
83 \fBdde services \fIservice topic\fR
84 \fBdde services\fR returns a list of service-topic pairs that
85 currently exist on the machine. If \fIservice\fR and \fItopic\fR are
86 both null strings ({}), then all service-topic pairs currently
87 available on the system are returned. If \fIservice\fR is null and
88 \fItopic\fR is not, then all services with the specified topic are
89 returned. If \fIservice\fR is not null and \fItopic\fR is, all topics
90 for a given service are returned. If both are not null, if that
91 service-topic pair currently exists, it is returned; otherwise, null
92 is returned.
93 .TP
94 \fBdde eval \fItopic cmd \fR?\fIarg arg ...\fR?
95 \fBdde eval\fR evaluates a command and its arguments using the
96 interpreter specified by \fItopic\fR. The DDE service must be the
97 \fBTclEval\fR service.  This command can be used to replace send on
98 Windows.
99 .SH "DDE AND TCL"
100 A Tcl interpreter always has a service name of \fBTclEval\fR.  Each
101 different interpreter of all running Tcl applications must be
102 given a unique
103 name specified by \fBdde servername\fR. Each interp is available as a
104 DDE topic only if the \fBdde servername\fR command was used to set the
105 name of the topic for each interp. So a \fBdde services TclEval {}\fR
106 command will return a list of service-topic pairs, where each of the
107 currently running interps will be a topic.
108 .PP
109 When Tcl processes a \fBdde execute\fR command, the data for the
110 execute is run as a script in the interp named by the topic of the
111 \fBdde execute\fR command.
112 .PP
113 When Tcl processes a \fBdde request\fR command, it returns the value of the
114 variable given in the dde command in the context of the interp named by the
115 dde topic. Tcl reserves the variable \fB$TCLEVAL$EXECUTE$RESULT\fR for
116 internal use, and \fBdde request\fR commands for that variable will give
117 unpredictable results.
118 .PP
119 An external application which wishes to run a script in Tcl should have
120 that script store its result in a variable, run the \fBdde execute\fR
121 command, and the run \fBdde request\fR to get the value of the
122 variable.
123 .PP
124 When using DDE, be careful to ensure that the event queue is flushed
125 using either \fBupdate\fR or \fBvwait\fR.  This happens by default
126 when using \fBwish\fR unless a blocking command is called (such as \fBexec\fR
127 without adding the \fB&\fR to place the process in the background).
128 If for any reason the event queue is not flushed, DDE commands may
129 hang until the event queue is flushed.  This can create a deadlock
130 situation.
131 .SH "SEE ALSO"
132 tk, winfo, send
133 .SH KEYWORDS
134 application, dde, name, remote execution
135