dde.n
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:7k
- '"
- '" Copyright (c) 1997 Sun Microsystems, Inc.
- '" Copyright (c) 2001 ActiveState Corporation.
- '"
- '" See the file "license.terms" for information on usage and redistribution
- '" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- '"
- '" RCS: @(#) $Id: dde.n,v 1.8.2.4 2004/12/03 00:37:21 hobbs Exp $
- '"
- .so man.macros
- .TH dde n 1.2 dde "Tcl Bundled Packages"
- .BS
- '" Note: do not modify the .SH NAME line immediately below!
- .SH NAME
- dde - Execute a Dynamic Data Exchange command
- .SH SYNOPSIS
- .sp
- fBpackage require dde 1.2fR
- .sp
- fBdde evalfR ?fB-asyncfR? fIservice cmdfR ?fIarg ...fR?
- .sp
- fBdde executefR ?fB-asyncfR? fIservice topic datafR
- .sp
- fBdde poke fIservice topic item datafR
- .sp
- fBdde requestfR ?fB-binaryfR? fIservice topic datafR
- .sp
- fBdde servernamefR ?fItopicfR?
- .sp
- fBdde services fIservice topicfR
- .BE
- .SH DESCRIPTION
- .PP
- This command allows an application to send Dynamic Data Exchange (DDE)
- command when running under Microsoft Windows. Dynamic Data Exchange is
- a mechanism where applications can exchange raw data. Each DDE
- transaction needs a fIservice namefR and a fItopicfR. Both the
- fIservice namefR and fItopicfR are application defined; Tcl uses
- the service name fBTclEvalfR, while the topic name is the name of the
- interpreter given by fBdde servernamefR. Other applications have their
- own fIservice namefRs and fItopicfRs. For instance, Microsoft Excel
- has the service name fBExcelfR.
- .PP
- The fBevalfR and fBexecutefR commands accept the option fB-asyncfR:
- .SH "DDE COMMANDS"
- .PP
- The following commands are a subset of the full Dynamic Data Exchange
- set of commands.
- .TP
- fBdde servername fR?fItopicfR?
- fBdde servernamefR registers the interpreter as a DDE server with
- the service name fBTclEvalfR and the topic name specified by fItopicfR.
- If no fItopicfR is given, fBdde servernamefR returns the name
- of the current topic or the empty string if it is not registered as a service.
- .TP
- fBdde executefR ?fB-asyncfR? fIservice topic datafR
- fBdde executefR takes the fIdatafR and sends it to the server indicated
- by fIservicefR with the topic indicated by fItopicfR. Typically,
- fIservicefR is the name of an application, and fItopicfR is a file to
- work on. The fIdatafR field is given to the remote application.
- Typically, the application treats the fIdatafR field as a script, and the
- script is run in the application. The fB-asyncfR option requests
- asynchronous invocation. The command returns an error message if the
- script did not run, unless the fB-asyncfR flag was used, in which case
- the command returns immediately with no error.
- .TP
- fBdde poke fIservice topic item datafR
- fBdde pokefR passes the fIdatafR to the server indicated by
- fIservicefR using the fItopicfR and fIitemfR specified. Typically,
- fIservicefR is the name of an application. fItopicfR is application
- specific but can be a command to the server or the name of a file to work
- on. The fIitemfR is also application specific and is often not used, but
- it must always be non-null. The fIdatafR field is given to the remote
- application.
- .TP
- fBdde requestfR ?fB-binaryfR? fIservice topic itemfR
- fBdde requestfR 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. fIservicefR is typically the name of an application,
- fItopicfR is typically the name of the file, and fIitemfR is
- application-specific. The command returns the value of fIitemfR as
- defined in the application. Normally this is interpreted to be a
- string with terminating null. If fB-binaryfR is specified, the
- result is returned as a byte array.
- .TP
- fBdde services fIservice topicfR
- fBdde servicesfR returns a list of service-topic pairs that
- currently exist on the machine. If fIservicefR and fItopicfR are
- both null strings ({}), then all service-topic pairs currently
- available on the system are returned. If fIservicefR is null and
- fItopicfR is not, then all services with the specified topic are
- returned. If fIservicefR is not null and fItopicfR is, all topics
- for a given service are returned. If both are not null, if that
- service-topic pair currently exists, it is returned; otherwise, null
- is returned.
- .TP
- fBdde evalfR ?fB-asyncfR? fItopic cmd fR?fIarg arg ...fR?
- fBdde evalfR evaluates a command and its arguments using the interpreter
- specified by fItopicfR. The DDE service must be the fBTclEvalfR
- service. The fB-asyncfR option requests asynchronous invocation. The
- command returns an error message if the script did not run, unless the
- fB-asyncfR flag was used, in which case the command returns immediately
- with no error. This command can be used to replace fBsendfR on Windows.
- .SH "DDE AND TCL"
- A Tcl interpreter always has a service name of fBTclEvalfR. Each
- different interpreter of all running Tcl applications must be
- given a unique
- name specified by fBdde servernamefR. Each interp is available as a
- DDE topic only if the fBdde servernamefR command was used to set the
- name of the topic for each interp. So a fBdde services TclEval {}fR
- command will return a list of service-topic pairs, where each of the
- currently running interps will be a topic.
- .PP
- When Tcl processes a fBdde executefR command, the data for the
- execute is run as a script in the interp named by the topic of the
- fBdde executefR command.
- .PP
- When Tcl processes a fBdde requestfR 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 fB$TCLEVAL$EXECUTE$RESULTfR for
- internal use, and fBdde requestfR commands for that variable will give
- unpredictable results.
- .PP
- An external application which wishes to run a script in Tcl should have
- that script store its result in a variable, run the fBdde executefR
- command, and the run fBdde requestfR to get the value of the
- variable.
- .PP
- When using DDE, be careful to ensure that the event queue is flushed
- using either fBupdatefR or fBvwaitfR. This happens by default
- when using fBwishfR unless a blocking command is called (such as fBexecfR
- without adding the fB&fR 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.
- .SH EXAMPLE
- This asks Internet Explorer (which must already be running) to go to a
- particularly important website:
- .CS
- package require dde
- fBdde executefR iexplore WWW_OpenURL http://www.tcl.tk/
- .CE
- .SH "SEE ALSO"
- tk(n), winfo(n), send(n)
- .SH KEYWORDS
- application, dde, name, remote execution