1
$\begingroup$

This question already has an answer here:

Dynamic[x=7]; does not make x dynamic! But Dynamic[x=7;] makes x dynamic with initial value 7. The problem with the later is the presence of Null in the output. My question is: how can I assign a (big) value (or a huge list, etc.) to a dynamic variable AND suppress any possible output (including Null)?

$\endgroup$

marked as duplicate by Mr.Wizard Mar 5 '13 at 18:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    $\begingroup$ What's the point of Dynamic then ? $\endgroup$ – b.gates.you.know.what Mar 5 '13 at 17:39
  • 2
    $\begingroup$ Have you investigated DynamicWrapper? $\endgroup$ – John Fultz Mar 5 '13 at 17:40
  • 1
    $\begingroup$ Read the tutorials on Dynamic. There's no such thing as a dynamic variable. There's only stuff that shows as the dynamically updated "current" value of an expression, and in the process of calculating that current value, it might update other "non-dynamic" variables $\endgroup$ – Rojo Mar 5 '13 at 17:58
  • $\begingroup$ I closed this question as a duplicate. (It is a common problem therefore "too localized" is inaccurate.) If anyone has a suggestion for a better duplicate (on Mathematica.SE) let me know. $\endgroup$ – Mr.Wizard Mar 5 '13 at 18:34
  • $\begingroup$ @Mr.Wizard Well, actually it's a duplicate of stackoverflow.com/questions/1179430/… $\endgroup$ – Ajasja Mar 5 '13 at 19:11
3
$\begingroup$

Dynamic doesn't work the way you think it does. See this answer for a full explanation.

In short, Dynamic doesn't do anything until it is actually displayed on screen.

$\endgroup$
1
$\begingroup$

Dynamic is only updated if it is displayed. Dynamic[]; is never displayed so it is never updated. Dynamic[...;] returns a dynamic that always returns Null, but is never the less updated.

Here is an example that demonstrates the problem:

x = .5;
Dynamic[Print["will not print:", x]];
Dynamic[Print["Should print:", x];]
Slider@Dynamic@x
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.