Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Dynamic

  • To: mathgroup at smc.vnet.net
  • Subject: [mg87376] Re: Dynamic
  • From: "David Park" <djmpark at comcast.net>
  • Date: Wed, 9 Apr 2008 05:53:25 -0400 (EDT)
  • References: <ftfeji$bue$1@smc.vnet.net>

Hi Gianluca,

I think what you are missing is the use of a second argument in Dynamic. See 
the 'Introduction To Dynamic' tutorial and scroll down toe 'The Second 
Argument of Dynamic'.

So I think you want:

DynamicModule[{p = 0},
 {Slider[Dynamic[p]], Dynamic[p + 1, (p = # - 1) &]}]

This is always a little difficult to get used to but # is the value that you 
want displayed (p+1) so the pure function is the inverse function.


-- 
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/


"Gianluca Gorni" <gianluca.gorni at dimi.uniud.it> wrote in message 
news:ftfeji$bue$1 at smc.vnet.net...
>
> Hi!
>
> I am trying to learn how the new Dynamic features work.
>
> The following two Manipulate expressions give outputs that
> make perfect intuitive sense to me:
>
> Manipulate[q = p + 1;
>  q,
>  {p, 0, 1}]
>
> Manipulate[q = p + 1;
>  FullForm@q,
>  {p, 0, 1}]
>
> (don't keep both outputs active at the same time
> if you are short on battery power!)
>
> When I try to reproduce similar effects with
> DynamicModule, I get all sorts of different behaviours.
> Compare the following:
>
> DynamicModule[{p = 0, q},
>  q = p + 1;
>  {Slider[Dynamic@p], q}]
>
> DynamicModule[{p = 0, q},
>  q = p + 1;
>  {Slider[Dynamic@p], Dynamic@q}]
>
> DynamicModule[{p = 0, q},
>  q = Dynamic[p] + 1;
>  {Slider[Dynamic@p], q}]
>
> DynamicModule[{p = 0, q},
>  q = Dynamic[p] + 1;
>  {Slider[Dynamic@p], FullForm@q}]
>
> DynamicModule[{p = 0, q},
>  q = Dynamic[p] + 1;
>  {Slider[Dynamic@p], FullForm@Dynamic@q}]
>
> DynamicModule[{p = 0, q},
>  q = Dynamic[p] + 1;
>  {Slider[Dynamic@p], Dynamic@FullForm@q}]
>
> DynamicModule[{p = 0, q},
>  q = Dynamic[p + 1];
>  {Slider[Dynamic@p], q}]
>
> DynamicModule[{p = 0, q},
>  q = Dynamic[p + 1];
>  {Slider[Dynamic@p], q[[1, 1]]}]
>
> DynamicModule[{p = 0, q},
>  q = Dynamic[p + 1];
>  {Slider[Dynamic@p], q[[1, 2]]}]
>
> DynamicModule[{p = 0, q},
>  q = Dynamic[p + 1];
>  {Slider[Dynamic@p], Dynamic@q}]
>
> DynamicModule[{p = 0, q},
>  q = Dynamic[p + 1];
>  {Slider[Dynamic@p], Dynamic[q[[1, 1]]]}]
>
> DynamicModule[{p = 0, q},
>  q = Dynamic[p + 1];
>  {Slider[Dynamic@p], Dynamic[q[[1, 2]]]}]
>
> DynamicModule[{p = 0, q},
>  q = Dynamic[p + 1];
>  {Slider[Dynamic@p], FullForm@q}]
>
> DynamicModule[{p = 0, q},
>  q = Dynamic[p + 1];
>  {Slider[Dynamic@p], Dynamic@FullForm@q}]
>
> DynamicModule[{p = 0, q},
>  q = Dynamic[p + 1];
>  {Slider[Dynamic@p], FullForm@Dynamic@q}]
>
> Right now all I need is a few kind words of encouragement
> from somebody who has already mastered dynamic interactivity...
>
> Gianluca
>
> 



  • Prev by Date: Re: Dynamic
  • Next by Date: Re: Bug in ExportString?
  • Previous by thread: Re: Dynamic
  • Next by thread: Re: Dynamic