comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Requested change to "SAVE" procedure
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Requested change to "SAVE" procedure [message #82855] Tue, 22 January 2013 13:19 Go to next message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
Sounds like a can of worms to me if command behavior from the command line is different from that executed in code. I would not touch that. Just my 2 cents.


On Tuesday, January 22, 2013 10:50:43 AM UTC-5, lef...@gmail.com wrote:
> I've been wanting this for a while:
>
>
>
> Sometimes I type save and (for a variety of reasons)overwrite an old idslave file that I didn't want to overwrite. What I'd like to see is the default behavior include a query to the user if a) no filename is provided (i.e. the idlsave.dat file is going to be used) and b) the command is issued from the command line. This should prevent accidental over-writes but not impact program behavior.
>
>
>
> What would be the negative implications of such a change? Are others interested in this modification?
>
>
>
> Exelisvis: Is this possible?
Re: Requested change to "SAVE" procedure [message #82862 is a reply to message #82855] Tue, 22 January 2013 11:36 Go to previous messageGo to next message
lefsky@gmail.com is currently offline  lefsky@gmail.com
Messages: 13
Registered: June 2010
Junior Member
This has only happened to me 4 or 5 times and the sequence usually looks like this:

It's late at night
I have a workspace with large variables to save
A process is running
I want to clear that process off as soon as possible because it is using so much memory.

So I type save, and then exit on the command line. (Stupid- but remember it's late at night and I want to get out of the office)

Then the process I'm running dies (inevitably this is a new error)
And "save and exit" are run
Leaving me with the variables that exist within the function
Not the ones I wanted.

If this (or something similar) has never happened to you in some part of your life- congratulations.

For the rest of us, an interactive save function would be nice. Perhaps this could be implemented with a system variable that we can set from out startup scripts.

M
Re: Requested change to "SAVE" procedure [message #82867 is a reply to message #82862] Tue, 22 January 2013 09:41 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
If "accidental" overwrites are that big of an issues for you, how come
you are not checking that the file exists before you try to create it --
and thus clobber existing ones?

I agree it's an annoyance but it's a relatively standard requirement
that the programmer be responsible for their output. Typically after the
first time this sort of thing happens one changes one's programming
habits to prevent further finger-burning.

I would most definitely not want the default behaviour to change since
it's well established that the default behaviour is to clobber existing
filenames of the same name. That sort of default pretty much crossing
language boundaries too.

<tongue-in-cheek>
Maybe you should write your own save file creation wrapper with a
"do_what_I_mean"
keyword? And perhaps a
"ignore_what_I_ask_for_but_do_not_mean"
keyword for others?
</tongue-in-cheek>

:o)

cheers,

paulv


On 01/22/13 10:50, lefsky@gmail.com wrote:
> I've been wanting this for a while:
>
> Sometimes I type save and (for a variety of reasons)overwrite an old
> idslave file that I didn't want to overwrite. What I'd like to see is
> the default behavior include a query to the user if a) no filename is
> provided (i.e. the idlsave.dat file is going to be used) and b) the
> command is issued from the command line. This should prevent
> accidental over-writes but not impact program behavior.
>
> What would be the negative implications of such a change? Are others
> interested in this modification?
>
> Exelisvis: Is this possible?
Re: Requested change to "SAVE" procedure [message #82868 is a reply to message #82867] Tue, 22 January 2013 08:51 Go to previous messageGo to next message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
How about rolling your own? This certainly not complete, but feel free to change/modfy/improve from here. RIght now, it just tests if the file exists and issues an error. (BTW, you'll need Coyote's Error_message.pro to run it...or you could change the error handler).

Cheers,
Phillip

PRO mysave, var1, var2, var3, _extra = extra

compile_opt idl2

;error catcher:
CATCH, theError
IF theError NE 0 THEN BEGIN
CATCH, /cancel
ok = ERROR_MESSAGE(TRACEBACK=1, QUIET=1)
RETURN
ENDIF

IF N_TAGS(extra) NE 0 THEN BEGIN ;make sure some keywords were defined
ind = WHERE(STREGEX(TAG_NAMES(extra), '^f', /FOLD_CASE, /EXTRACT), count) ;find the filename tag
file = extra.(ind)
ENDIF ELSE file = 'idlsave.dat' ;this is the default of IDL's SAVE pro

IF FILE_TEST(file) THEN MESSAGE, 'File exists!'

save, var1, var2, var3, _extra=extra

END

;main level program for testing:
a = findgen(10)

mysave, a, f='hello.sav', /var

END
Re: Requested change to "SAVE" procedure [message #82869 is a reply to message #82868] Tue, 22 January 2013 08:10 Go to previous messageGo to next message
Carsten Lechte is currently offline  Carsten Lechte
Messages: 124
Registered: August 2006
Senior Member
On 22/01/13 16:50, lefsky@gmail.com wrote:
> Sometimes I type save and (for a variety of reasons)overwrite an
> old idslave file that I didn't want to overwrite. What I'd like to
> see [...]

I would suggest that instead of adding interactivity where previously
there was none, idl rename the old file (e.g. to idlsave-001.dat,
-002.dat etc.) before writing the new.

This will placate the users who do a little type-ahead on their
command lines and expect their commands to be obeyed without question.
It will anger the users whose disks are filled up with unwanted
savefile backups.


chl
Re: Requested change to "SAVE" procedure [message #82934 is a reply to message #82867] Wed, 23 January 2013 09:33 Go to previous message
Matthew is currently offline  Matthew
Messages: 18
Registered: February 2006
Junior Member
> If "accidental" overwrites are that big of an issues for you, how come
> you are not checking that the file exists before you try to create it --
> and thus clobber existing ones?

The SAVE command works without any arguments. If SAVE is called without arguments, I would assume that the user wants a new file, not to overwrite existing files. In this case, a '-001' appended to the filename seems like the right move. Either that, or make FILENAME required.

If SAVE is called with the FILENAME keyword, then clobbering should take place. It is definitely the user's fault this time.

My two cents...
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Reading CDF files on a Mac
Next Topic: Re: Region_Grow kills IDL Workbench on Windows

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 07:33:19 PDT 2025

Total time taken to generate the page: 0.00711 seconds