2
$\begingroup$

A nice way to centralize various tasks in one notebook is the NotebookEvaluation function. For instance I can evaluate ten notebooks from a single notebook (e.g. allnotebooks.nb) like this:

NotebookEvaluation["nbpath_1.nb"]
NotebookEvaluation["nbpath_2.nb"]
...
NotebookEvaluation["nbpath_10.nb"]

I would like to update this automatically, e.g. every six hours, but it doesnt work. My idea is to create a master notebook with the following code (here: 15 seconds):

Dynamic[NotebookEvaluate[
  "C:\\Users\\myname\\Desktop\\allnotebooks.nb"], 
 UpdateInterval -> 15]

And it works without using dynamic. Using dynamic gives the following error:

An unknown box name (ToBoxes) was sent as the BoxForm for the expression.
Check the format rules for the expression.

Does someone have an idea about the reason? Is Dynamic not an adequate function to do this?

Thanks a lot for any ideas!

P.S. I tested it with this code for the sub notebooks, e.g. for nbpath_1.nb:

path = "C:\\Users\\myname\\Desktop\\";
time = DateString[{"YearShort", "Month", "Day", "_", "Hour", "Minute",
     "Second"}];
data = Table[RandomInteger[{1, 10}], {10}];
Export[path <> "nb1_" <> time <> ".xls", data];
$\endgroup$
3
  • 3
    $\begingroup$ I think you can check ScheduledTasks to manage repeated evaluation easily. $\endgroup$
    – Kuba
    Sep 5, 2013 at 16:07
  • 3
    $\begingroup$ ScheduledTasks is more appropriate. Dynamic is for display. You could try Dynamic[NotebookEvaluate[ "C:\\Users\\myname\\Desktop\\allnotebooks.nb"];ExampleData[{"TestImage", "Lena"}], UpdateInterval -> 15] $\endgroup$
    – Rojo
    Sep 5, 2013 at 16:45
  • $\begingroup$ ScheduledTasks works perfectly. Especially the RunScheduledTask option. Thanks a lot for your help! Patrick $\endgroup$ Sep 6, 2013 at 7:52

1 Answer 1

2
$\begingroup$

Just for the record:

ScheduledTasks will be more convenient to manage this task. Just like:

RunScheduledTask[Print@DateList[], {3, 2}]

Also, Rojo said:

ScheduledTasks is more appropriate. Dynamic is for display. You could try Dynamic[NotebookEvaluate[ "C:\\Users\\myname\\Desktop\\allnotebooks.nb"];
ExampleData[{"TestImage", "Lena"}], UpdateInterval -> 15]

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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