I‘m sometimes (mainly on vacation) Mathematica online on an iPad. Up to now I could not find a way to evaluate the initialization cells (only) which is a menu command in Mathematica on my Mac. Does anyone know how I can do this?
Asked
Active
Viewed 122 times
5
-
Why is this needed? Wouldn't those cells still be evaluated when opening the notebook? Do you want a line of code that calls all cells which are initialization cells? – Gladaed Feb 14 '19 at 13:32
-
1@Gladaed: No they are not evaluated when opening the notebook. I need the initialization cells for utility functions, data preparation etc. So it is more than convenient to have them executed seperately - this is what they are made for, isn’t it? – mgamer Feb 14 '19 at 14:08
2 Answers
2
FrontEndToken solution won't work because it is not implemented yet.
You could filter InitializationCell from Cells[], then scan them with SelectionMove+SelectionEvaluate. Unfortunately it seems you can select CellContents but not Cell so SelectionEvaluate won't work...
Assuming you don't need them to generate output you could do:
ToExpression @* First @* NotebookRead /@ Select[CurrentValue[#,InitializationCell]&] @ Cells[];
Kuba
- 136,707
- 13
- 279
- 740
0
You can call
FrontEndExecute[FrontEndToken[InputNotebook[], "EvaluateInitialization"]]
this works for most FrontEnd interactions.
Gladaed
- 987
- 4
- 12