Tcl/Tk and SKILL Mix It Up
by Christopher Nelson

Listing One
proc ilEval { expression } {
    puts file3 $expression
    return [read file4]
}

Listing Two # Get a request from the client
set request [read $clientIn]
# Parse the command and response template
set command [lindex $request 0]
set response [lindex $request 1]
# Fill in the response and return it to the client
puts $clientOut [fillTemplate $response [eval $command]]

Listing Three
# Set a value in the server, no response needed
puts $server [list {set a 1} {}]
# Get the value back to confirm
set responseAction "The value of a is <<%r>>"
puts $server [list {set a} $responseAction]

Listing Four
# When the update button is clicked, get the value of the named variable, 
# and update the value entry with it
set responseAction "$valueEntry select 0 end; $valueEntry insert end %r"
$updateButton configure -command \
        puts $server [list [list set [$variableEntry get]] $responseAction]

Listing Five
(setq tclProcess
                  (hiBeginProcess cmdLine     ;; Command
                                  ""          ;; Host name
                                  'tclInterp  ;; stdout handling
                                  'tclEcho    ;; stderr handling
                                  'tclDone    ;; post-func
                                  ))

Listing Six
;; Echo data received on stderr from child to CIW.
;; This allows Tcl clients to put messages in the CIW with
;;     [puts stderr ...].
(defun tclEcho (x_childID t_data)
    (printf "%s\n" t_data)
    );;tclEcho

Listing Seven
(if (and (boundp 'serverTrace) 
             (geqp serverTrace 0))
                (printf "\n$$$ tclInterp got <<%s>>\n" t_data))

Listing Eight
(defun serverTrace (level format @rest args)
            (setq format (strcat "\n$$$ " format "\n"))
            (if (and (boundp 'serverTraceLevel)
                         (geqp serverTraceLevel level))
                 (if args
                     (eval (append (list 'printf format) args))
                     (printf format)))
           )

Listing Nine
(defun tclNotify (s)
    (if (and (boundp 'tclProcess)
             tclProcess) 
            (hiWriteChild tclProcess
                          (sprintf nil "skill::IlNotify %s\n" s))
            );; if
    );; tclNotify




2

