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

Home » Public Forums » archive » Re: IDL Structures
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: IDL Structures [message #1690] Thu, 10 February 1994 23:38
stl is currently offline  stl
Messages: 70
Registered: February 1994
Member
In article <2je7gn$1kn@kirk.giss.nasa.gov> crdmi@vulcan.giss.nasa.gov writes:
>
> I've noticed that IDL seems to treat all structures as arrays of
> structures.
>
> Example:
> IDL> a={ new_structure, x : 1e0, y : 1e0 }
> IDL> help, /structure, a
> A STRUCT = -> Array(1)
>

Actually this is kind of nice that they are all treated like arrays. If
you need to use the scalar of this, just use a(0), or actually like the
other person just mentioned, something like a.x should just return you a
scalar (otherwise use a(0).x)
The advantage of this is that when you use replicate on the
structure, you don't change from a scalar to an array, ie, very
little code change (if any at all)

-stephen

--
Stephen C Strebel / SKI TO DIE
stl@maz.stl.ch / and
Swiss Meteorological Institute, Zuerich / LIVE TO TELL ABOUT IT
01 256 93 85 / (and pray for snow)
Re: IDL Structures [message #1693 is a reply to message #1690] Thu, 10 February 1994 14:35 Go to previous message
thompson is currently offline  thompson
Messages: 584
Registered: August 1991
Senior Member
acdmi@kirk.giss.nasa.gov (Daniel M. Israel) writes:

> I've noticed that IDL seems to treat all structures as arrays of
> structures.

> Example:
> IDL> a={ new_structure, x : 1e0, y : 1e0 }
> IDL> help, /structure, a
> A STRUCT = -> Array(1)

> No matter what I do, I can't get a structure that doesn't think it is part
> of an array of one element. Now I do some things that require
> distungishing between scalars and arrays, where structures should be
> scalars. But IDL thinks all my structures are arrays of one elements. Is
> this a bug in my version? Or is it a bug in IDL? Or is there some reason
> why this notation is useful? (Because I have to kludge around it, it is
> definitely not useful for me.)

As far as I know, this is true of all versions of IDL. I don't know why this
is.

Actually, I'm not sure that it's really important to distinguish between
scalars and arrays that only have one element. It used to be important, but
later versions of IDL have been breaking down the distinctions. I've been
simply using the N_ELEMENTS() function lately to distinguish between arrays and
"scalars", rather than using the first element of the SIZE() function as I used
to do.

Of course, your mileage may vary. :^)

Bill Thompson
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: coloring buttons (widgets)
Next Topic: Wavelet transforms

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

Current Time: Wed Oct 08 17:36:39 PDT 2025

Total time taken to generate the page: 0.00737 seconds