Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to keep cells closed?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32432] Re: [mg32244] How to keep cells closed?
  • From: Omega Consulting <omega_consulting at yahoo.com>
  • Date: Sat, 19 Jan 2002 19:03:35 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

At 02:17 AM 1/9/2002, jose flanigan wrote:
>I have a large cell that contains many small formulas I frequently
>use. When I evaluate the notebook, the output of each of these is
>shown in the corresponding  output cell. Now, I know how to suppress
>the output using the semicolon, but what I would really like this to
>have the cell closed until I specifically opened it (by clicking on
>the bracket) to examine the result.
>
>Is there a way to do this?
>
>Thanks in advance.

Here's some code for doing that:

Attributes[CloseMyOutput]={HoldAll};

CloseMyOutput[
     CompoundExpression[expr___,
       Null]] := (SuppressedOutput[CompoundExpression[expr]];)

SuppressedOutput[x_]:=
   Module[{nb=EvaluationNotebook[]},
     CloseGroup[nb];
     x;
     ]

CloseMyOutput[x_] :=NormalOutput[x]

NormalOutput[x_]:=
   Module[{nb=EvaluationNotebook[]},
     If[x=!=Null,
       CellPrint[
         Cell[BoxData[ToBoxes[x]],"Output",
           CellLabel->"Out["<>ToString@$Line<>"]="]];
       CloseGroup[nb];
       x;,
       SelectionMove[nb, All,GeneratedCell];
       If[NotebookRead[nb]=!={}, CloseGroup[nb],
         SelectionMove[nb, All,EvaluationCell];
         SelectionMove[nb,After,Cell];
         ];
       x;
       ]
     ]

CloseGroup[nb_]:=
    (SelectionMove[nb, All,EvaluationCell];
     SelectionMove[nb, All, CellGroup];
     FrontEndExecute[{FrontEndToken["OpenCloseGroup"]}];
     SelectionMove[nb,After,Cell];)

Then you can wrap your commands in this function.

CloseMyOutput[2+2]

Or you can have it automatically wrapped around all input.

$Pre=CloseMyOutput;

2+2

--------------------------------------------------------------
Omega Consulting
"The final answer to your Mathematica needs"

Spend less time searching and more time finding.
http://www.wz.com/internet/Mathematica.html



  • Prev by Date: Re: Pink Parentheses
  • Next by Date: RE: When does x/x not equal 1?
  • Previous by thread: RE: How to keep cells closed?
  • Next by thread: Update for MathSource/Stein's mathematica toolbox for Matlab?