# Deleting variable assignments in a sub-notebook which is called from my main notebook

I have two notebooks; one main notebook which calls another notebook several times in a loop. I want to delete the assignments of variables in the sub-notebook which is called from the main one.

Using ClearAll["Global*"] in the sub-notebook also clears the main notebook variable assignments, which I want to protect; I just want to clear the assignments in the sub-notebook.

How could I solve this?

• I strongly recommend to convert your notebook to a function e.g. proc1[]: = Module[{localvariables...}, ...]. You will have more flexibility and no questions like this anymore. – Kuba Jul 28 '16 at 6:36
• @Kuba Will I write the procedure proc1[] into the notebook cell or elsewhere ? The problem is I use notebooks since it allows to use mathematical superscript and subscripts, which makes the calculations easy to follow and while writing a procedure in a .m script; could I use Basic Math Assistant Pallette ? – ahmethasim Jul 28 '16 at 6:43
• You can define it in a notebook, no problem. Just be sure to evaluate this definition in a fresh session. – Kuba Jul 28 '16 at 6:45
• This is a good start tutorial/DefiningFunctions – Kuba Jul 28 '16 at 6:46
• Set the default CellContext for the notebooks to Notebook. Any variables that you need in Global  then explicitly set with the context name, e.g. Globalx = 2`. – Edmund Aug 1 '16 at 10:03