|
[Date Index]
[Thread Index]
[Author Index]
DumpSave of packages
- To: mathgroup at smc.vnet.net
- Subject: [mg88898] DumpSave of packages
- From: Hannes Kessler <HannesKessler at hushmail.com>
- Date: Tue, 20 May 2008 07:00:12 -0400 (EDT)
Hello,
how to save interrelated packages to mx-files? This question is a
follow-up to my previous one
http://groups.google.de/group/comp.soft-sys.math.mathematica/browse_thread/thread/99547ed0a031ccbe/c2f36a4341d05396?lnk=gst&q=kessler#c2f36a4341d05396
DumpSave["package.mx", {"package`", "otherpackage`"}] does not work
always if the packages depend on each other and contain subcontexts.
No problems using only .m files.
Here is roughly what I tried:
1. Start the notebook package.nb (working directly with package.m
gives similar results).
2. Assign Contexts[] to a variable initialContexts
3. Execute the package itself
4. Execute Contexts[] again, delete all contexts already in
initialContexts and assign the result to a variable requiredContexts
5. DumpSave["package.mx", requiredPackages]
Now, executing Needs["package`"] loads the correct context package`
but some functions do not work anyways.
Below are the details (paste into a notebook). Any ideas are
appreciated.
Regards,
Hannes Kessler
(* not an initialization cell *)
virgin\[LetterSpace]contexts = Contexts[];
BeginPackage["package`", {...}]
...
EndPackage[];
(* Now the DumpSave, again not an initialization cell *)
nb = EvaluationNotebook[];
Module[{
required\[Dash]contexts =
DeleteCases[
Contexts[], _?(MemberQ[virgin\[LetterSpace]contexts, #] &)],
nb\[Dash]file = Replace["FileName", NotebookInformation[nb]][[2]],
nb\[Dash]dir =
ToFileName @
First @ Replace["FileName", NotebookInformation[nb]],
mx\[Dash]file, mx\[Dash]dir, save
},
mx\[Dash]file =
StringReplace[nb\[Dash]file,
s_ ~~ ".nb" ~~ EndOfString :> s <> ".mx"];
mx\[Dash]dir =
ToFileName[{nb\[Dash]dir, mx\[Dash]file, ToString @ $SystemID}];
If[ FileNames@mx\[Dash]dir === {},
CreateDirectory @ mx\[Dash]dir];
save = Hold[
DumpSave[ToFileName[{mx\[Dash]dir}, mx\[Dash]file],
"contexts"]] /. {"contexts" -> required\[Dash]contexts};
ReleaseHold @ save]
Prev by Date:
Re: Problems with ListPlot
Next by Date:
Re: an easy one?
Previous by thread:
Re: sending programatically output to clipboard
Next by thread:
Re: DumpSave of packages
|