Erick Gallesio writes:
>
> On Thu, 14 Mar 2002 16:04:33 +0100 (MET)
> Guenther Goerz <goerz_at_informatik.uni-erlangen.de> wrote:
>
> > Dear Erick, dear STkers,
> >
> > a while ago one of our students wrote a program for Paul Lorenzen's
> > dialogue logic as part of his diploma (master's) thesis. Although
> > there is a line mode which should run in any Scheme system, he
> > implemented a nice graphical interface with STk. With recent STk
> > versions (the latest one for Windows as well as that for Linux, which
> > I downloaded from your site) the following problem came up:
> >
> > In the program's main window there is a menu bar. Selecting one of
> > its items, a pop-up submenu comes up in which several items can be
> > selected. The effect of such a selection is that the value of a
> > variable should be set from #f (the default value) to #t which in turn
> > should cause the appearance of another window. What happens is that
> > the value(s) of the resp. variables are not affected by selecting the
> > corresponding menu item (which used to work before). This can easily
> > be verifed by asking for the value in the main STk window after
> > clicking the corresponding menu item. However, if I set the value in
> > the main STk window, everything works as it should do.
> >
> From what I understand you have an environment problem. In "recent"
> versions (since 4.0 probably), you can associate an environment with
> a checkbutton. The following example will make things clearer:
>
> STk> (define env (let ((x 1)) (the-environment))) ; a local x
> env
> STk> (define x 0) ; a global one
> x
> STk> (menu '.foo)
> #[Tk-command .foo]
> STk> (.foo 'add 'check :label "test" :variable 'x :environment env)
> ()
> STk> (.foo 'post 10 10)
> ()
> If you try to click on the menu, you'll see that the global in
> untouched, but this is in fact the on in the let which is modified.
> To be convinced of that you can do:
> STk> (car (environment->list env))
> ((x . #t))
> and try to click on the menu and you'll see
> STk> (car (environment->list env))
> ((x . #f))
>
> So, I suppose that for some reason, you don't capture the global
> variable in your code but a local one (by some way, I don' know).
> Perhaps, you can try to specify the global environment in your
> menu. Something like:
> STk> (.foo 'add 'check :label "test2" :variable 'x :environment
> (global-environment))
> ()
>
> Tell me if it works.
Dear Erick,
thank you, THAT'S IT! I just didn't see the local/global problem.
With the additional feature :environment set to (global-environment)
it works as it used to work.
Best regards,
-- Günther
-- ---------------------------------------------------------------------------
Prof. Dr. Guenther Goerz Fon: (+49 9131) 852-8701; -8702
Univ. Erlangen-Nuernberg Fax: (+49 9131) 852-8986
Institut f. Informatik 8/AI (Comp.Sci.) goerz_at_informatik.uni-erlangen.de
Haberstrasse 2 guenther.goerz_at_acm.org
D-91058 ERLANGEN
http://www8.informatik.uni-erlangen.de/IMMD8/staff/Goerz/
Received on Fri Mar 22 2002 - 17:30:58 CET