Chapter 22 presented two examples: a browser for the examples in this book, and a simple shell in which to try out Tcl commands. In that chapter they are put into the same application. The two examples shown below hook these two applications together using the send command. Example 40-2 changes the Run and Reset procedures to send Tcl commands the shell defined in Example 22-4 on page 329. The StartEvalServer procedure starts up the shell, if necessary.
The number of lists created before the send command may seem excessive, but they are all necessary. The send command concatenates its arguments, so instead of letting it do that, we pass it a single list. Similarly, EvalServe expects a single argument that is a valid command, so list is used to construct that.
The shell in Example 22-4 on page 329 has an EvalEcho procedure that we can use as the target of send. The only thing it needs is to complete the rendez-vous with the browser. When the tcl shell starts up, it sends the browser its application name. The browser passes its own name on the command line that starts the shell, so the shell knows how to talk to the browser.
# Add this to Example 22–4 on page 329 if {$argc > 0} { # Check in with the browser send [lindex $argv 0] [list set browse(evalInterp) [tk appname]] } |
18.222.168.163