Re: IDL XDR Problem [message #9442] |
Mon, 07 July 1997 00:00 |
Jack Saba
Messages: 30 Registered: January 1996
|
Member |
|
|
Justin Baker wrote:
>
> Hi there,
>
> I've got a problem with IDL when reading XDR data generated by a C
> program.
> I can happily read in longs or floats, but IDL gives a strange error
> when I try and read in strings.
>
> i.e % READU: Error encountered reading from file. Unit: 1
>
> My program is very simple, for example
>
> ...
> max_recs = 1000
> rec = {i:0, l:0L, f:0.0, s:''}
1. When reading a binary record, you have to specify the number of bytes
in the string or IDL won't know how much to read. Here you tell IDL to
read 0 bytes into rec.s.
2. IDL will pad this structure to a multiple of 4 bytes, in this case to
12 bytes (if the first variable were 8 bytes long, the padding would be
to 8N or 16 bytes). Chances are that's not the length of your record. If
your record is not 4N bytes long, you won't be able to use a structure
to read the data.
--
Jack Saba <jsaba@magus.stx.com>
|
|
|