[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: % Loop limit expression too large for loop variable type.




"hua Guo" <gh75@usa.net> writes:

> Dear all,
> I got this error message when I tried to run a program:
> 
> % Loop limit expression too large for loop variable type.
>   <LONG     (       54695)>.
> 
> What is wrong here? I am a beginner here. Thanks for any help.

The default type for integers in IDL is a "short" or 16-bit integer,
which can only go from -32768 to 32767.  The quick fix is to put an
"L" at the end of your numeric constants to promote them to "long"
32-bit integers.

for i = 0L, NMAX-1 do begin ...

Note the "0L" instead of "0".

Craig

P.S.  This is one of the secret banes of IDL programming.  You have
the freedom to use any IDL type at any time.  The problem is that any
IDL type can appear at any time...

-- 
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------