Re: bounds check in array subscripts [message #16733] |
Fri, 20 August 1999 00:00 |
Liam Gumley
Messages: 473 Registered: November 1994
|
Senior Member |
|
|
Mark Fardal <fardal@weka.astro.umass.edu> wrote in message
news:7vlnb6i69g.fsf@weka.phast.umass.edu...
> just noticed something odd, running IDL 5.1 on a Debian Linux Pentium box.
>
> IDL> x = findgen(3)
> IDL> subs = indgen(10)
> IDL> print, x(subs)
> 0.00000 1.00000 2.00000 2.00000 2.00000
2.00000
> 2.00000 2.00000 2.00000 2.00000
> IDL> print, x(9)
> % Attempt to subscript X with <INT ( 9)> is out of range.
> % Execution halted at: $MAIN$ 1 sfr.pro
> is this the expected behavior?
Yes. The following quotes are from the IDL 5.2 document 'Building IDL
Applications', section 'Subscripts'.
IDL> ? subscript examples
"If an attempt is made to reference a nonexistent element of an array using
a scalar subscript (a subscript that is negative or larger than the size of
the dimension minus 1), an error occurs and program execution stops."
IDL> ? array subscripts
"If an element of the subscript array is less than or equal to zero, the
first element of the subscripted variable is selected. If an element of the
subscript is greater than or equal to the last subscript in the subscripted
variable (N, above), the last element is selected."
Cheers,
Liam.
|
|
|