Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Shared variables between notebooks?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg46786] Re: Shared variables between notebooks?
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Mon, 8 Mar 2004 04:10:21 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

On 3/7/04 at 1:34 AM, richter at cs.montana.edu (Neal Richter) wrote:

>1) It appears that when I have multiple notebooks open, the
>variables and functions are 'shared'..  ie they have global scope. 
>Can I change this?

Yes, use the BeginPackage/EndPackage for each notebook. Then, the variables in that notebook will be in a separate context and will distinct from variables in the global context. Note, you will have to deal with shadowing issues if the same name is used in more than one context.

>2) Is there a "#include" type command in mathematica?   I'd like to
>be able to have a notebook with common functions I use, and include
>it in other notebooks where use the functions.

Save the common functions in a .m file. Then, that file can be loaded at the beginning of a session using Get. This should give you equivalent functionality to the "#include" construct of C/C++.
--
To reply via email subtract one hundred and four


  • Prev by Date: RE: simple bug about Sum/Product function?
  • Next by Date: Differences in Random Numbers
  • Previous by thread: RE: ReplaceList -- Unexpected Answer
  • Next by thread: RE: Shared variables between notebooks?