home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!uwm.edu!zaphod.mps.ohio-state.edu!menudo.uh.edu!sugar!karl
- From: karl@NeoSoft.com (Karl Lehenbauer)
- Newsgroups: comp.lang.tcl
- Subject: Re: variable visibility problem
- Message-ID: <BxwI80.MFB@NeoSoft.com>
- Date: 18 Nov 92 07:31:04 GMT
- Article-I.D.: NeoSoft.BxwI80.MFB
- References: <PRZEMEK.92Nov17130700@rrdstrad.nist.gov>
- Organization: NeoSoft Communications Services -- (713) 684-5900
- Lines: 37
-
- In article <PRZEMEK.92Nov17130700@rrdstrad.nist.gov> przemek@rrdstrad.nist.gov (Przemek Klosowski) writes:
- > [button $w.plot.Qp -text "E-Q-space plot" -relief raised \
- > -command "MyPlot $num $w $zoomfac"] {right}
- >Of course the code above does not work, because $zoomfac is evaluated
- >once at the creation of button, and the MyPlot command is called with
- >a constant argument. My second try was
- > [button $w.plot.Qp -text "E-Q-space plot" -relief raised \
- > -command {MyPlot $num $w $zoomfac}] {right}
- >but this in turn fails, because $num is not a valid variable in the
- >routine from which MyPlot is called.
-
- [button $w.plot.Qp -text "E-Q-space plot" -relief raised \
- -command "MyPlot $num $w \$zoomfac"] {right}
- ^
- You can use backslash to quote a dollar sign ----^ and get it evaluated
- when the button is pressed rather than when the button is created.
-
- I have seen a tendency on the part of myself and others to write some
- fairly huge -command arguments with a lot of exotic quoting to get
- things to come out just right. I would rather that we subsume this
- complexity into procs to make it easier to read and understand, something
- like:
-
- proc plot_button {num w} {
- global zoomfac
-
- MyPlot $num $w $zoomfac
- }
-
- button $w.plot.Qp -text "E-Q-space plot" -relief raised \
- -command "plot_button $num $w"
-
- pack $w.plot.Qp ...
-
- --
- -- Email info@NeoSoft.com for info on getting interactive Internet access.
- "Turn on your hot tub by email now. Ask me how."
-