MathGroup Archive 2009

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

Search the Archive

Re: update notebook calculations on startup?

Make the cells you want to be automatically evaluated Initialization cells.
You do this be selecting them and then using Menu -> Cell -> Cell Properties
-> Initialization Cell. Or use Alt-CPI.

When you first save the notebook you will be asked if you want it saved as
an AutoGenerated Package. Answer NO. (That would generate a .m package file,
which you don't want. You just want the initialization cells to be evaluated
when you open the notebook.)

So far, what this will do is cause a pop-up window to ask if you want the
initialization cells evaluated when you first try to evaluate any cell in
the notebook. What you want is for the initialization cells to be
automatically evaluated when the notebook is opened. To get that open the
Options Inspector (Shift-Ctrl-O), set the selection in Show option values to
your notebook, and go to Notebook Options, Evaluation Options. Then set
InitializationCellEvaluation to True and InitializationCellWarning to False.
Then change Show option values to Global Preferences and set
GlobalInitializationCellWarning to False. (Otherwise you will obtain a
pop-up window on opening the notebook asking if you want to evaluate the
initialization cells.)

Then the desired cells will be automatically evaluated on opening the

Another possibility is to put all of the cells you want to initialize in one
Section of the notebook, without making them initialization cells. Then
select the entire section and evaluate it when you open the notebook. This
isn't automatic but it is fairly easy.

David Park
djmpark at 

From: donkey [mailto:psilo_naut at]

I'm using mathematica to do some calculations on financial data and want to
know if there is a way to make the calculations execute automatically when I
notebook is open.

For example I have a notebook with the following code:
stock1 = "ASX:RHC"

stock2 = "ASX:PRY"

currentDate = {2009, 5, 21}

correlationOffset = -150

DateListPlot[{FinancialData[stock1, "Jan.1,2009"],
=C2  FinancialData[stock2, "Jan. 1,2009"]}, Joined -> True,
=C2 PlotLabel -> "Blue -> " + stock1 +=C2  "Red -> " + stock2,
=C2 FrameLabel -> {"Date", "Closing Price"}]

I would like it to update the graph automatically rather than me having to
go through and shift+enter on each of the lines.


  • Prev by Date: Re: list manipulation
  • Next by Date: Re: Basic question about Mathematica Interface
  • Previous by thread: Re: update notebook calculations on startup?
  • Next by thread: Re: update notebook calculations on startup?