|
[Date Index]
[Thread Index]
[Author Index]
Re: if I open multiple files in Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg64155] Re: [mg64124] if I open multiple files in Mathematica
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Thu, 2 Feb 2006 19:09:07 -0500 (EST)
- Organization: Mathematics & Statistics, Univ. of Mass./Amherst
- References: <200602020505.AAA16055@smc.vnet.net>
- Reply-to: murray at math.umass.edu
- Sender: owner-wri-mathgroup at wolfram.com
As you have discovered, definitions (rules) are associated with a
Mathematica session and NOT with a Mathematica notebook.
One work-around is to have use a different Mathematica Context for each
notebook. A context is essentially a "namespace". See the Mathematica
Book's materials for details.
Here's a simple example. You have two notebooks. In one you evaluate
the following input cells:
Begin["This`"]
x=100;
End[]
If you evaluate any cells in that notebook after evaluating the Begin
cell and the x = 100 cell, but before evaluating the End[] cell, x will
take the vaule 100 there.
In the other notebook you evaluate input cells:
Begin["Other`"]
x = "hello";
End[]
If you evaluate any cells in that notebook after evaluating the Begin
cell and the x = "hello" cell, but before evaluating the End[] cell, x
will take the vaule "hello" there.
But: After you have evaluated both End[] cells, now no matter in what
notebook you do further evaluations, if you refer to x you will just get
the symbol x and neither of those two values. But if you want to use
one of the values from within those context, you qualify x with the
context name:
This`x
100
This`x + 23
123
Other`x
"hello"
StringJoin[Other`x, ", world!"]
hello, world
Jackie wrote:
> The variables in different files will be cross-referenced. I don't like
> this feature, What should I do ?
>> thanks.
>
>
--
Murray Eisenberg murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
Prev by Date:
Problem to evaluate a function inside a function
Next by Date:
Re: Matrix decomposition with NullSpace and QRDecomposit
Previous by thread:
if I open multiple files in Mathematica
Next by thread:
Re: if I open multiple files in Mathematica
|