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

Home » Public Forums » archive » structure length in files
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
structure length in files [message #84907] Tue, 18 June 2013 08:20 Go to next message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
Hi,

[Short summary: When IDL writes structures in unformatted binary data files, what size will the resulting file have, that described by n_tags(Example1,/LENGTH) or n_tags(Example1,/DATA_LENGTH)?]

I was just looking at the length/size of a structure. I'm reading data from a file and using structures looking like this:

Example1 = {Field1: 0 ,$ ; Integer, 2 byte
Field2: 0 ,$ ; Integer, 2 byte
Field3: 0 ,$ ; Integer, 2 byte
Field4: 0 ,$ ; Integer, 2 byte
Field5: 0ULL } ; Unsigned Long64, 8 byte

Example2 = {Field1: 0 ,$ ; Integer, 2 byte
Field2: 0 ,$ ; Integer, 2 byte
Field3: 0 ,$ ; Integer, 2 byte
Field4: 0 ,$ ; Integer, 2 byte
Field5: 0ULL ,$ ; Unsigned Long64, 8 byte
Field6: 0 } ; Integer, 2 byte

When I look at it using the help command with /structure, I get:
IDL> help, example1, example2, /struct

** Structure <edbf6a0>, 5 tags, length=16, data length=16, refs=1:
...
** Structure <104d4de0>, 6 tags, length=24, data length=18, refs=1:
...

What is bothering me is that the addition of a field in the second structure results in an increased length (24 bytes) for a data length of 18 bytes. In the first example, the length is the same as the "data length". [the origin of this is probably filling the structure up to multiples of 8 bytes...]
The same results can be obtained using n_tags with the /length and data_length keywords.

So, reading the n_tags documentation, it seems like the Data_length is constant (machine independent) and the length is machine dependent (as in 32-64 bit and other things).

However, my question:
I noticed that when I read structures, the sizes are the expected "data_length" (machine independent). When IDL writes, what size will I have to expect: "length" or "data_length"?

Thanks,
Helder
Re: structure length in files [message #84908 is a reply to message #84907] Tue, 18 June 2013 08:31 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Helder writes:

> [Short summary: When IDL writes structures in unformatted binary data files, what size will the resulting file have, that described by n_tags(Example1,/LENGTH) or n_tags(Example1,/DATA_LENGTH)?]
>
> I was just looking at the length/size of a structure. I'm reading data from a file and using structures looking like this:
>
> Example1 = {Field1: 0 ,$ ; Integer, 2 byte
> Field2: 0 ,$ ; Integer, 2 byte
> Field3: 0 ,$ ; Integer, 2 byte
> Field4: 0 ,$ ; Integer, 2 byte
> Field5: 0ULL } ; Unsigned Long64, 8 byte
>
> Example2 = {Field1: 0 ,$ ; Integer, 2 byte
> Field2: 0 ,$ ; Integer, 2 byte
> Field3: 0 ,$ ; Integer, 2 byte
> Field4: 0 ,$ ; Integer, 2 byte
> Field5: 0ULL ,$ ; Unsigned Long64, 8 byte
> Field6: 0 } ; Integer, 2 byte
>
> When I look at it using the help command with /structure, I get:
> IDL> help, example1, example2, /struct
>
> ** Structure <edbf6a0>, 5 tags, length=16, data length=16, refs=1:
> ...
> ** Structure <104d4de0>, 6 tags, length=24, data length=18, refs=1:
> ...
>
> What is bothering me is that the addition of a field in the second structure results in an increased length (24 bytes) for a data length of 18 bytes. In the first example, the length is the same as the "data length". [the origin of this is probably filling the structure up to multiples of 8 bytes...]
> The same results can be obtained using n_tags with the /length and data_length keywords.
>
> So, reading the n_tags documentation, it seems like the Data_length is constant (machine independent) and the length is machine dependent (as in 32-64 bit and other things).
>
> However, my question:
> I noticed that when I read structures, the sizes are the expected "data_length" (machine independent). When IDL writes, what size will I have to expect: "length" or "data_length"?

Donno. Why don't you write one and find out? You can check the file size
with FSTAT.

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: structure length in files [message #84911 is a reply to message #84907] Tue, 18 June 2013 09:20 Go to previous messageGo to next message
Bill Nel is currently offline  Bill Nel
Messages: 31
Registered: October 2010
Member
On Tuesday, June 18, 2013 11:20:10 AM UTC-4, Helder wrote:

> [Short summary: When IDL writes structures in unformatted binary data files, what size will the resulting file have, that described by n_tags(Example1,/LENGTH) or n_tags(Example1,/DATA_LENGTH)?]

I don't believe it is documented, but empirically (on my Windows 7 system -- and several years ago on a Unix system), writeu, struct writes the structure unpadded to a file, n_tags(struct, /data_length). You can check yourself using
openw, unit, filename, /get_lun,
writeu, unit, struct
point_lun, -unit, fileOffset

There is one important exception. If the struct contains strings, then n_tags(... , /data_length) isn't the size of the unpadded structure. (This is documented.)

--Wayne
Re: structure length in files [message #84917 is a reply to message #84911] Tue, 18 June 2013 11:13 Go to previous messageGo to next message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Tuesday, June 18, 2013 6:20:13 PM UTC+2, ri...@crd.ge.com wrote:
> On Tuesday, June 18, 2013 11:20:10 AM UTC-4, Helder wrote:
>
>
>
>> [Short summary: When IDL writes structures in unformatted binary data files, what size will the resulting file have, that described by n_tags(Example1,/LENGTH) or n_tags(Example1,/DATA_LENGTH)?]
>
>
>
> I don't believe it is documented, but empirically (on my Windows 7 system -- and several years ago on a Unix system), writeu, struct writes the structure unpadded to a file, n_tags(struct, /data_length). You can check yourself using
>
> openw, unit, filename, /get_lun,
>
> writeu, unit, struct
>
> point_lun, -unit, fileOffset
>
>
>
> There is one important exception. If the struct contains strings, then n_tags(... , /data_length) isn't the size of the unpadded structure. (This is documented.)
>
>
>
> --Wayne

Hi,
thanks to both of you. Today I learned three things:
1) fstat
2) point_lun
3) to look for the solution yourself... Somewhere in the documentation you'll find the tools to answer your question.

Thanks,
Helder
Re: structure length in files [message #84918 is a reply to message #84917] Tue, 18 June 2013 11:26 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Helder writes:

> 3) to look for the solution yourself... Somewhere in the documentation you'll find the tools to answer your question.

Ah, yes. But, where!?

I spent another fruitless 20 minutes today looking for the DejaVuSans
font table, which I KNOW is in the documentation, but is so well hidden
that it might as well not exist. :-(

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: structure length in files [message #84925 is a reply to message #84918] Tue, 18 June 2013 12:05 Go to previous messageGo to next message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
Le mardi 18 juin 2013 20:26:16 UTC+2, David Fanning a écrit :
> Helder writes:
>
>
>
>> 3) to look for the solution yourself... Somewhere in the documentation you'll find the tools to answer your question.
>
>
>
> Ah, yes. But, where!?
>
>
>
> I spent another fruitless 20 minutes today looking for the DejaVuSans
>
> font table, which I KNOW is in the documentation, but is so well hidden
>
> that it might as well not exist. :-(
>
>
>
> Cheers,
>
>
>
> David
>
>
>
>
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

By simply putting "dejavusans" in the IDL help search box, you will get four answers, all of them leading you to the full documentation...
alx.
Re: structure length in files [message #84926 is a reply to message #84925] Tue, 18 June 2013 12:14 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
alx writes:

> By simply putting "dejavusans" in the IDL help search box, you will get four answers, all of them leading you to the full documentation...

Yeah, I grew up reading books, unfortunately, and look for things in the
index. Hard habit to break. :-(

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: A possible bug in IDL 8.2.3
Next Topic: Yet Another IDL 8.2.3 Anomoly with Window Refresh

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

Current Time: Wed Oct 08 11:32:37 PDT 2025

Total time taken to generate the page: 0.00512 seconds