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

Home » Public Forums » archive » Skip file during loop based on subprocess
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
Skip file during loop based on subprocess [message #91570] Thu, 30 July 2015 04:55 Go to next message
Kai Heckel is currently offline  Kai Heckel
Messages: 51
Registered: April 2015
Member
Hey there!

Here is what I have:

FOR f=0, N_ELEMENTS(foldername)-1 DO BEGIN<-----
IF test EQ 1 THEN BEGIN -
IF test EQ 1 THEN BEGIN -
IF test EQ 1 THEN BEGIN -
PROBLEM >--------------------------
ENDIF
ENDIF
ENDIF
ENDFOR


What I'd like to do:

If an error in the third IF statement occurs/ if the statement does not match the criteria, then the FOR-loop should skip the current file (f=n) and continue with the next file (f=n+1).

I saw that there is a function called CONTINUE but I couldn't make it work yet.

Does anyone have solution for this problem?

Thank you very much!

Greetings
Re: Skip file during loop based on subprocess [message #91571 is a reply to message #91570] Thu, 30 July 2015 06:14 Go to previous message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Thursday, July 30, 2015 at 1:55:03 PM UTC+2, Kai Heckel wrote:
> Hey there!
>
> Here is what I have:
>
> FOR f=0, N_ELEMENTS(foldername)-1 DO BEGIN<-----
> IF test EQ 1 THEN BEGIN -
> IF test EQ 1 THEN BEGIN -
> IF test EQ 1 THEN BEGIN -
> PROBLEM >--------------------------
> ENDIF
> ENDIF
> ENDIF
> ENDFOR
>
>
> What I'd like to do:
>
> If an error in the third IF statement occurs/ if the statement does not match the criteria, then the FOR-loop should skip the current file (f=n) and continue with the next file (f=n+1).
>
> I saw that there is a function called CONTINUE but I couldn't make it work yet.
>
> Does anyone have solution for this problem?
>
> Thank you very much!
>
> Greetings

Hi,
I'm not sure what "PROBLEM" means, therefore I've made two versions. The easiest one:

pro testEasyContinue
for i=0,10 do begin
if i eq 5 then begin
if i eq 5 then begin
if i eq 5 then begin
print, 'skip this one!'
continue
endif
endif
endif
print, i
endfor
end

and the complicated one that catches an error:

pro testContinue
for i=0,10 do begin
if i eq 5 then begin
if i eq 5 then begin
if i eq 5 then begin
Catch, theError
if theError ne 0 then begin
print, 'skip this one!'
continue
endif
a = b ;generate error
endif
endif
endif
print, i
endfor
end

Both give the same result:

0
1
2
3
4
skip this one!
6
7
8
9
10

I hope it helps.

Cheers,
Helder
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: FG bug
Next Topic: Dynamically naming structures in IDL

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

Current Time: Wed Oct 08 07:25:24 PDT 2025

Total time taken to generate the page: 0.00202 seconds