[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: IDL Save file query routine

Jonathan Joseph <jj21@cornell.edu> writes:
> IDL (I'm still using 5.3) has nice query routines to let you know if the
> image read operation you are about to perform is likely to work.
> Is there any way to query an IDL save file?
> I want to idiot-proof a program which will restore
> a save file that a user selects, but if the program tries
> to restore file which is not an IDL save file, it will halt.
> Is there a way to test?

I don't think there is a standard way to do what you want.  There are
a couple of other possibilities.

One is to use a CATCH handler to catch any errors that occur upon
restoring.  For example:

catch, catcherr
if catcherr EQ 0 then begin
  restore, 'filename.sav'
endif else begin
  catch, /cancel
  message, 'This is not a SAVE file'
catch, /cancel

You can and should do a lot of additional checking to be sure the
right variables were restored.

A second option is to use my CMSV SAVE library, which is designed for
exactly this purpose.  You can use CMSAVEDIR to query not only for a
valid SAVE file, but also to inquire about the names of variables.
When it's time to actually restore the variables there are a lot of
useful programming options as well, using CMRESTORE.

http://cow.physics.wisc.edu/~craigm/idl/idl.html    (under SAVE files)


Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response