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

Home » Public Forums » archive » Re: Array subscripting oddity
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 subscripting oddity [message #1258] Fri, 20 August 1993 07:17 Go to previous message
sterner is currently offline  sterner
Messages: 106
Registered: February 1991
Senior Member
glenn@atm.ch.cam.ac.uk (Glenn Carver) writes:

> I thought I understand array subscripting in PV-wave but this bit of
> code has got me foxed. I was trying to figure out what was going wrong
> with a procedure and finally tracked it down to a problem that I can
> demonstrate using the following example:

> WAVE> a=indgen(3)
> WAVE> print,a
> 0 1 2
> WAVE> m=[45,99]
> WAVE> print,m
> 45 99
> WAVE> a(m)=255
> WAVE> print,a
> 0 1 255

> Now, I would have thought that because both elements of 'm' are more
> than the size of 'a', no element of 'a' would have been assigned?
> The values '45' and '99' are completely arbitrary. You can set them to
> anything you like.

> If someone could explain what's going on here (maybe it's a bug??) I'd
> be most grateful. The configuration is PV-wave 4.01 running on SunOS
> 4.1.3.


IDL does the same thing. I think of it as a feature, not a bug.
You can use it to your advantage as follows. Let x be a 10 element
array. t = x(i) will fail for scalar values of i that are less than
0 or greater than 9. It is not uncommon that you want to
force i to be in the correct subscript range, in this case you
could say t = x(i>0<9) but in general it is extra work to find
the upper subscript limit. A much simpler fix is t = x([i]).

Ray Sterner sterner@tesla.jhuapl.edu
Johns Hopkins University North latitude 39.16 degrees.
Applied Physics Laboratory West longitude 76.90 degrees.
Laurel, MD 20723-6099
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: bug in tvtwm (X11R5 version)
Next Topic: PV-WAVE POINT+CLICK

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

Current Time: Fri Oct 10 07:23:01 PDT 2025

Total time taken to generate the page: 2.80165 seconds