MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Scoping constructs Block, Module, ModuleBlock

  • To: mathgroup at
  • Subject: [mg111300] Re: Scoping constructs Block, Module, ModuleBlock
  • From: Michael <michael2718 at>
  • Date: Tue, 27 Jul 2010 04:15:15 -0400 (EDT)

On 7/22/2010 2:42 AM, John Fultz wrote:
> [...]
> I didn't look at your original code, but I think I probably know why your use of
> Block and Dynamic together failed.  The principal point is that Block introduces
> an environment where variables can be temporarily redefined, but that
> environment evaporates the moment Block is finished evaluating.  The contents of
> a Dynamic never even begin evaluating until well after the Shift-Enter
> evaluation is over.
> [...]

Hi again John,

I'm seeing a similar thing happen when I use DynamicModule:

xyz = "A";
f[] := DynamicModule[{tmp = "A"},
      PopupMenu[Dynamic[tmp], {"A", "B", "C", "D"}],
      PopupMenu[Dynamic[xyz], {"A", "B", "C", "D"}]
Button["Test", f[]]

If I click on the "Test" button, I don't see the value of "tmp" being 
changed when I pick different options from the pop up menu, but I *do* 
see the value of "xyz" being changed when I pick different options from 
its pop up menu.

However, if I execute f[] directly, it works for both cases.  Shouldn't 
clicking the button produce identical results to calling whatever is 
defined for its action?  There seems to be something related to using a 
dynamic module variable, perhaps it loses its definition during a Button 
call or something.

> Sincerely,
> John Fultz
> jfultz at
> User Interface Group
> Wolfram Research, Inc.

Best Regards,


  • Prev by Date: Re: NDSolve - how to bypass safety chceck?
  • Next by Date: Re: FindRoot + Compile = incompatible (?)
  • Previous by thread: Parallel search?
  • Next by thread: SetAttributes for entire package