PT 10-Jul-2003: By default, a Tcl dde server exposes all the commands and variables defined in the interpreter to remote dde requests. DDE requests require three identifiers - an application name, a topic and an item. For Tcl servers the application is always TclEval and the topic is whatever you provided as an argument to dde servername. The item name will be the name of a tcl command for execute or the name of a tcl variable for request. To illustrate - fire up a wish and execute 'package require dde ; dde servername alpha'. Now try:
% dde services TclEval {} alpha % dde execute TclEval alpha {puts Hello} # Hello is printed in the remote window % dde request TclEval alpha tcl_patchLevel 8.4.3As you can see - we cause the server application to execute Tcl commands and to return variable values. Note that execute will not return a result to you. You'd need to use a temporary variable for this.To put this into practice - lets use Excel and fill a field from out running Tcl application. If you open up a new excel worksheet and enter
=TclEval|alpha!tcl_patchLevelThats the application name (TclEval), a pipe symbol, the topic name (our dde servername), an exclamation point, then the variable name. You should now have your tcl patchlevel displayed in the Excel cell.For Tcl 8.5 you can restrict the access to your interpreter by specifying a handler procedure which can validate incoming commands and requests. This version also supports loading the dde package into a safe interpreter. For more information about this see dde restriction and ddeexec and also TIP #120 [1].