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

Home » Public Forums » archive » Re: Arrays in Structures Question (newbie)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Arrays in Structures Question (newbie) [message #22404] Thu, 09 November 2000 00:00
John-David T. Smith is currently offline  John-David T. Smith
Messages: 384
Registered: January 2000
Senior Member
Mike Garrett wrote:
>
> Hej guys,
>
> I was writing some structures to hold some data values and I am having a
> hard time determining what is going inside IDL. Could someone explain why
> I keep gettin two values back when I am just asking for one? And why the
> values are getting switched down a level?
>
> IDL> pointdata([1]).distance([[44],[0]]) = 12
> IDL> print, pointdata([1]).distance([[44],[0]])
> 12
> 12
> IDL> pointdata([1]).distance([[44],[1]]) = 3
> IDL> print, pointdata([1]).distance([[44],[1]])
> 3
> 3
> IDL> print, pointdata([1]).distance([[44],[0]])
> 3
> 12
>
> Thanks for any help,
>
> Mike

Short answer:

IDL> pointdata[1].distance[44,0]=12
IDL> print, pointdata[1].distance[44,0]

Long answer:

The quantity [[44],[0]] in your statement is really the vector [44,0].
If you index an array with a vector, you get all of those elements. By
the way, don't use () to index an array unless you're using a very old
IDL. It confuses the compiler in some cases.

If you're really fond of lots and lots of punctuation, you could still
do:

IDL> print, pointdata([1]).distance([[44]],[[0]])

(note carefully the difference) but hopefully I've convinced you not to.

JD

--
J.D. Smith | WORK: (607) 255-6263
Cornell Dept. of Astronomy | (607) 255-5842
304 Space Sciences Bldg. | FAX: (607) 255-5875
Ithaca, NY 14853 |
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Window Background
Next Topic: Arrays in Structures Question (newbie)

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

Current Time: Thu Oct 09 09:21:50 PDT 2025

Total time taken to generate the page: 0.79990 seconds