N_TAGS( , /LENGTH) strange result! [message #13900] |
Wed, 06 January 1999 00:00 |
Luis Oliveira
Messages: 4 Registered: November 1998
|
Junior Member |
|
|
Hi all readers.
My problem with N_TAGS(?,/LENGTH) is that it's result with some structures
is diferent from the size of the files that That structures originate?!
(Diferences of about 3 or 4 bytes.)
I am using IDL to read some unformated data file that was written with a C
program. The size calculated with the C structures was the same as the size
of that structures in files. N_TAGS gives a diferent value, but when I
write the same structure with IDL to a file, it's size is the same as the C
structures!
My IDL version is 5.11 in a windows95 PC.
Thanks for any light on this subject...
Luis
PS: After some tests, I've seen that this happens with structures that have
members that are structures... here goes an example:
IDL> x={a:0L,b:0,c:bytarr(5),d:0B,e:bytarr(3),g:{a:0B,b:0}}
IDL> print,n_tags(x,/length)
20
IDL> x={a:0L,b:0,c:bytarr(5),d:0B,e:bytarr(3),g:{a:0B,b:0},f:0B}
IDL> print,n_tags(x,/length)
24
This two structures only differ by one byte! The real length is 18 and 19.
Now, if I write the structure to a file:
IDL> openw,1,'lixo.txt',/delete
IDL> writeu,1,x
IDL> print,(fstat(1)).size ;To return the size of the file
19
IDL> close,1
|
|
|
Re: N_TAGS( , /LENGTH) strange result! [message #13905 is a reply to message #13900] |
Tue, 05 January 1999 00:00  |
mgs
Messages: 144 Registered: March 1995
|
Senior Member |
|
|
In article <01be38eb$bb18fe80$56040a0a@loliveira.ipimar.pt>, "Luis
Oliveira" <eu_luis@hotmail.com> wrote:
> Hi all readers.
>
> My problem with N_TAGS(?,/LENGTH) is that it's result with some structures
> is diferent from the size of the files that That structures originate?!
> (Diferences of about 3 or 4 bytes.)
>
> I am using IDL to read some unformated data file that was written with a C
> program. The size calculated with the C structures was the same as the size
> of that structures in files. N_TAGS gives a diferent value, but when I
> write the same structure with IDL to a file, it's size is the same as the C
> structures!
>
> My IDL version is 5.11 in a windows95 PC.
>
> Thanks for any light on this subject...
>
> Luis
>
> PS: After some tests, I've seen that this happens with structures that have
> members that are structures... here goes an example:
I suspect you're running into problems with the number of bits in the
processing architecture. Sorry, I don't know how to word the explanation
decently. Basically, your 32-bit PC is probably adjusting part of your
structure to sit on byte boundaries. I've seen similar things when dealing
with PC's, Mac's (32-bit systems) and UNIX (32-bit and 64-bit systems).
--
Mike Schienle Interactive Visuals, Inc.
mgs@ivsoftware.com http://www.ivsoftware.com/
|
|
|