3
$\begingroup$

Is there a way to DumpSave all the variables in the notebook? Or better whole notebook so that opening it would restore all the definitions.

$\endgroup$
3
  • $\begingroup$ If you give the notebook its own context, it is then easy to save all definitions in that context using DumpSave. $\endgroup$ Commented Sep 1, 2015 at 0:39
  • $\begingroup$ How do I do it? $\endgroup$
    – Al Guy
    Commented Sep 1, 2015 at 1:10
  • $\begingroup$ reference.wolfram.com/language/ref/menuitem/… $\endgroup$ Commented Sep 1, 2015 at 1:14

1 Answer 1

1
$\begingroup$

Definition of a variable in a context is done by myContext`a=100; !! Typing "a" later will not give 100!! To call the content defined above you need to specifiy the context other wise it is assumed Global`. So use myContext`a to get 100.

Do this with all the needed variables in the notebook. You can use DumpSave["file","myContext`"] to save all the definitions at once.

$\endgroup$
2
  • $\begingroup$ Does that mean that in principle all the global variables can be saved by DumpSave["file","Global"]`? $\endgroup$
    – Al Guy
    Commented Sep 2, 2015 at 2:06
  • $\begingroup$ I was not sure if Global` context is far more than your defined variables. I just tried ?Global`* and indeed I only get my defined variables/functions and not some genereal Mathematica definitions. $\endgroup$
    – Eisbär
    Commented Sep 2, 2015 at 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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