Is there any way to automatically evaluate an input cell after evaluating the previous one without the need to press ENTER?
$\begingroup$
$\endgroup$
2
-
1$\begingroup$ Out of curiosity - is there a reason why you wouldn't want to put them into the same cell? $\endgroup$– JonieCommented Aug 7, 2013 at 5:16
-
2$\begingroup$ @Jonie Because I want the next cell be evaluated only if certain conditions are met. I also want to separate the outputs. $\endgroup$– M6299Commented Aug 7, 2013 at 5:20
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
2
One way to acheive this is:
a = 1 + 2
If[a == 3, SelectionMove[EvaluationNotebook[], Next, Cell]];
SelectionEvaluate[EvaluationNotebook[]];
Other way is by adding CellTag
to our "conditional" cell. Use Crtl+J on that cell or use menu: Cell > Cell Tags > Add/Remove... to add tag, here I used "only if"
.
And then:
a = 1 + 2;
If[a == 3,
NotebookLocate["only if"];
SelectionEvaluate[EvaluationNotebook[]]
]
This seems to be more bulletproof.