RE: Command for Stopping Notebook Evaluation?
- To: mathgroup at smc.vnet.net
- Subject: [mg19242] RE: [mg19215] Command for Stopping Notebook Evaluation?
- From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
- Date: Wed, 11 Aug 1999 02:06:53 -0400
- Sender: owner-wri-mathgroup at wolfram.com
siegman at stanford.edu wrote:
----------------------------
The problem here is finding an easy, preferably keyboard-driven way to
select and evaluate a range of cells starting at the beginning of a
notebook and going part-way through it, using just a few keystrokes, and
without having to carefully select the range of cells with the mouse.
A quick and convenient way to initiate evaluation of an entire notebook,
at least on a Mac, is
ctrl-A (Select All Cells)
Enter (start evaluation)
But how can one insert a "Stop" cell down in the notebook, just after
the desired range, that will stop evaluation at that point, including
deselecting the remaining cells?
Inserting a cell with Abort[ ] doesn't do this -- evaluation of the
following cells continues.
One can insert a cell with Pause[some_large_number] and then hit
"ctrl-dot" (abort evaluation) to deselect the remaining cells.
But is there no "Stop[ ]" command to accomplish the same thing w
ithout operator attention?
----------------------
REPLY:
I give a solution below that programs a button to do the job.
I think you could change the file (MenuSetUp.tr) to add a menu selection
that would evaluate the expression:
With[{nb=SelectedNotebook[]},
NotebookFind[nb,"WillEvaluate", All, CellTags],
SelectionEvaluateCreateCell[nb]
]
The expression above is the same thing my button does (see below).
I think you can also associate the menu selection with some
keyboard short cut (e.g. Shft,E).
However, I haven't done much altering of (MenuSetup.tr)
and I don't feel like dealing with it right now.
Of course you should save a backup copy of (MenuSetUp.tr) before you edit
it.
-----------------------
NOW FOR MY BUTTON SOLUTION:
Paste the notebook expression below into a notebook. When you are given a
prompt select Yes to interpret the text. You then have a notebook
containing one button labeled
"Evaluate Cells".
(*** Notebook Begins ****)
(************************)
Notebook[{
Cell[BoxData[
TagBox[
ButtonBox[\(Evaluate\ Cells\),
ButtonFunction:>With[ {
Set[ nb,
SelectedNotebook[ ]]},
CompoundExpression[
NotebookFind[ nb, "WillEvaluate", All, CellTags],
SelectionEvaluateCreateCell[ nb]]],
ButtonEvaluator->Automatic],
DisplayForm]], NotebookDefault,
CellMargins->{{Inherited, Inherited}, {7, Inherited}}
]
},
ScreenRectangle->{{0, 800}, {0, 527}},
Editable->False,
WindowToolbars->{},
WindowSize->{Fit, Fit},
WindowMargins->{{238, Automatic}, {Automatic, 26}},
WindowFrame->"Palette",
WindowElements->{},
WindowFrameElements->"CloseBox",
WindowClickSelect->False,
ShowCellBracket->False,
CellMargins->{{0, 0}, {Inherited, 0}},
Active->True,
CellOpen->True,
ShowCellLabel->False,
ShowCellTags->False
]
(*********************)
(*** Notebook Ends ***)
----------------------------
Next select one or multiple cells in your notebook that you
want to evaluate. Make the menu selection
Find > Add Remove Cell Tags
At the "Cell Tag" prompt type:
WillEvaluate
Then click the Add button in the dialog box.
If you need to assign this CellTag to other cells you can select it from the
bottom of the dialog box once it's typed in.
OK at this point several cells in your Notebook have the option
CellTags->"WillEvaluate"
Click the "Will Evaluate" button and only the appropriate cells in your
notebook will evaluate. Evaluation will start at the top, and go down in
sequential order.
You can even skip cells you don't want to evaluate.
---------------------
With Mathematica anything is possible!
Well almost anything.
------------------
Regards,
Ted Ersek