error: subscript range values of the form low:high must be >= 0, < size [message #63194] |
Fri, 31 October 2008 10:34  |
frankosuna
Messages: 31 Registered: February 2008
|
Member |
|
|
I am trying to store values into a array of type long but I keep
getting the following error:
subscript range values of the form low:high must be >= 0, < size, with
low <= high: ROIPIXELS.
The weird thing about it is when I set a breakpoint and step through
the code it doesn't throw the error anymore. Also, if instead I don't
use numClicks as the index and hardcode a 0 or 1 or 2...etc the code
works as well!!!
HELP!!!!!!!!!
roiPixels = LONARR(5,25)
numClicks = 1
WHILE(!mouse.button NE 4) DO BEGIN
CURSOR, xi, yi, /DEVICE
IF(!mouse.button EQ 1) THEN BEGIN
x = LINDGEN(5*5) MOD 5 + xi
y = LINDGEN(5*5) / 5 + yi
roiPixels[numClicks,*] = x + y * 1024
numClicks++
ENDIF
ENDWHILE
|
|
|
Re: error: subscript range values of the form low:high must be >= 0, < size [message #63301 is a reply to message #63194] |
Mon, 03 November 2008 15:54  |
Jean H.
Messages: 472 Registered: July 2006
|
Senior Member |
|
|
frankosuna wrote:
> I am trying to store values into a array of type long but I keep
> getting the following error:
> subscript range values of the form low:high must be >= 0, < size, with
> low <= high: ROIPIXELS.
> The weird thing about it is when I set a breakpoint and step through
> the code it doesn't throw the error anymore. Also, if instead I don't
> use numClicks as the index and hardcode a 0 or 1 or 2...etc the code
> works as well!!!
>
> HELP!!!!!!!!!
>
> roiPixels = LONARR(5,25)
> numClicks = 1
>
> WHILE(!mouse.button NE 4) DO BEGIN
> CURSOR, xi, yi, /DEVICE
> IF(!mouse.button EQ 1) THEN BEGIN
> x = LINDGEN(5*5) MOD 5 + xi
> y = LINDGEN(5*5) / 5 + yi
> roiPixels[numClicks,*] = x + y * 1024
> numClicks++
> ENDIF
> ENDWHILE
if you click 6 times, numClicks = 7, which is greater than the 1st
dimension of roiPixels...
You might want to resize roiPixels as numClicks grows (or start with a
bigger array, and cut the unused entry when you are done)
Jean
|
|
|