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

Home » Public Forums » archive » Re: changing a datatype in a structure
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: changing a datatype in a structure [message #48643 is a reply to message #48642] Thu, 11 May 2006 13:17 Go to previous messageGo to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
Kenneth Bowman wrote:
> You cannot change the type of a variable inside a structure, but you can add a
> new variable to an existing (anonymous) structure.
>
> IDL> data = {i : LINDGEN(5)}
> IDL> help, data, /str
> ** Structure <215d270>, 1 tags, length=20, data length=20, refs=1:
> I LONG Array[5]
> IDL> data = CREATE_STRUCT(data, 'x', FLOAT(data.i))
> IDL> help, data, /str
> ** Structure <215d330>, 2 tags, length=40, data length=40, refs=1:
> I LONG Array[5]
> X FLOAT Array[5]
> IDL> print, data
> { 0 1 2 3 4
> 0.00000 1.00000 2.00000 3.00000 4.00000
> }

Well, maybe it's just semantics, but in the above you create a new
structure and copy the old structure's data into. So, in effect, you're
"adding" a field to it, but in that case the following changes the type:

IDL> data = { i : indgen(5) }
IDL> help, data, /structure
** Structure <2213490>, 1 tags, length=10, data length=10, refs=1:
I INT Array[5]
IDL> data = { i : float(data.i) }
IDL> help, data, /structure
** Structure <22135b0>, 1 tags, length=20, data length=20, refs=1:
I FLOAT Array[5]

Mike
--
www.michaelgalloy.com
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: 6.3 reactions?
Next Topic: VIRUS: [avast! - INFECTED] HOT TEEN WEB CAM SHOTS FROM MSN MESSENGER

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

Current Time: Fri Oct 10 03:08:44 PDT 2025

Total time taken to generate the page: 0.47930 seconds