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 #28463 is a reply to message #28462] Wed, 12 December 2001 16:10 Go to previous messageGo to previous message
Andrew Cool is currently offline  Andrew Cool
Messages: 219
Registered: January 1996
Senior Member
Paul van Delst wrote:
>
> Craig Markwardt wrote:
>>
>> Andrew Cool <andrew.cool@dsto.defence.gov.au> writes:
>>
>>> Hi All,
>>>
>>> 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:
>>
>> See "Using Arrays as Subscripts" in the manual. I believe this
>> behavior has been true since the dawn of SYSTIME().
>
> Huh. How 'bout that?
>
> IDL> a = indgen(10)
> IDL> x=[-100,3, 4, 5]
> IDL> print, a(x)
> 0 3 4 5
>
> but only for array subscripts,
>
> IDL> print, a[-100]
> % Attempt to subscript A with <INT ( -100)> is out of range.
> % Execution halted at: $MAIN$
>
> Seems logical....<insert chirping cricket sounds here>.....in an IDL sorta way.
>
> paulv
>

Thanks David, Craig & Paul...

I did actually search every which way through the online v5.4 "Help"
before posting the query.

Thanks to Jeff, I've gone back to my *paper* v4.0 User's Guide and
found on 5-5 that :-

"If an element of a 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."

Sounds fair - if only they'd keep that text in the bloody Help!

But what sort of person attempts to subscript an array without checking
the bounds
in the first place? Sounds like sloppy practice to me.

Anyways, Y'all have a good Christmas. I'll be thinking of you Paul,
freezing your
buns off in Yankee Land while prawns & cold beer are Order of the Day
back in OZ.

Cheers,

Andrew


------------------------------------------------------------ ---------
Andrew D. Cool .->-.
Electromagnetics & Propagation Group `-<-'
Surveillance Systems Division Transmitted on
Defence Science & Technology Organisation 100% recycled
PO Box 1500, Salisbury electrons
South Australia 5108

Phone : 061 8 8259 5740 Fax : 061 8 8259 6673
Email : andrew.cool@dsto.defence.gov.au
------------------------------------------------------------ ---------
[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: Sun Oct 12 01:31:32 PDT 2025

Total time taken to generate the page: 0.64189 seconds