|
[Date Index]
[Thread Index]
[Author Index]
Re: DumpSave of packages - now it works
- To: mathgroup at smc.vnet.net
- Subject: [mg88902] Re: DumpSave of packages - now it works
- From: Hannes Kessler <HannesKessler at hushmail.com>
- Date: Wed, 21 May 2008 14:47:34 -0400 (EDT)
- References: <g0uavk$57s$1@smc.vnet.net>
... I had overseen changes made to system variables in one of the
packages. After including the System` context to the DumpSave, all
package functions are loaded correctly from the .mx file.
Regards,
Hannes Kessler
On 20 Mai, 13:00, Hannes Kessler <HannesKess... at hushmail.com> wrote:
> Hello,
>
> how to save interrelated packages to mx-files? This question is a
> follow-up to my previous onehttp://groups.google.de/group/comp.soft-sys.math.mathematica/browse_t...
>
> 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: How to connect one object to the other?
Next by Date:
Re: Re: an easy one?
Previous by thread:
Re: URL button on Documentation Center pages
Next by thread:
Re: Colors chosen for ListPlot, etc., in v. 6 -- followup
|