I have a notebook which allows to set some parameters at the start, and then does computations depending on these parameters. It is a long notebook and for readability it is broken up into sections and subsections etc.
Now for some values of the parameters, certain sections of calculations are not necessary, so I want to skip these whole sections, without having to put them in one evaluation cell. Is this possible?
I tried putting this piece of code in the beginning of the section I want to skip:
If[p>3,Goto[nextsection]];
And in the following section,
Label[nextsection];
This is the effect I want, except that it doesn't work, because for Goto the label needs to be in the same input cell.
When I run it manually I can of course just skip it, or comment it out, but I'm running this notebook automatically (using the code in my own answer to my question here) so I want to automate this skipping as well.
Function
s orModule
s or even packages to facilitate repeated evaluation. This should also help eliminate errors caused by wrong evaluation order etc.. $\endgroup$NotebookFind
andSelectionEvaluate
. But it seems less trouble to do as Yves suggests. $\endgroup$NotebookLocate["next"]; SelectionEvaluate[EvaluationNotebook[]];
in the beginning of the section that is to be skipped, and i mark some cell in the next section withnext
, the effect is something else. Everything is evaluated, and after this is done, the cells marked next are evaluated again $\endgroup$