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

Home » Public Forums » archive » Re: Invalid indices?
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: Invalid indices? [message #68414 is a reply to message #68413] Tue, 27 October 2009 11:02 Go to previous messageGo to previous message
Foldy Lajos is currently offline  Foldy Lajos
Messages: 268
Registered: October 2001
Senior Member
On Tue, 27 Oct 2009, Y.T. wrote:

> So I'm kinda living under a rock:
> IDL Version 6.3, Microsoft Windows (Win32 x86 m32)
>
> so I'm curious whether this is intended/expected behaviour or a bug or
> what (and whether it has change in recent years):
>
> IDL> t = lindgen(7)
> IDL> print,t
> 0 1 2 3 4
> 5 6
>
> IDL> n=5*indgen(5)
> IDL> print,n
> 0 5 10 15 20
>
> IDL> t[n] = 100
> IDL> print,t
> 100 1 2 3 4
> 100 100
>
> So element number 0 got set to 100 (OK), element number 5 got set to
> 100 and ... element number 6 also got set to 100?
>
> Why is that? I understand that I'm specifying elements "out of
> range" (number 10 and 15 etc) - is that the reason? Is this
> documented? It took me by surprise...
>

There is no out of range error for array subscripts, they are always
clipped. From the docs:

Elements of the subscript array that are negative or larger than the
highest subscript are clipped to the target array boundaries. Note that a
common error is to use a negative scalar subscript (e.g., A[-1]). Using
this type of subscript causes an error. Negative array subscripts (e.g.,
A[[-1]]) do not cause errors.

regards,
lajos
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: What is the problem ?
Next Topic: Fractal in IDL!

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

Current Time: Fri Oct 10 15:08:09 PDT 2025

Total time taken to generate the page: 1.15622 seconds