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

Home » Public Forums » archive » error in a simple pro
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: error in a simple pro [message #55934 is a reply to message #55786] Wed, 12 September 2007 20:30 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
yychongzi@gmail.com writes:

> Below is a simple pro file for reading ENVI image, but there is
> something wrong with the line 'for i=0, .....' Could anyone tell me
> why?

I am going to presume you are having trouble compiling this
file, with IDL reporting a syntax error. This sheds some
light on a couple of things I have noticed from time to time,
that I am certain is not how IDL used to work. (I would
test it, but a couple of weeks ago, in an effort to get
more work out of an old machine, I deleted all my old
IDL versions.)

Here is what I think is happening. You don't have
the file ENVI_GET_DATA on your IDL path. Thus, when you
go to compile this file, this line causes a syntax error:

for I=0, num_bands -1 do image[I,*,*] = $
envi_get_data (fid=fid, dims=dims, pos = pos[I])

The problem is this. IDL can't find ENVI_GET_DATA on
your path, so it thinks ENVI_GET_DATA is a variable,
not a function call. This then *is* the wrong IDL syntax
for a variable, and IDL complains about it. Correctly, I think.

There are a couple of things you can do to get the file
compiled.

(1) Make sure the ENVI files are on your IDL path before
you try to compile ENVI functions. This is a good idea,
since even if the file compiles, it won't run unless
this happens.

(2) Add this line at the start of your program, so IDL
knows it is a function:

FORWARD_FUNCTION ENVI_GET_DATA

(3) Set the compiler option STRICTARR. (This is the best
solution in my opinion, and should be done in *all* your
IDL programs.)

COMPILE_OPT STRICTARR

Normally, you will see this written as this:

COMPILE_OPT idl2

which is just a short-hand way of getting STRICTARR
and DEFINT32 (long integers as the default, also a
good thing).

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: ENVI File Question
Next Topic: insufficient system resources

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

Current Time: Fri Oct 10 16:30:25 PDT 2025

Total time taken to generate the page: 0.40179 seconds