Message Boards Message Boards

0
|
877 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

How to make repeated notebook evaluations possible without restarting ?

Posted 4 months ago

Hello,

I am trying to use a notebook written by someone else, and I observe that in order to correctly repeat the notebook evaluation I have to exit the notebook, re-load the MATHEMATICA, and read the notebook again. Otherwise the calculations are not reproduced. I presume this behaviour may be caused by un-cleared variables. I made a search for how to use Clear[] and ClearAll[] but I don't feel any wiser. I certainly don't want to put all numerous symbols present in the notebook into a Clear command, but I also don't want to unconsciously Clear something important that is defined outside the notebook. Is there no single command that would make all my runs of the notebook identically prepared, with no left-overs from previous runs?

Lesław

POSTED BY: Leslaw Bieniasz
3 Replies
Posted 4 months ago

I would be happy to understand how this works. My questions:

1) where the information about the context is stored? In notebooks?

2) depending on (1), what will be the effect of the above command if I make a batch mode run, using as input the MATHEMATICA code in the ordinary text format (exported from a notebook, so that I don't expect the info about the context to be there)?

3) What is the purpose of "Evaluate" in the above command?

4) What is the intended meaning of "*" in the above command? A wildcard? (I don't find this info in online help)

Leslaw

POSTED BY: Leslaw Bieniasz
Posted 4 months ago

I will try to answer three of your questions.

1) Each notebook has an option CellContext. The option value is stored within each notebook.

3) While preparing this post I have seen that the Evaluate[Context ... syntax is no longer needed. Probably oldfashioned, something I have been using for years. One can just use:

Clear["`*"]

Same as in the Global context.

4) For the role of "*" see the documentation for Clear, under Details.

POSTED BY: Hans Milton
Posted 4 months ago

You can keep definitions in a particular notebook to be isolated from any other notebooks. Use this item under the Evaluation menu:

enter image description here

To clear all definitions in the "standalone" nb:

Clear@Evaluate[Context[] <> "*"]
POSTED BY: Hans Milton
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract