Re: restore all but ! variables [message #60629] |
Thu, 29 May 2008 14:04  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
Jeremy Bailin wrote:
> Does anyone know of a convenient way of restoring the contents of a
> SAVEd file created using /ALL that will restore everything except for
> system variables (ie. anything starting with !)? I have some old .sav
> files from a different system with a different file structure, and
> doing a simple RESTORE over-writes things like !PATH that really need
> to be from the new system.
I think the IDL_Savefile class should be able to do what you want, but
the "everything else" needs to be enumerated i.e. regular variables
and common blocks should be sufficient:
IDL> save, /all, filename='all.sav'
IDL> exit
~$ idl
IDL> savfile = obj_new('idl_savefile', filename='all.sav')
IDL> savfile->restore, savfile->names(), /verbose ; regular
variables
IDL> savfile->restore, savfile->names(/common_block), /common, /
verbose ; common blocks
IDL> obj_destroy, savfile
Mike
--
www.michaelgalloy.com
Tech-X Corporation
Software Developer II
|
|
|
|
Re: restore all but ! variables [message #60633 is a reply to message #60631] |
Thu, 29 May 2008 09:14   |
Allan Whiteford
Messages: 117 Registered: June 2006
|
Senior Member |
|
|
Jeremy Bailin wrote:
> Does anyone know of a convenient way of restoring the contents of a
> SAVEd file created using /ALL that will restore everything except for
> system variables (ie. anything starting with !)? I have some old .sav
> files from a different system with a different file structure, and
> doing a simple RESTORE over-writes things like !PATH that really need
> to be from the new system.
>
> On a related note, is there a way to rename a common block? I.e. I
> have a .sav file that contains a previous version of a common block,
> but in my current code I have extended the common block to include
> some new variables. So I would like to do something like this so that
> I can resurrect the saved data into the new data structure where my
> new code can operate on it:
>
> restore, 'oldsavedfile'
> ***RENAME cb (WITH ASSOCIATED vars) TO oldcb (WITH ASSOCIATED
> oldvars)***
> common_block, cb, LIST OF VARIABLES IN NEW COMMON BLOCK
> ASSIGN oldvars TO EQUIVALENT vars
> save, 'newsavedfile', ....
>
> -Jeremy.
Jeremy,
If you've not seen them you should look at Craig Markwardt's
save/restore routines which could provide some help:
http://cow.physics.wisc.edu/~craigm/idl/cmsave.html
Thanks,
Allan
|
|
|
Re: restore all but ! variables [message #60752 is a reply to message #60631] |
Thu, 05 June 2008 11:01  |
Jeremy Bailin
Messages: 618 Registered: April 2008
|
Senior Member |
|
|
>> Does anyone know of a convenient way of restoring the contents of a
>> SAVEd file created using /ALL that will restore everything except for
>> system variables (ie. anything starting with !)? I have some old .sav
>> files from a different system with a different file structure, and
>> doing a simple RESTORE over-writes things like !PATH that really need
>> to be from the new system.
>
> How about (temporarily) SAVEing the new system's system variables in a
> SAV file using /SYSTEM_VARIABLES then RESTOREing them after you've
> restoring the sav file from the old system?
Why didn't I think of that? Great idea - works beautifully. :-)=
Thanks!
-Jeremy.
|
|
|