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 #37852 is a reply to message #37851] Thu, 29 January 2004 09:43 Go to previous messageGo to previous message
Liam Gumley is currently offline  Liam Gumley
Messages: 473
Registered: November 1994
Senior Member
I think your options are

(1) Modify the code

or

(2) Use IDL 6.0

Perhaps you could show us the original code?

"Roy" <roberson_1@yahoo.com> wrote in message
news:c0a9aee5.0401290903.154044d3@posting.google.com...
> Thank you for responding so quickly. Compile_opt STRICTARRSUBS works
> for IDL 6.0 but I have to use 5.1. Is there a way to add in a compile
> function, or some else that will look for this error in the original
> code? I don't want to add an error handler, which David suggested.
> The original code can not be altered.
>
> Roy
>
> "Liam Gumley" <pip_book@mailinator.com> wrote in message
news:<bv9c35$lqf$1@news.doit.wisc.edu>...
>> "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: Sat Oct 11 02:45:24 PDT 2025

Total time taken to generate the page: 0.16149 seconds