Union in IDL? [message #16259] |
Mon, 12 July 1999 00:00 |
Guido Lemoine
Messages: 3 Registered: October 1998
|
Junior Member |
|
|
Dear All,
Is there a way to convert a bytarr of length N_TYPE to TYPE?
For instance, if TYPE = DOUBLE (so, N_TYPE=8), how do I convert the
bytarr(8) to
DOUBLE. I am looking for something like the UNION construction in C
(i.e. which
allows you, more or less, to reference a piece of memory as more then
one type).
I have been looking at IDL pointers, but can't seem to get that working.
A (fairly stupid)
work-around is to write the bytarr(8) to a binary file (writeu) and then
read it again
into a double. But that's not very elegant. Also, I would think it is
somewhat bothersome
to write an external C extension to do the union.
Ideally, there would be something like read_bin, BYTARR_VAR, VAR, /TYPE
Any ideas?
Guido Lemoine.
PS. The reason why this is non-trivial is that I am implementing a
vector reader with
DataMiner. I am already able to dump ArcView shape files into the data
base. The vectors
are written as binary blocks of doubles. If I read the stuff, however,
using VectorTable->GetField(n)
I defaultly get a BYTARR with a length equal to the number of doubles*8.
I need to convert
these back to doubles (but double(BYTARR) doesn't work, of course...).
|
|
|