The Daily CLAD

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: File Operations: Write to binary file (with Clusters)

SercoSteveB
Active Participant

Which of the following most closely describes the sizes of the files generated by the following VI?

BIN Files.bmp

a) steve.txt is the same size as steve2.txt

b) steve.txt is larger than steve2.txt

c) steve.txt is smaller than steve2.txt

d) steve2.txt is the larger as steve.txt was not created due to an error

Comments
crossrulz
Knight of NI

Can you update that picture to either be a snippet or make it larger.  I can't quite make out what's happening.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
crossrulz
Knight of NI

A


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Neelamma
Member

Ans:A

Pratibha
Member

Ans:- A

Asha_Nagaraj
Member

Ans :- A

mini09
Active Participant

A...

faymia
Member

Agreed with all of the folks above, the answer is A.

SercoSteveB
Active Participant

Answer: A.  Nice one crossrulz, Neelamma, Pratibha, AshaNagaraj, gnshmrthy & faymia

clendon.gibson@canrig.com
Member

The answers refer to steve.txt, but the files are steve.bin.

Can someone explain why a cluster with a string is the same size on disk as just the string?

plyons
Member

I would love to see some kind of explanation here- I got the answer wrong thinking that a cluster of a string would contain more information in binary form than just a string (of the same length).  I made myself a little vi to try and learn this stuff (seeing as Im now feeling like I'm far less knowledgable than I thought I was haha) and I have a question.

I'm attaching a pic of some code that I dont quite understand - this could be a dumb question, but I'm too frustrated to care. CLADquestion.PNG

why dont the two-element cluster and the double length string have the same file size? (20 vs 16bytes)

john111
Member

Yeah i would also like to know the answer to this question. And why is file with a "string" 10bytes big? Shouldn't it be 6 bytes? I've opened the file and there are some spaces in there, that's why it's 10 bytes then. Why it adds the spaces?

crossrulz
Knight of NI

When writing to a BINARY file, there is on option on the top of the Write Binary File to prepend the Array and String lengths.  By default, it is set to true.  So for each string, there will be 4 bytes (I32) written before the string saying how long the string is.  In the case of the two string cluster, this length is added to each string.

If you just want to write plain text, you should use the Write Text File instead.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
ashwinilele
Member

Ans is A

Very good explained by plyons

hemanths
Member

hi all,

Can any one please explain me that, To know the file size i am using Get file size function. Please find in the snippet. Is that

correct or any other alternate method(shortcut). Please explain. Sorry for my Limited Knowledge.

Get File Size Function.png

crossrulz
Knight of NI

hemanths wrote:


                       

To know the file size i am using Get file size function. Please find in the snippet. Is that

correct or any other alternate method(shortcut).


                   

That is the way to do it.  I would probably get the size after the File Close, but it should not really matter.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
hemanths
Member

Thanks