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

Home » Public Forums » archive » Re: Array indexing "Feature"
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: Array indexing "Feature" [message #28469 is a reply to message #28468] Wed, 12 December 2001 14:12 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Andrew Cool (andrew.cool@dsto.defence.gov.au) writes:

> One of my colleagues has noted something apparently screwy in the
> indexing of
> arrays.
>
> e.g. a = indgen(10)
> print, a(9) -> you get 9
> print, a(10) -> you get an error, as expected for a zero-based
> index
>
> but if you access the array with the index as a vector, it seems to
> truncate the index to the maximum allowable:
>
> print, a([10]) -> you get 9
> print, a([666]) -> you get 9
>
> Similarly:
>
> print, a(-1) -> you get an error
> print, a([-1]) -> you get 0
>
> This feature holds good for IDL 5.2 and 5.4 on OpenVMS and for 5.5 on
> Windows.
>
> Where, Oh where in the manuals does it describe this?

This has been a feature of IDL since about IDL 0.5, or thereabouts.

I first encountered it in about 1988 in some chapters
Ray Sterner of JHUAPL was putting together for a book about
IDL. He found it incredibly useful for array bound error
checking. But I don't think I have ever read about it in any
documentation. My guess is that after the IDL 1.0
documentation was finished, and RSI had hired a real
technical writer, that he could never figure out
a way to explain the situation that didn't sound
really lame. So he just left it out. :-)

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL Expert Programmer's Association Vote
Next Topic: Re: Newbie IDl question

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

Current Time: Sat Oct 11 14:37:52 PDT 2025

Total time taken to generate the page: 2.31777 seconds