Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I want to have my entire notebook be a conditional while statement. However, I don't want to merge all of my cells together, as it is a long and detailed process. Is there a way to create another cell that encompasses all of the smaller cells in my notebook?

share|improve this question
    
What do you mean by "I want to have my entire notebook be a conditional while statement?" Have you looked at Cell Groups? –  Mr.Wizard Jun 11 at 13:45
    
Just guesswork, but this could be useful: Creating Mathematica packages. Otherwise, your question is unclear. –  Yves Klett Jun 11 at 13:50
    
I want to be able to combine all of my original cells into a larger cell without losing the smaller subcells. I don't know how topics in Cell groups would help if I am trying to span across multiple cells to create another cell. @Mr.Wizard –  Kaisey Jun 11 at 14:08
    
Is is possible to simple rerun the notebook if, at the end, a certain condition is not met? –  Kaisey Jun 11 at 14:23

2 Answers 2

Grouping power is controlled by the Option CellGroupingRules, frequently defined in the style sheet system. The outermost Cell style by default is Title and has CellGroupingRules->{"TitleGrouping", 0}. Smaller values group larger values, and 0 is the smallest that is normally present. If you create a new Cell with negative value in this place it will group all below it.

For example if I create a new Cell (as entered in the Show Expression view):

Cell["Entire Notebook", "Title", CellGroupingRules->{"TitleGrouping", -10}]

It will group everything under it, e.g.:

enter image description here

share|improve this answer

I guess you are looking for something like this:

 If[condition, NotebookEvaluate[EvaluationNotebook[]]]

I'd suggest its somewhat cleaner to create a second 'control' notebook with some code similar to this:

 While[condition , NotebookEvaluate[First@Notebooks["Untitled-4"]]
share|improve this answer
    
your code seems to work, but I cannot figure out how to get the output of my cells to show. –  Kaisey Jun 11 at 18:54
    
I don't follow that - the output appears in the notebook same as if you did select-all;shift-enter. –  george2079 Jun 12 at 15:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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