2
$\begingroup$

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?

$\endgroup$
  • 1
    $\begingroup$ 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. $\endgroup$ – Mark McClure Mar 27 '13 at 21:34
4
$\begingroup$

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.

E.g:

In[1]:= 
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.

$\endgroup$
  • $\begingroup$ @TMH you're welcome. $\endgroup$ – geordie Mar 28 '13 at 5:46

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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