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

Home » Public Forums » archive » Re: Convert a byte array to 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: Convert a byte array to a structure? [message #28880 is a reply to message #28877] Thu, 17 January 2002 14:57 Go to previous messageGo to previous message
Bhautik Joshi is currently offline  Bhautik Joshi
Messages: 21
Registered: November 2001
Junior Member
> Does IDL have a simple and/or elegant way to convert a byte array
> into a structure?
> ..
> But is there a better, platform independent, way?
> (Windows NT/2K, Linux, and Solaris)
I wouldn't mind finding this out myself (its a nifty trick). However,
from what I can see, a simple method is not possible? Please, correct me
if I'm wrong.

There is a newsgroup post from a while back here (from JD Smith):
http://groups.google.com/groups?q=converting+type+struct+gro up:comp.lang.idl-pvwave++group:comp.lang.idl-pvwave&hl=e n&selm=3BAF6CAD.CFB19104%40astro.cornell.edu&rnum=3

The structure of a structure in memory is something like:

typedef struct { /* Reference to a structure */
IDL_ARRAY *arr; /* ^ to array block containing data */
struct _idl_structure *sdef; /* ^ to structure definition */
} IDL_SREF;

So what you have is data, stored as bytes in an array, that is the data
that fills out the structure fields, all concatenated together. Then
there is the 'context', which defines the data types of the fields and
how many bytes each field takes up. So, if you could extract the data
and context blocks (I haven't tried this before, but using pointers and
stuff, just like good old C) and then play with it from there...

Another option would be to use the READS command and use explicitly
formatted I/O to format the data into fields. I'm having a look at that
now, and I'll get back to you on that one :)

cheers,
Bhautik
--
/--------------------------------------------------(__)----- ----\
| nbj@imag.wsahs.nsw.gov.au | phone: 0404032617 |..|--\ -moo |
| ICQ #: 2464537 | http://cow.mooh.org | |--| |
|---------------------------+----------------------\OO/|| ------/
| international |
| roast. my sanity has gone |
| its lost forever |
\---------------------------/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: nested subroutines and scope
Next Topic: max, mean, min of array

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

Current Time: Fri Oct 10 23:20:55 PDT 2025

Total time taken to generate the page: 1.43820 seconds