0
$\begingroup$

I am working on a DockedCells toolbar for common tasks like Save, ClearAll, scrolling, etc., etc. My next addition to that toolbar is creating a button that executes Evaluation -> Evaluate Notebook. I only need the function to work. I already know how to insert that into a button.

When I type NotebookEvaluate[EvaluationNotebook[], InsertResults -> True]directly into a cell and doing a Shift-Enter nothing visual happens other than showing (Running...) for an extended period of time at the top window frame of the notebook. I am not sure what is supposed to happen here so I did an Abort Evaluation as too much time has passed. It should only take 1 second for this particular notebook.

Why isn't this behaving like doing Evaluation -> Evaluate Notebook from the menu?

$\endgroup$
  • 2
    $\begingroup$ If you run this it will run itself over and over, won't it? Related: 33197 $\endgroup$ – Kuba Oct 9 at 8:06
3
$\begingroup$

To add to what Kuba said: you can avoid the infinite loop by creating a button that starts the evaluation:

Button["Evaluate notebook",
 NotebookEvaluate[EvaluationNotebook[], InsertResults -> True],
 Method -> "Queued"
]

Note the Method option. Without it, the FE will freeze up completely.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Sjoerd-Smit it works!!! thank you so much. i had been struggling with this flocking thing all day. $\endgroup$ – Jules Manson Oct 10 at 6:28

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