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

Home » Public Forums » archive » Catched in a catch loop
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Catched in a catch loop [message #94801 is a reply to message #94799] Wed, 18 October 2017 07:21 Go to previous messageGo to previous message
Markus Schmassmann is currently offline  Markus Schmassmann
Messages: 129
Registered: April 2016
Senior Member
On 10/18/2017 03:48 PM, LNpellen wrote:
> I'm not used to CATCH - I strive to write the code robust enough to
> not cause errors. No I need it and seem to not understand how.
>
> Using RESTORE with a not valid save file causes
> % RESTORE: Not a valid save file:
>
> So I try with this catch, but the error occurs even though I get the
> dialog With the error-message I wrote (looping until I have to crash
> the program).
>
> What have I misunderstood?
>
>
> CATCH, err_stat
> IF err_stat NE 0 THEN BEGIN
> CATCH, /CANCEL
> sv=DIALOG_MESSAGE('Not valid .sav file: '+adr, /INFORMATION)
> ENDIF
> RESTORE, adr

after pressing OK in the dialog window, the process continues, i.e. it
tries again to run

RESTORE, adr

therefore after the line

sv=DIALOG_MESSAGE('Not valid .sav file: '+adr, /INFORMATION)

you have to either do something to fix adr to a correct filename, or
you have to abort the process, e.g. by a RETURN


alternatively you can replace the DIALOG_MESSAGE function by

message, 'Not valid .sav file: '+adr

in which case the program would stop at this line and the user could
enter a correct filename by entering at the console

IDL> adr='filename.sav'
IDL> .c


another possibility,

adr = DIALOG_PICKFILE(filter='*.sav',/must_exist,title='Not valid .sav
file: '+adr)
if adr eq '' then begin message, 'no file selected' & return & endif

I hope one of these is what you are looking for, Markus
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: tvscl
Next Topic: tvscl

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

Current Time: Wed Oct 08 14:10:48 PDT 2025

Total time taken to generate the page: 0.00217 seconds