From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
03-31-2014 11:23 AM
Hello,
I have a subvi in my project that is used to log data to a text file according to a user specified recording interval. I use the Get Date/Time in seconds function and concatenate the output to my data using format into string. Then I use the Write to Text File function to write the string to the file. 99% of the time, Write to Text seem to appends a CRLF to the end of the line. 1% of the time it doesn't seem to append a CRLF and I end up with a line in my log file that looks like "Timestamp,Data,Next_Timestamp,Next_Data"
I suspect a race condition maybe causing my trouble due to the inconsistent nature of the problem, but I don't see where it could be coming from. I've attached a .png showing my logfile code. Please let me know if you need any additional information. Thanks!
03-31-2014 12:04 PM
Your issue would have to be coming from the Current Data input. So you need to look everywhere that you call this subVI and make sure the end of line constant is correct.
03-31-2014 12:33 PM
Thanks for the reply!
Unless I am somehow mistaken, I am not providing the end of line constant. Instead, the Write to Text function is appending it to the string I am passing. It's just sometimes, for whatever reason, Write to Text doesn't append the end of line.
03-31-2014 12:41 PM
_Ben_ wrote:
Unless I am somehow mistaken, I am not providing the end of line constant. Instead, the Write to Text function is appending it to the string I am passing. It's just sometimes, for whatever reason, Write to Text doesn't append the end of line.
You are mistaken. The Write To Text File does not append an End Of Line. You have to write it.
03-31-2014 12:55 PM
Why don't you post the actual code instead of a picture so we can see what is in the other cases not visible in the picture? Seems kind of convoluted for simple log file.
03-31-2014 01:25 PM - edited 03-31-2014 01:28 PM
@_Ben_ wrote:
Hello,
I have a subvi in my project that is used to log data to a text file according to a user specified recording interval. I use the Get Date/Time in seconds function and concatenate the output to my data using format into string. Then I use the Write to Text File function to write the string to the file. 99% of the time, Write to Text seem to appends a CRLF to the end of the line. 1% of the time it doesn't seem to append a CRLF and I end up with a line in my log file that looks like "Timestamp,Data,Next_Timestamp,Next_Data"
I suspect a race condition maybe causing my trouble due to the inconsistent nature of the problem, but I don't see where it could be coming from. I've attached a .png showing my logfile code. Please let me know if you need any additional information. Thanks!
just slap a build array on the string in front of the write to text file.
I know, that kind of sucks to have such a simple solution available but it works without having to go and dig through all the callers. That EOL conversion can forgive a lot of string formating mistakes.
03-31-2014 01:34 PM
@JÞB wrote:
@_Ben_ wrote:
Hello,
I have a subvi in my project that is used to log data to a text file according to a user specified recording interval. I use the Get Date/Time in seconds function and concatenate the output to my data using format into string. Then I use the Write to Text File function to write the string to the file. 99% of the time, Write to Text seem to appends a CRLF to the end of the line. 1% of the time it doesn't seem to append a CRLF and I end up with a line in my log file that looks like "Timestamp,Data,Next_Timestamp,Next_Data"
I suspect a race condition maybe causing my trouble due to the inconsistent nature of the problem, but I don't see where it could be coming from. I've attached a .png showing my logfile code. Please let me know if you need any additional information. Thanks!
just slap a build array on the string in front of the write to text file.
I know, that kind of sucks to have such a simple solution available but it works without having to go and dig through all the callers. That EOL conversion can forgive a lot of string formating mistakes.
So it won't add an extra EOL if one is already there?
03-31-2014 01:45 PM
@ Not so lowly minion
Nope, It'll convert any EOL it sees to the OS specific EOL and only add one if its missing one.
Open the example from the help and play with it to prove it to yourself.
03-31-2014 02:22 PM
Sorry about that! Here is the code.
03-31-2014 02:29 PM
This code looks very fragile.