| Re: Changing a structure [message #2383] |
Fri, 24 June 1994 13:40  |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
kkobayas@husc9.harvard.edu (Ken Kobayashi) writes:
> In IDL, is there any way to change the structure of an existing structured
> variable? Or do I have to break it down to the components, save, exit, start
> idl again, restore, and re-assemble a new structure?
If you use anonymous structures, then you don't have to go through all that.
Simply create the new structure out of the old structure. For example, suppose
you set
A = {IMAGE: indgen(100,100), LABEL: 'label', DATE: '24-JUN-94'}
and you want to multiply the image 3.74 to put it into physical units. Since
this would convert it from integer to floating point, you can't simply say
A.IMAGE = 3.74*A.IMAGE
However, you can say
A = {IMAGE: 3.74*A.IMAGE, LABEL: A.LABEL, DATE: A.DATE}
It's still a bit tedious, but better than dealing with named structures.
Bill Thompson
|
|
|
|
| Re: Changing a structure [message #2447 is a reply to message #2383] |
Wed, 29 June 1994 14:47  |
HADFIELD[1]
Messages: 9 Registered: March 1994
|
Junior Member |
|
|
In article <thompson.772490435@serts.gsfc.nasa.gov> thompson@serts.gsfc.nasa.gov (William Thompson) writes:
> ... suppose
> you set
> A = {IMAGE: indgen(100,100), LABEL: 'label', DATE: '24-JUN-94'}
> and you want to multiply the image 3.74 to put it into physical units. Since
> this would convert it from integer to floating point, you can't simply say
> A.IMAGE = 3.74*A.IMAGE
Well, you can, but the answer is converted to integer type before it's stored
in A.IMAGE.
============================================================ ===========
Mark Hadfield hadfield@greta.niwa.cri.nz
NIWA Marine (Taihoro Nukurangi) NIWA.GRETA:HADFIELD
Wellington, New Zealand
|
|
|
|