Jump to content

Set File Position?


Recommended Posts

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

Link to comment

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

Link to comment

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.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.