 
 
 
 
 
 
Making new Contexts in Modules in a package
- To: mathgroup at smc.vnet.net
- Subject: [mg48368] Making new Contexts in Modules in a package
- From: Johan van der Meer <vdmeer at science.uva.nl>
- Date: Tue, 25 May 2004 07:18:19 -0400 (EDT)
- Reply-to: vdmeer at science.uva.nl
- Sender: owner-wri-mathgroup at wolfram.com
Hello, I am fairly new to mathematica and need some help with this 
context stuff :-).
What I want is to read with a function in a package some data (from a 
file), and put that in a (nested) list called listname`unmodifiedlist.
The idea is to make modifications to that list with other functions, 
where the new list name is listname`modifiedlist.
So what I want is a function called MakeList[data_String], that reads 
the data and puts it in the variable unmodifiedlist in the (newly made) 
context data.
Then, in my notebook I can simply type:
MakeList["data"]
Plot[data`unmodifiedlist]
to plot it for example.
I have in a package (package.m) a function that looks like this:
Function[data_String]:=
Module[{newcontext="",unmodifiedlist,readlist},
unmodifiedlist=ReadList[OpenRead[data],Number];
Close[data];
newcontext=ToString[context]<>"`";
$ContextPath=Join[$ContextPath,{newcontext}];
$Context=newcontext;
unmodifiedlist=readlist;
]
However, this doesn't seem to work. What I also tried is to change the 
context in the beginning of my module to "data`". I am not sure if this 
is good programming either, or if I should be wanting this with 
mathematica, but any help is greatly appreciated.
Regards,
Johan van der Meer

