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

Home » Public Forums » archive » Re: OOB array indexing with an array gives no error message
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: OOB array indexing with an array gives no error message [message #15700] Fri, 04 June 1999 00:00 Go to previous message
Liam Gumley is currently offline  Liam Gumley
Messages: 473
Registered: November 1994
Senior Member
Bobstrosity wrote:
> Array indexing is always a popular thread!
> It seems that you can index an array with a "bad value"
> if that bad value is an array rather than a scaler.
[examples removed]

This behavior is described in the IDL 5.2 online book 'Building IDL
Applications', in the section entitled 'Subscripts':

---begin quote---
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.

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.
---begin quote---

In addition, regarding the use of trailing zero dimensions:

---begin quote---
When creating arrays, IDL eliminates all size 1, or
"degenerate", trailing dimensions. Thus, the statements

A = INTARR(10, 1)

HELP, A

print the following:

A INT = Array(10)

This removal of superfluous dimensions is usually convenient,
but it can cause problems when attempting to write fully general
procedures and functions. Therefore, IDL allows you to specify
"extra" dimensions for an array as long as the extra dimensions
are all zero. For example, consider a vector defined as follows:

ARR = INDGEN(10)

The following are all valid references to the sixth element of
ARR:

X = ARR[5]

X = ARR[5, 0]

X = ARR[5, 0, 0, *, 0]

Thus, the automatic removal of degenerate trailing dimensions
does not cause problems for routines that attempt to access the
resulting array.
---begin quote---

I guess the documentation is there for a reason after all. For those who
prefer a book made of paper, printable PDF versions of all the IDL
manuals are available at ftp://ftp.rsinc.com/pub/idl/info/docs/

Cheers,
Liam.

--
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley
[Message index]
 
Read Message
Read Message
Previous Topic: CW_FSLIDER woes
Next Topic: OOB array indexing with an array gives no error message

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

Current Time: Fri Oct 24 04:05:44 PDT 2025

Total time taken to generate the page: 0.19109 seconds