MathGroup Archive 2009

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

Search the Archive

Re: Import "HeldExpression" element of MX file

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103237] Re: [mg103219] Import "HeldExpression" element of MX file
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Fri, 11 Sep 2009 05:26:58 -0400 (EDT)
  • References: <200909101125.HAA18361@smc.vnet.net>
  • Reply-to: drmajorbob at yahoo.com

In documentation, I see "HeldExpression" for Export, but not for DumpSave.

But Export doesn't do what you want, either... or not right away:

a = {1, 2, 3};
Export["a.mx", a];

Quit

Import["a.mx", "HeldExpression"]

HoldComplete[{1, 2, 3}]

?a

(a is undefined)

But this works:

Export["a.mx", Hold[a = {1, 2, 3}]];

Quit

imported = Import["a.mx", "HeldExpression"]

HoldComplete[Hold[a = {1, 2, 3}]]

imported = ReleaseHold@imported

Hold[a = {1, 2, 3}]

Bobby

On Thu, 10 Sep 2009 06:25:34 -0500, Szabolcs Horvát <szhorvat at gmail.com>  
wrote:

> I was trying to get the content of an MX file (there was a question
> about this about a week ago).  If I read the documentation correctly,
> this should be possible by importing the "HeldExpression" element.  But
> it doesn't seem to work.
>
> What am I doing wrong?
>
> This is what I did:
>
> a = {1,2,3}
> DumpSave["a.mx", a]
>
> Quit
>
> Import["a.mx", "HeldExpression"]
>
> (* Import returned nothing *)
>
> ?Global`*
>
> I expected that input would return something like Hold[a = {1,2,3}].
> Instead it simply re-imported the variable a into the workspace, just
> like Import["a.mx", "Expression"] does.
>


-- 
DrMajorBob at yahoo.com


  • Prev by Date: Oil and gold price chart, for your interest
  • Next by Date: Re: docs for Style, etc.
  • Previous by thread: Import "HeldExpression" element of MX file
  • Next by thread: Re: Import "HeldExpression" element of MX file