Message Boards Message Boards

2 Replies
1 Total Likes
View groups...
Share this post:

re-running a notebook after making changes

Posted 10 years ago
I am creating notebooks which usually get edited. I then want to evaluate the newly saved notebook but I want it to be evaluated from scratch and not use data which I had created in the previous version during the current session. However,  I have noticed that the new notebook does not work well because it seems that the data associated with the previously run notebook is not cleared. I want to rerun the notebook after saving a new version and have it be evaluated from scratch.  The only way this work is for me to exit Mathematica, restart it , reload the notebook and then evaluate the notebook in the new Mathematica session. This seems clearly inefficient. My question is how to reevaluate the changed, saved notebook from scratch? I have tried putting a 'clear all' as the first line but this does not seem to throw away all data, etc from the previous evaluation.  Can you guys please clue me in. I feel this is a very basic question and am embarrassed to ask, but need a better way.

Thanks very much!

POSTED BY: Comer Duncan
2 Replies

You can specify the context (like a scope) of variables unique to a notebook. See the screenshot. In this case, you do not have to clear the variables by yourself. Because everytime you open the notebook, there would be a new "x". That is the number 64007 would change automatically, you will always have a new variable with different context. 

POSTED BY: Shenghui Yang
Posted 10 years ago
You should start the notebook with the line:

However this will clear all open notebooks, if you do not want this make sure to turn off dynamic updating under the Evaluation tab.

I believe that this is Mathematica syntax for "clear all" but I may be mistaken.
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract