MathGroup Archive 2008

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

Search the Archive

Re: Strange interaction between local symbols of a proc inside the

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84893] Re: Strange interaction between local symbols of a proc inside the
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Fri, 18 Jan 2008 05:47:50 -0500 (EST)
  • Organization: Uni Leipzig
  • References: <fmngdf$3e7$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de

Hi,

try

cc = ContinuousAction -> False;

Manipulate[
  proc[], {xMax, 10, ControlType -> None}, {yMax, 1,
   ControlType -> None},
  Initialization :> {proc[] := DynamicModule[{yy = 2, xx = 8},
      Dynamic[
       Plot[Sin[x], {x, 0, xMax},
        PlotRange -> {Automatic, {-yMax, yMax}}, Frame -> True,
        FrameLabel -> {Slider[Dynamic[xMax], {1, 2*xx}, cc],
          VerticalSlider[Dynamic[yMax], {1, 2*yy}, cc]},
        RotateLabel -> False]]]}]

..

Regards
   Jens

Nasser Abbasi wrote:
> Mathematica 6.0.1 on windoz.
> 
> Below are 2 examples. In the first I have a proc in the init of a Manipulate 
> which uses Dynamic symbols to obtain the limits of a plot. (the x and y 
> limits).
> 
> In the first example, I have ONE local symbol called yy in the proc which is 
> used as the maximum this dynamic symbol goes to.  This seems to work ok:
> 
> 
> (*********** EXAMPLE 1 works ******************)
> cc=ContinuousAction->False;
> 
> Manipulate[proc[],
>   {xMax, 10, ControlType -> None},
>   {yMax, 1, ControlType -> None},
>   Initialization :>
>   {
>    proc[] := Module[{yy},
>    yy = 2;
>    Dynamic[Plot[Sin[x], {x, 0, xMax},
>      PlotRange -> {Automatic, {-yMax, yMax}},
>      Frame -> True,
>      FrameLabel -> {Slider[Dynamic[xMax], {1, 10},cc],
>                     VerticalSlider[Dynamic[yMax], {1, 2*yy},cc]},
>      RotateLabel -> False
>      ]
>     ]
>    ]
>  }
> ]
> 
> 
> Now, I added another local symbol call xx and did the same using it for the 
> x-range. Now I get errors. You'd have to move the slides couple of times to 
> see the error.
> 
> (********** EXAMPLE 2  error *******************)
> cc=ContinuousAction->False;
> 
> Manipulate[proc[],
>   {xMax, 10, ControlType -> None},
>   {yMax, 1, ControlType -> None},
>   Initialization :>
>   {
>    proc[] := Module[{yy,xx},
>    yy = 2;
>    xx = 8;
>    Dynamic[Plot[Sin[x], {x, 0, xMax},
>      PlotRange -> {Automatic, {-yMax, yMax}},
>      Frame -> True,
>      FrameLabel -> {Slider[Dynamic[xMax], {1, 2*xx},cc],
>                     VerticalSlider[Dynamic[yMax], {1, 2*yy},cc]},
>      RotateLabel -> False
>      ]
>     ]
>    ]
>  }
> ]
> 
> Why would the first example work, and the second not work?
> I can fix the second example, by making yy and xx localized to Manipulate 
> and not local symbols to the proc[] as follows
> 
> (********** EXAMPLE 3 works *******************)
> cc=ContinuousAction->False;
> 
> Manipulate[proc[],
>   {xMax, 10, ControlType -> None},
>   {yMax, 1, ControlType -> None},
>   {yy, 1, ControlType -> None},
>   {xx, 1, ControlType -> None},
> 
>   Initialization :>
>   {
>    proc[] := Module[{},
>    yy = 2;
>    xx = 8;
>    Dynamic[Plot[Sin[x], {x, 0, xMax},
>      PlotRange -> {Automatic, {-yMax, yMax}},
>      Frame -> True,
>      FrameLabel -> {Slider[Dynamic[xMax], {1, 2*xx},cc],
>                     VerticalSlider[Dynamic[yMax], {1, 2*yy},cc]},
>      RotateLabel -> False
>      ]
>     ]
>    ]
>  }
> ]
> 
> 
> It seems if a local symbol to Manipulate depends on a local symbol to a 
> proc[] 'called' by Manipulate as in the first 2 examples above, this will 
> result in something not nice.  But I do not understand why the first example 
> works, and the second does not. It seems adding a second interaction broke 
> something internally by accident?
> 
> Any idea? And on the subject, could any one be kind enought and summarize 
> what is the visibility scope of a Dynamic symbol in Mathematica?
> 
> thanks,
> Nasser
> 
> 
> 
> 


  • Prev by Date: Re: Re: Version 6 graphics can be painfully slow
  • Next by Date: Re: Wavelet "filter"?
  • Previous by thread: [M6] Aligning graphics on frame boundaries
  • Next by thread: Mathematica commenting of code using (* *) can't be nested well.