home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.tcl
- Path: sparky!uunet!eco.twg.com!twg.com!news
- From: "David Herron" <david@twg.com>
- Subject: Re: How difficult is a restricted tcl shell ?
- Message-ID: <1993Jan23.030504.3434@twg.com>
- Sensitivity: Personal
- Encoding: 112 TEXT , 4 TEXT
- Sender: news@twg.com (USENET News System)
- Conversion: Prohibited
- Organization: The Wollongong Group, Inc., Palo Alto, CA
- Conversion-With-Loss: Prohibited
- Date: Sat, 23 Jan 1993 03:10:04 GMT
- Lines: 117
-
- The last time this issue was brought up someone mentioned my work with
- adding multiple interpretor manipulation to TCL. But back then I was
- on vacation, or for some other reason was too busy to respond then.
-
- As Bruce suggested, different interpretors can very easily have different
- sets of commands. One interpretor can have access to the full TCL while
- others have access to some small set of commands.
-
- I have an extension to TCL I'm working on (slowly) which can do this
- from TCL. It is nearing a releasable state. Since there seems to be
- more demand for this feature than I have time to satisfy we might have
- to set up some kind of committee to further develop this module/extension.
- If you agree, send me mail to my home address (david@davids.mmdf.com) since
- this may take some time to develop and arrange, and it has no bearing
- on what I do here at twg.com.
-
- What I have now is rather different from what was posted before. It
- has been tweaked to improve the notation, and to provide support for
- object oriented programming -- an object being an interpretor. So I
- had to first learn some fundamentals of OO programming before implementing
- TCL extensions for that purpose.
-
- The facilities are:
-
- interpretor create: The command is "interp new interp-name". This creates
- an interpretor; puts an entry into a hashed table of interpretors; creates
- a command in one (or more) other interpretors which will execute commands
- in that other interpretor; creates a few needed commands in this new
- interpretor.
-
- interpretor delete: The exit command in the interpretor is changed to
- call an interp destruction function. There's also "interp delete interp-name".
-
- accessing variables: Some of the commands given to the interpretor are
-
- -getVar name1 name1
- -setVar name1 name2 value
- -unsetVar name1 name2
-
- So that you can access like: interp-name -getVar name1 name2
- or: $interp -getVar name1 name2
- or: set var [$interp -getVar name1 name2]
-
- calling functions in other interpretor: interp-name command line
- or: interp-name {
- complex; command; sequence; including;
- proc definition{} {code }
- }
-
- The facilities go on and on. There's also a C API to the module to
- use it in other ways. For instance, the interp's are created knowing
- nothing but the basic TCL commands. None of the TCLX or TK commands
- are known. If you want a customized interp, you've gotta use the
- C API to create it.
-
- I've written a file browser "object" which I'll post next week (or
- maybe over the weekend). It shows lots of the interp facilities.
- The programming interface to the file browser object is like:
-
- wm minsize . 1 1
- # Tell the interp module which is the "main interpretor" so
- # it knows where to send unknown commands.
- interp MainInterp
-
- # Load in the object definition. Create the object and
- # its visual look.
- source $ooLibrary/FileBrowserC.tcl
- set fb [FileBrowserClass new]
- $fb MakeWidgets .fb
- pack append . .fb {top fill expand}
-
- # Customize this particular instance.
- $fb {
- # Set beginning directory, filter. Make the contents
- # of it appear.
- setDirectory "/tmp"
- setPattern "*"
- changeDirectory
-
- # These are called when the OK and CANCEL buttons are pressed
- proc okCommand {} {
- set dir [getDirectory]
- set file [getFile]
- if {$dir != "" && $file != ""} {
- puts stdout "$dir/$file"
- }
- MainInterp exit
- }
-
- proc cancelCommand {} { MainInterp exit }
- }
-
- This program is pretty much what the test script for the filebrowser
- object is. If you slap a "#! /usr/local/bin/wish -f" in front
- and named "queryFile", it could be used from a shell script like:
-
- FILE="`queryFile`"
-
-
-
- This gets away from the original query of a way to have limited
- interpretors. Sorry, this is what I've been working on and this
- is pretty cool by itself. The limited interp's idea is very doable
- and requires some tweaking of my interp module. I'm very interested
- in seeing that happen.
-
- I offer to host a mailing list on my home system for this purpose.
- (Which means setting ServiceMail back up and making sure it
- can manipulate MMDF style mailing lists....!)
-
- Again, send me mail at david@davids.mmdf.com about this!
-
-
- <- David Herron <david@twg.com> (work) <david@davids.mmdf.com> (home)
- <-
- <- "That's our advantage at Microsoft; we set the standards and we can change them."
- <- Karen Hargrove of Microsoft quoted in the Feb 1993 Unix Review editorial.
-