I started to write TclTutor before Win 95 came out (1995), and before a Tcl port for MS Windows was available. Thus, I did not put any support for MS Windows into TclTutor. Once Tcl was ported to MS Windows, however, there were many requests that TclTutor run in the MS Windows environment.
The changes to support MS Windows were mostly simple, but affected much of the package.
Renaming the files was tedious and uninteresting.
Removing the exec
's of Unix (tm) programs was a bit more challenging, but most
of the functionality I needed had already been provided by the Sun team.
Only two pieces of code needed re-writes to replace their Unix (tm) equivalents.
One was the grep for lesson titles, as discussed previously, and the other
was the invocation of TkMan.
One of my design goals for TclTutor was to allow students to gain
hypertextual access to more information about commands at the click of a
button. Under Unix (tm), I did this by exec
'ing a copy of Tom Phelps TkMan
program. Under MS Windows it turns out that one can provide similar
functionality by exec
'ing winhlp32.exe.
The most challenging problem was to evaluate the lessons within the MS Windows environment.
When the TclTutor project was started, child interpreters were not
available, and in order to keep an example program with errors from
crashing the TclTutor, I decided to exec
a new copy of the wish interpreter to interpret
the example script, and then parse the standard output and standard
error to display the success or failure of the example code. This happy
choice made it very easy to extend TclTutor into other
languages, as described above.
Unfortunately, the Win 95 environment doesn't distinguish between stdout and stderr. This makes distinguishing errors from legitimate output a challenging task.
My solution to this for Tcl is to parse the Tcl example code within a child interpreter, since errors are handled much differently from standard output by a child interpreter. Unfortunately, this solution is valid only for Tcl and Tcl extensions, so other language lessons are not yet supported in the MS Windows version of TclTutor.
This solution required a major rewrite of the example running code, including a
modified puts
(to capture the output to display on the
TclTutor screen), modified bgerror
(to emulate reading stderr), and some
much different logic for massaging example code prior to evaluating it.
Rather than clutter the TclTutor program with if ($tcl_platform == "windows")
statements,
all of the modified procs are kept in a separate file, which is sourced
if tcl_platform
is set to "windows".