Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a notebook which contain all the variables and defined functions. I want to do two tasks. As an example, I want to find the density and energy which have equations in terms of above mentioned variables and functions. If I write one code for these two tasks, it is a very large notebook. So, if I have separate notebooks for "variables and functions",density and energy, how can I connect each notebook so that they can run properly and give the result? Could anyone please help me to do this?

share|improve this question
Can you be more specific about the nature of your"variables and functions"? How huge are we talking? You might be able to place them in a .m file and read that in. Or you might be able to place them in an initialization cell in a separate (collapsed) section in the same notebook. A little more information might help. – Mark McClure Mar 27 '13 at 21:34
up vote 4 down vote accepted

If you open and evaluate the 'functions and variables' notebook and then evaluate the second (or third or fourth) notebook everything should work fine. You can use Names[$Context <> "*"] to see what variables and functions have been defined in the current session.


a = blah;
b = blah;
c = blah;

{a, b, c}

Out[4]= {blah, blah, blah}

In[5]:= Names[$Context <> "*"]

Out[5]= {"a", "b", "blah", "c"}

More detail here.

share|improve this answer
Thanks geordie. – TMH Mar 28 '13 at 4:37
@TMH you're welcome. – geordie Mar 28 '13 at 5:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.