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 #48648 is a reply to message #48643] Thu, 11 May 2006 06:16 Go to previous messageGo to previous message
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
In article <1147306191.957848.151880@q12g2000cwa.googlegroups.com>,
mark.macauda@gmail.com wrote:

> Ok, here is my current very frustrating problem. I have ALOT of IDL
> work done the general idea is that I read in binary files that are
> stored in very specific format...blah blah, the details aren't
> important, the important part is that rewriting all of that becuase of
> the current problem is not a desirable solution. Here's the problem.
> All the info is read in in structures and the data types are dictated
> by the binary files. One is an array of long 32-bit integers. I have
> discovered that I need to do some calculations on this array, that
> require the data type to be something other than interger. Normally I
> would just use the float command and be on my merry way...but for all
> the other programs to work I need the float arrays to be back in the
> handy dandy structures...is there anyway I can easily change that
> datatype?

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
}

Ken Bowman
[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: Thu Oct 09 20:59:03 PDT 2025

Total time taken to generate the page: 1.12006 seconds