MathGroup Archive 2007

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

Search the Archive

Re: Issue with Synchronization between Manipulate and functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79015] Re: [mg78978] Issue with Synchronization between Manipulate and functions
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Sun, 15 Jul 2007 01:17:55 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200707140643.CAA03713@smc.vnet.net>
  • Reply-to: murray at math.umass.edu

On my Windows XP system with Mathematica 6.0.1, I'm seeing each integer, 
from 1 through 10 inclusive, displayed.  Nothing skipped.

I don't know whether the result should be so sensitive to the PC's 
strength.  After all, this Manipulate is being asked to do very little. 
(My PC, about 3 years old, is a 3.2GHz Pentium XE, with 2 GB RAM.)

Nasser Abbasi wrote:
> (Mathematica 6.0, Windows XP, OLD PC)
> 
> Manipulate[expr,{n,1,10}] is supposed to evaluate expr for each value
> of 'n'.
> 
> There seems to be a synchronization problem between Manipulate[] and
> completing evaluation of expr, when there is a Graphics inside expr.
> 
> I have a simple example below, where expr is a function, which
> displays 'n'.
> 
> ---- CODE -----------------
> 
> process[a_] := Graphics[ {Text[StringJoin["a=", ToString[a]]]},
> ImageSize -> {40} ]
> 
> Manipulate[ process[a],  {a, 1, 10, 1} ]
> 
> ---- END CODE -----------------------
> 
> If you run the above, and click on 'play' and look at the display
> inside the Graphics window, you will see that not every integer is
> being printed. i.e. NOT each 'n' is being displayed.
> 
> Some values of 'n' are skipped.  What is being displayed is something
> like 2,4,6... or 1,2,3,5,6,... instead of 1,2,3,4,5,.... i.e. some numbers
> do NOT get displayed, while Manipulate itself is of course is
> incrementing 'n' correctly.  This ofcourse might depend on speed of
> the computer itself and other factors, but on my slow PC, I see this
> is clearly happening.
> 
> I think this happens because Manipulate is calling expr before the
> previous Graphics[] which displays the text is fully flushed out to
> display within the function expr.
> 
> Hence, expr returns back, and Manipulate now calls it with n+1 value,
> before the previous n value is yet displayed, and so n+1 overwrites
> earlier 'n' in some internal Graphics buffer, and what I see is n+1
> and 'n' is missing.
> 
> I need a way  to make sure Graphics[] is completed inside expr before
> I return back from the function, back to Manipulate, to prevent this
> problem.
> 
> To confirm this,  when I 'slow' down Manipulate using the 'slow'
> control, now I see that each number is being displayed ok. So this
> clearly is telling me there is a buffer overrun problem.
> 
> I need to study the documentation more, I just started using
> Manipulate, but I noticed this problem.
> 
> Do you think I am interpreting this ok, or am I doing something silly
> elsewhere?
> 
> thank you
> Nasser
> 
> 

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: Re: LinksBar
  • Next by Date: Re: annoying documentation in 6 (rant)
  • Previous by thread: Issue with Synchronization between Manipulate and functions called by Manipulate with Graphics[]
  • Next by thread: TrackedSymbols