prads Posted May 29, 2008 Report Share Posted May 29, 2008 Hello, I have a text file into which I have to write string data. The data I write consists of (a) Position, (b) Timestamp and © some bits. All these have to be appended to the same file. I started with the Position and then used the Set File Position.vi with a 0-offset and 1-from values for the vi to point to the end of file. Then I connected it to another WriteFile.vi with the refnum from previous SetFilePosition.vi. As required, the Timestamp value was written in the next line in the file. Then I again connected the refnum to another SetFilePosition.vi and WriteFile.vi. However it now writes these bits in the same line and exactly adjacent to the Timestamp. I want these bits and whatever I append in future to the file to be written in the next line. Here's how my textFile looks like: 86.0 21.0 8231.0 05/27/2008 15:10:1200101111000 --as seen here the bits(00101111000) are written adjacent to the Timestamp but I want it to be written in the next line!!! Please help me..... Thanks, prads Quote Link to comment
Mellroth Posted May 29, 2008 Report Share Posted May 29, 2008 QUOTE (prads @ May 28 2008, 05:31 AM) H05/27/2008 15:10:1200101111000 --as seen here the bits(00101111000) are written adjacent to the Timestamp but I want it to be written in the next line!!! Hi prads, it is always easier to get good answers if you can post a picture, or a piece of code, to show us what you have done. If you want the bits to be written on the next row, add a newline '\n' at the end of the timestamp. Appending data to a file does not require the Set Write Position to explicitly tell LabVIEW to append the data at each write operation, it is only necessary to do this before you start writing data to the file. Hope this helps /J Quote Link to comment
Justin Goeres Posted May 29, 2008 Report Share Posted May 29, 2008 QUOTE (JFM @ May 27 2008, 10:29 PM) Appending data to a file does not require the Set Write Position to explicitly tell LabVIEW to append the data at each write operation, it is only necessary to do this before you start writing data to the file. To elaborate a little bit on this, the File Position is automatically tracked by LabVIEW and is associated with the file refnum that you're passing into the Write File function(s). It is automatically updated after each Write or Read. So if you want a write operation to begin "where you left off last time" you don't have to use Set File Position. Quote Link to comment
Francois Normandin Posted May 29, 2008 Report Share Posted May 29, 2008 QUOTE (JFM @ May 28 2008, 01:29 AM) Hi prads,it is always easier to get good answers if you can post a picture, or a piece of code, to show us what you have done. If you want the bits to be written on the next row, add a newline '\n' at the end of the timestamp. Appending data to a file does not require the Set Write Position to explicitly tell LabVIEW to append the data at each write operation, it is only necessary to do this before you start writing data to the file. Hope this helps /J Indeed, each time you append some data to file, the "Set Position" will be at the end of what you wrote. If that was at the end of the file, you'll still be at the end of the file without any need to specify it. You can use the "Set Position" VI when you want to change some data in a file without rewriting all of it (changing a status bit or else...). Also, you might want to save your bits as a number instead of text "01010101". Your code & file will both be more compact, and it's easy to convert back to array of bits if needed. See attached picture. http://lavag.org/old_files/monthly_05_2008/post-10515-1211978264.jpg' target="_blank"> EDIT: It took me too long to write! Justin beat me to it... :-) Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.