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

Home » Public Forums » archive » negative array index in IDL8
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: negative array index in IDL8 [message #86375 is a reply to message #86374] Fri, 01 November 2013 11:55 Go to previous messageGo to previous message
suicidaleggroll is currently offline  suicidaleggroll
Messages: 14
Registered: September 2013
Junior Member
On Friday, November 1, 2013 11:38:03 AM UTC-6, chu xiangning wrote:
> Hi All,
>
> My first noobie post here. I wanted to turn off negative index in the following commands. New IDL return error for x[[-1,-2]], but not for x[-1]. Is there anyway that I can turn off the negative indexing completely?
>
> Thank you in advance!
>
>
>
>
>
> pro test_negative_index
>
> COMPILE_OPT STRICTARRSUBS
>
> x=INDGEN(10)
>
> print,x[-1]
>
> print,x[[-1,-2]]
>
> end
>
>
>
> Here is the result I got:
>
> % Compiled module: TEST_NEGATIVE_INDEX.
>
> 9
>
> % Array used to subscript array contains out of range subscript: X.
>
> % Execution halted at: TEST_NEGATIVE_INDEX 6

I'm following this thread with hopeful anticipation.

A lot of my colleagues (who are no longer here) used to write IDL code assuming that a negative index would cause an error. So for example if they used a where statement to find some match, rather than checking the number of matches and erroring if there were none, they would just directly subscript the array with the output, counting on the fact that IDL would crash with the negative subscript.

Bad programming practices aside, all of these programs now result in unpredictable behaviour in IDL8. Rather than combing through all of our old programs line by line to find these problems, it would be nice to add an option to turn off negative subscripting, since we never use it anyway for backwards compatibility.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: derivative function in IDL similar as DIFF in matlab
Next Topic: covariance matrix

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

Current Time: Fri Oct 10 03:53:51 PDT 2025

Total time taken to generate the page: 0.96102 seconds