The Daily CLAD

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

Re: Write to File with Error

SercoSteveB
Active Participant

What is the size in bytes of DataFile.txt following execution of the VI?

Write To File with Error 24_12_2014.png

a) 17

b) 18

c) 19

d) Undefined

Comments
mini09
Active Participant

Answer is 19, since the error is generated after string is written into file.

sathishp91
Member

18

A.Bernau
Member

I think it is more complicated:
LabVIEW 2014 help (via Internet) says:
"Error I/O operates uniquely in this function, which closes the file regardless of whether an error occurred in a preceding operation."

But the point is we overwrite the error output of write file and open file. Let’s assume there was an error (no or not enough disk space, drive is read only, no permission or something else) we are not able to handle the error. So to be precise for this very seldom and special case I would prefer answer d. Even most likely in almost all other cases correct answer from one day before is correct. (But it was undefined too 😉

MrStevenUND
Member

Same as previous question, depends on the OS - 18 (Unix-like) or 19 (Windows). 

Even with an error, the file is still closed (I did not know this until looking at help)

crossrulz
Knight of NI

MrStevenUND wrote:


Even with an error, the file is still closed (I did not know this until looking at help)


                   

There are a lot of functions that work even with an upstream error.  These are mostly "Close" functions (which makes perfect sense to me).  But always check the help to make sure.

Speaking of the help, here's a little paragraph that is in the help for the Format Into File:

This function converts new lines, or \n, in the format string into the platform-specific end-of-line character, for example, CR/LF on Windows, CR on Mac OS X, and LF on Linux. If you do not want to convert new lines into the end-of-line character, use the Format Into String function and wire the resulting string output to the text input of the Write to Text File function. Then right-click the Write to Text File function and remove the checkmark next to the Convert EOL shortcut menu item.


                   

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
SOM19
Member

19

sahils
Member

IS 17letter + 2 byte for next line= 19 correct? or am i missing something ?

SercoSteveB
Active Participant

Hi sahils.

Yes, on Windows, as MrStevenUND & crossrulz point out.  The question is more about how the Close File behaves with an up stream error.

SercoSteveB
Active Participant

Answer: C (for windows).  Nice one gnshmrthy, SOM19 & sahils.

Thanks MrStevenUND & crossrulz for the Win OS - Mac OS comparisons.