The script-window application in Dalgaard (2001) got hit rather badly by the interface changes. Below is a version that works with the new interface. Notice that it is necessary to insert tclvalue() constructions in several places, even when the return values are only used as arguments to Tcl/Tk routines. You can sometimes avoid this because the default treatment of arguments (in .Tcl.args()) is to preprocess them with as.character(), but for objects of class tclObj this only works if there are no whitespace characters in the string representation. The contents of the script window and the files that are read can obviously contain spaces and it is also not safe to assume that file names and directory names are single words.
The scripting widget is shown below with an example of some trivial R code:
The results are displayed in the R console:
Of course, it would also be possible to display the results in another Tk text window, rather than in the R console.