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

Home » Public Forums » archive » Re: Need Help Resolving ENDIF Errors
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: Need Help Resolving ENDIF Errors [message #65522] Wed, 11 March 2009 07:35 Go to next message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
This thread is a typical example of scientific arguments:
a plethora of wild speculations based on insufficient data!

;-)

Ciao,
Paolo

Jean H. wrote:
> Hi,
>
> also don't forget, if you have ELSE begin statements, to close them by
> ENDELSE, not endif... (it's different in other languages, I make the
> mistake half of the time!)
>
> Jean
Re: Need Help Resolving ENDIF Errors [message #65523 is a reply to message #65522] Wed, 11 March 2009 06:51 Go to previous messageGo to next message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
Hi,

also don't forget, if you have ELSE begin statements, to close them by
ENDELSE, not endif... (it's different in other languages, I make the
mistake half of the time!)

Jean
Re: Need Help Resolving ENDIF Errors [message #65526 is a reply to message #65523] Wed, 11 March 2009 05:25 Go to previous messageGo to next message
David Gell is currently offline  David Gell
Messages: 29
Registered: January 2009
Junior Member
On Mar 10, 3:38 pm, einszweil...@gmail.com wrote:
> I'm trying to run a procedure in IDL.  The procedure has a series of
> IF LOOPS, each of minimal complexity - they are fairly simple.
>
> For example:
>
> XX=readfits('/home/kphil/img/img213.fits')
> YY=readfits('/home/kphil/img/img213.fits', EXTEN_NO=1)
> ZZ =YY
>
> G  = where(ZZ ne 0)
> invarmap=  ZZ * 0.0
> invarmap[G] = (1./(ZZ[G])^2)
>
> if ((where(XX ne XX))(0) ne -1) then begin
>    ZZ[where(XX ne XX)] = 0
>    XX[where(XX ne XX)] = 0
> endif
>
>    The problem is that everything runs just great, until the ENDIF is
> reached.  I CONSTANTLY get ENDIF errors.
>
> Why is this happening?  I feel that my code is solid, but all I get
> are ENDIF errors.
>
> The .pro I'm running has about 7 IF LOOPS, and the ONLY errors I get
> are on the lines where ENDIF is.
>
> Any idea what the problem is?  Help!
>
> Thanks in advance.

Usually, this error message appears at an END statement someplace
after the actual location of the syntax error. Check each of the seven
IF blocks to make sure that they are properly formed. Also if you have
other compound statements, e.g. FOR ... DO BEGIN ... ENDFOR or
WHILE .. DO BEGIN...ENDWHILE, make sure that they are properly formed.
Finally make sure that any continued statements have the $ character
at the end and that non-continued statements do not.
Re: Need Help Resolving ENDIF Errors [message #65531 is a reply to message #65526] Tue, 10 March 2009 15:18 Go to previous messageGo to next message
Andi Walther is currently offline  Andi Walther
Messages: 5
Registered: March 2009
Junior Member
On 10 Mrz., 16:56, Andi Walther <andi.b.walt...@googlemail.com> wrote:
>> XX=readfits('/home/kphil/img/img213.fits')
>> YY=readfits('/home/kphil/img/img213.fits', EXTEN_NO=1)
>> ZZ =YY
>
>> G  = where(ZZ ne 0)
>> invarmap=  ZZ * 0.0
>> invarmap[G] = (1./(ZZ[G])^2)
>
>> if ((where(XX ne XX))(0) ne -1) then begin
>>    ZZ[where(XX ne XX)] = 0
>>    XX[where(XX ne XX)] = 0
>> endif
>
> in case you meant
> if ((where(XX ne YY))(0) ne -1) then begin
>     ZZ[where(XX ne YY)] = 0
>     XX[where(XX ne YY)] = 0
>  endif
>
> you can just use
>
> IDL> ivermap = (1/((ZZ^2)>1)) * (ZZ NE 0)
> IDL> ZZ = XX * ( XX EQ YY)

And, you can't us blocks (everything that starts with a BEGIN) in
batch files.
That means you will get this error message with

IDL> @my_program_with_an_if_block
Re: Need Help Resolving ENDIF Errors [message #65532 is a reply to message #65531] Tue, 10 March 2009 14:56 Go to previous messageGo to next message
Andi Walther is currently offline  Andi Walther
Messages: 5
Registered: March 2009
Junior Member
>
> XX=readfits('/home/kphil/img/img213.fits')
> YY=readfits('/home/kphil/img/img213.fits', EXTEN_NO=1)
> ZZ =YY
>
> G  = where(ZZ ne 0)
> invarmap=  ZZ * 0.0
> invarmap[G] = (1./(ZZ[G])^2)
>
> if ((where(XX ne XX))(0) ne -1) then begin
>    ZZ[where(XX ne XX)] = 0
>    XX[where(XX ne XX)] = 0
> endif
>

in case you meant
if ((where(XX ne YY))(0) ne -1) then begin
ZZ[where(XX ne YY)] = 0
XX[where(XX ne YY)] = 0
endif

you can just use

IDL> ivermap = (1/((ZZ^2)>1)) * (ZZ NE 0)
IDL> ZZ = XX * ( XX EQ YY)
Re: Need Help Resolving ENDIF Errors [message #65533 is a reply to message #65532] Tue, 10 March 2009 14:56 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
einszweilieb@gmail.com wrote:
> I'm trying to run a procedure in IDL. The procedure has a series of
> IF LOOPS, each of minimal complexity - they are fairly simple.
>
> For example:
>
> XX=readfits('/home/kphil/img/img213.fits')
> YY=readfits('/home/kphil/img/img213.fits', EXTEN_NO=1)
> ZZ =YY
>
> G = where(ZZ ne 0)
> invarmap= ZZ * 0.0
> invarmap[G] = (1./(ZZ[G])^2)
>
> if ((where(XX ne XX))(0) ne -1) then begin
> ZZ[where(XX ne XX)] = 0
> XX[where(XX ne XX)] = 0
> endif
>
>
> The problem is that everything runs just great, until the ENDIF is
> reached. I CONSTANTLY get ENDIF errors.

Weird. On *every* endif?

> Why is this happening? I feel that my code is solid, but all I get
> are ENDIF errors.

Such basic syntax error reports are an indication code is definitely not "solid". Now,
don't take that the wrong way: most of my code qualifies in the jello category so I'm
quite familiar with the phenomenon. :o)

Apart from the strangeness of "where(XX ne XX)", what happens if you replace

if ((where(XX ne XX))(0) ne -1) then begin

with

if ((where(XX ne XX))[0] ne -1) then begin

?

cheers,

paulv

> The .pro I'm running has about 7 IF LOOPS, and the ONLY errors I get
> are on the lines where ENDIF is.
>
> Any idea what the problem is? Help!
>
> Thanks in advance.
Re: Need Help Resolving ENDIF Errors [message #65534 is a reply to message #65533] Tue, 10 March 2009 14:34 Go to previous messageGo to next message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
einszweil...@gmail.com wrote:
> I'm trying to run a procedure in IDL. The procedure has a series of
> IF LOOPS, each of minimal complexity - they are fairly simple.
>
> For example:
>
> XX=readfits('/home/kphil/img/img213.fits')
> YY=readfits('/home/kphil/img/img213.fits', EXTEN_NO=1)
> ZZ =YY
>
> G = where(ZZ ne 0)
> invarmap= ZZ * 0.0
> invarmap[G] = (1./(ZZ[G])^2)
>
> if ((where(XX ne XX))(0) ne -1) then begin
> ZZ[where(XX ne XX)] = 0
> XX[where(XX ne XX)] = 0
> endif
>
>
> The problem is that everything runs just great, until the ENDIF is
> reached. I CONSTANTLY get ENDIF errors.
>
> Why is this happening? I feel that my code is solid, but all I get
> are ENDIF errors.

If you put an "else" after endif on the next line,
be sure to put a $ after endif


Ciao,
Paolo

>
> The .pro I'm running has about 7 IF LOOPS, and the ONLY errors I get
> are on the lines where ENDIF is.
>
> Any idea what the problem is? Help!
>
> Thanks in advance.
Re: Need Help Resolving ENDIF Errors [message #65535 is a reply to message #65534] Tue, 10 March 2009 14:26 Go to previous messageGo to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
einszweilieb@gmail.com wrote:
> On Mar 10, 3:38 pm, einszweil...@gmail.com wrote:
>> I'm trying to run a procedure in IDL. The procedure has a series of
>> IF LOOPS, each of minimal complexity - they are fairly simple.
>>
>> For example:
>>
>> XX=readfits('/home/kphil/img/img213.fits')
>> YY=readfits('/home/kphil/img/img213.fits', EXTEN_NO=1)
>> ZZ =YY
>>
>> G = where(ZZ ne 0)
>> invarmap= ZZ * 0.0
>> invarmap[G] = (1./(ZZ[G])^2)
>>
>> if ((where(XX ne XX))(0) ne -1) then begin
>> ZZ[where(XX ne XX)] = 0
>> XX[where(XX ne XX)] = 0
>> endif
>>
>> The problem is that everything runs just great, until the ENDIF is
>> reached. I CONSTANTLY get ENDIF errors.
>>
>> Why is this happening? I feel that my code is solid, but all I get
>> are ENDIF errors.
>>
>> The .pro I'm running has about 7 IF LOOPS, and the ONLY errors I get
>> are on the lines where ENDIF is.
>>
>> Any idea what the problem is? Help!
>>
>> Thanks in advance.
>
> For clarity the error message always looks something like:
>
> endif
> ^
> % Syntax error.
> At: /home/kphil/idl/pro/cltin.pro, Line 37
>
> Ugh...

My guess would be that you are forgetting the BEGIN. If there are only 7
loops, maybe it's short enough to show the entire code?

Mike
--
www.michaelgalloy.com
Associate Research Scientist
Tech-X Corporation
Re: Need Help Resolving ENDIF Errors [message #65536 is a reply to message #65535] Tue, 10 March 2009 14:21 Go to previous messageGo to next message
ben.bighair is currently offline  ben.bighair
Messages: 221
Registered: April 2007
Senior Member
On Mar 10, 4:41 pm, einszweil...@gmail.com wrote:
> On Mar 10, 3:38 pm, einszweil...@gmail.com wrote:
>
>
>
>> I'm trying to run a procedure in IDL.  The procedure has a series of
>> IF LOOPS, each of minimal complexity - they are fairly simple.
>
>> For example:
>
>> XX=readfits('/home/kphil/img/img213.fits')
>> YY=readfits('/home/kphil/img/img213.fits', EXTEN_NO=1)
>> ZZ =YY
>
>> G  = where(ZZ ne 0)
>> invarmap=  ZZ * 0.0
>> invarmap[G] = (1./(ZZ[G])^2)
>
>> if ((where(XX ne XX))(0) ne -1) then begin
>>    ZZ[where(XX ne XX)] = 0
>>    XX[where(XX ne XX)] = 0
>> endif



Hi,

Do you really mean where(XX ne XX)? XX ne XX should give you and
array the size of XX filled with zeroes.

IDL> xx = INDGEN(10)
IDL> print, xx ne xx
0 0 0 0 0 0 0 0 0 0

I have no idea how to resolve the endif error or if the above is
related. However, in general (regardless of the comparison you are
making) you want to do the WHERE search just once.

index = WHERE(something NE somethingElse, count)
if (count NE 0) then begin

aThirdThing = ZZ[index]

endif

No point in searching your array repeatedly if you don't need to.

Ben
Re: Need Help Resolving ENDIF Errors [message #65537 is a reply to message #65536] Tue, 10 March 2009 13:41 Go to previous messageGo to next message
einszweilieb is currently offline  einszweilieb
Messages: 4
Registered: March 2009
Junior Member
On Mar 10, 3:38 pm, einszweil...@gmail.com wrote:
> I'm trying to run a procedure in IDL.  The procedure has a series of
> IF LOOPS, each of minimal complexity - they are fairly simple.
>
> For example:
>
> XX=readfits('/home/kphil/img/img213.fits')
> YY=readfits('/home/kphil/img/img213.fits', EXTEN_NO=1)
> ZZ =YY
>
> G  = where(ZZ ne 0)
> invarmap=  ZZ * 0.0
> invarmap[G] = (1./(ZZ[G])^2)
>
> if ((where(XX ne XX))(0) ne -1) then begin
>    ZZ[where(XX ne XX)] = 0
>    XX[where(XX ne XX)] = 0
> endif
>
>    The problem is that everything runs just great, until the ENDIF is
> reached.  I CONSTANTLY get ENDIF errors.
>
> Why is this happening?  I feel that my code is solid, but all I get
> are ENDIF errors.
>
> The .pro I'm running has about 7 IF LOOPS, and the ONLY errors I get
> are on the lines where ENDIF is.
>
> Any idea what the problem is?  Help!
>
> Thanks in advance.

For clarity the error message always looks something like:

endif
^
% Syntax error.
At: /home/kphil/idl/pro/cltin.pro, Line 37

Ugh...
Re: Need Help Resolving ENDIF Errors [message #65617 is a reply to message #65522] Wed, 11 March 2009 08:05 Go to previous messageGo to next message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
Are you slowly bringing the idea that it could be an hardware problem? ;)

Jean

Paolo wrote:
> This thread is a typical example of scientific arguments:
> a plethora of wild speculations based on insufficient data!
>
> ;-)
>
> Ciao,
> Paolo
>
> Jean H. wrote:
>> Hi,
>>
>> also don't forget, if you have ELSE begin statements, to close them by
>> ENDELSE, not endif... (it's different in other languages, I make the
>> mistake half of the time!)
>>
>> Jean
Re: Need Help Resolving ENDIF Errors [message #65618 is a reply to message #65537] Wed, 11 March 2009 08:19 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Mar 10, 4:41 pm, einszweil...@gmail.com wrote:
> On Mar 10, 3:38 pm, einszweil...@gmail.com wrote:
>
>
>
>> I'm trying to run a procedure in IDL.  The procedure has a series of
>> IF LOOPS, each of minimal complexity - they are fairly simple.
>
>> For example:
>
>> XX=readfits('/home/kphil/img/img213.fits')
>> YY=readfits('/home/kphil/img/img213.fits', EXTEN_NO=1)
>> ZZ =YY
>
>> G  = where(ZZ ne 0)
>> invarmap=  ZZ * 0.0
>> invarmap[G] = (1./(ZZ[G])^2)
>
>> if ((where(XX ne XX))(0) ne -1) then begin
>>    ZZ[where(XX ne XX)] = 0
>>    XX[where(XX ne XX)] = 0
>> endif
>
>>    The problem is that everything runs just great, until the ENDIF is
>> reached.  I CONSTANTLY get ENDIF errors.
>
>> Why is this happening?  I feel that my code is solid, but all I get
>> are ENDIF errors.
>
>> The .pro I'm running has about 7 IF LOOPS, and the ONLY errors I get
>> are on the lines where ENDIF is.
>
>> Any idea what the problem is?  Help!
>
>> Thanks in advance.
>
> For clarity the error message always looks something like:
>
> endif
>  ^
> % Syntax error.
>   At: /home/kphil/idl/pro/cltin.pro, Line 37
>
> Ugh...

My votes:

1. Yes, there is a use of asking where(XX ne XX) - it tells you where
there are NaNs. I use it all the time.

2. Definitely take Ben's advice about only having one WHERE!!!

3. I think Andi's speculation is the right one... you're probably
using @foo.pro instead of .run foo.pro.

-Jeremy.
Re: Need Help Resolving ENDIF Errors [message #65620 is a reply to message #65522] Wed, 11 March 2009 08:02 Go to previous message
ben.bighair is currently offline  ben.bighair
Messages: 221
Registered: April 2007
Senior Member
On Mar 11, 10:35 am, Paolo <pgri...@gmail.com> wrote:
> This thread is a typical example of scientific arguments:
> a plethora of wild speculations based on insufficient data!
>
> ;-)
>

Just keeping limber for the upcoming grant renewal season!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: using irregularly spaced coordinates with ray-casting in iVolume
Next Topic: OpenADDE and IDL

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

Current Time: Wed Oct 08 15:22:44 PDT 2025

Total time taken to generate the page: 0.00516 seconds