MathGroup Archive 2008

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

Search the Archive

DumpSave of packages

  • To: mathgroup at
  • Subject: [mg88898] DumpSave of packages
  • From: Hannes Kessler <HannesKessler at>
  • Date: Tue, 20 May 2008 07:00:12 -0400 (EDT)


how to save interrelated packages to mx-files? This question is a
follow-up to my previous one

DumpSave["", {"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["", 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

Hannes Kessler

(* not an initialization cell *)
virgin\[LetterSpace]contexts = Contexts[];

BeginPackage["package`", {...}]

(* Now the DumpSave, again not an initialization cell *)
nb = EvaluationNotebook[];
  required\[Dash]contexts =
    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 =
   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