5
$\begingroup$

Why does this simple expression freezes Mathematica? (version 10.3.0, Windows 7 64)

SetOptions[EvaluationNotebook[], 
 NotebookDynamicExpression :> (Dynamic[
    Refresh[If[! NumericQ[myColorID], myColorID = 1]; 
     myColorID = If[myColorID == 2, 1, 2], UpdateInterval -> 0.5], 
    TrackedSymbols -> {}])]

And yet, when I do just the Dynamic part, it works fine:

Dynamic[Refresh[If[! NumericQ[myColorID], myColorID = 1]; 
  myColorID = If[myColorID == 2, 1, 2], UpdateInterval -> 0.5], 
 TrackedSymbols -> {}]

(and the same problem exists when using SetOptions[$FrontEndSession, FrontEndDynamicExpression :>... )

$\endgroup$
1
  • $\begingroup$ Freezes 10.2 on linux too. $\endgroup$ – bobbym Oct 19 '15 at 0:10
4
$\begingroup$

I don't know why it doesn't work, but you can skip Dynamic and put TrackedSymbols to Refresh. With this setup it won't make any troubles.

SetOptions[
 EvaluationNotebook[], 
 NotebookDynamicExpression :> Refresh[
  If[! NumericQ[myColorID], myColorID = 1]; 
  myColorID = If[myColorID == 2, 1, 2], 
  UpdateInterval -> 0.5, 
  TrackedSymbols -> {}
 ]
]

Notebook|FE|Cell DynamicExpressions are by default wrapped/treated as Dynamic by FrontEnd, this is why we could do this.

Here's an answer where I;ve shown that Dynamic/Refresh behaviour in those options is slightly different: What is the point of Refresh?

$\endgroup$
2
  • $\begingroup$ thank you. I'm reporting it as a bug. $\endgroup$ – P. Fonseca Oct 19 '15 at 8:22
  • $\begingroup$ @P.Fonseca ok, good luck :) $\endgroup$ – Kuba Oct 19 '15 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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