Re: Index should be out of range, right? [message #64518 is a reply to message #64517] |
Wed, 31 December 2008 11:52  |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
On Dec 31, 2:42 pm, "T.H." <timhoagl...@gmail.com> wrote:
> This is confusing because some values of y are greater than the
> dimensions of the array that they are being used to access and in
> fact
>
> IDL> x[y[10],y[10]]=1
> % Attempt to subscript X with <INT ( 10)> is out of range.
> % Execution halted at: $MAIN$
>
> this fails. Why do I not get an "out of range error" in the first
> case?
The difference is that in the second example you are subscripting with
a scalar. You may want to check out the "strictarrsubs" option to
the command compile_opt which I quote below:
"When IDL subscripts one array using another array as the source of
array indices, the default behavior is to clip any out-of-range
indices into range and then quietly use the resulting data without
error. This behavior is described in Array Subscripting. Specifying
STRICTARRSUBS will instead cause IDL to treat such out-of-range array
subscripts within the body of the routine containing the COMPILE_OPT
statement as an error. "
|
|
|