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

Home » Public Forums » archive » Re: Array indexing problem
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 problem [message #37866 is a reply to message #37858] Wed, 28 January 2004 14:11 Go to previous messageGo to previous message
Liam Gumley is currently offline  Liam Gumley
Messages: 473
Registered: November 1994
Senior Member
"Roy" <roberson_1@yahoo.com> wrote in message
news:c0a9aee5.0401281200.400888f1@posting.google.com...
> Is there any existing code that will catch the below IDL simple
> example? Input a and b must be an array.
>
> Input is an array:
> IDL> b=[4]
> IDL> a=[0,1,2]
> IDL> print,a[b]
> 2
> This should give me an error.

This is how array subscripting works in IDL, when the subscript is an array.
To quote the IDL Manual "Building IDL Applications", Chapter 5, "Using
Arrays as Subscripts":

"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."

If the subscript variable has just one elements, then you can do this
instead

IDL> print, a[b[0]]
% Attempt to subscript A with <LONG ( 4)> is out of range.
% Execution halted at: $MAIN$

since b[0] is a scalar. You can do this even if b is a scalar.

Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
[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: Re: V5.6 to V6.0 license server question
Next Topic: Rapid "moving windows" access in IDL?

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

Current Time: Fri Oct 10 10:03:18 PDT 2025

Total time taken to generate the page: 0.56426 seconds