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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

First Values Keep Replacing Old one despite file position set

Solved!
Go to solution

I have saved to file and I have used the save to file function.

It works well and for each run I have 6 values, however on the second run there, the first new value replaces the old first value but others work well.

What can I do?. I set the position to end for each value collected.

 

Thanks

0 Kudos
Message 1 of 8
(2,509 Views)

It's impossible to debug a paragraph.

 

Try attaching your VI.

0 Kudos
Message 2 of 8
(2,502 Views)

I attach the VI.

 

Thanks

 

0 Kudos
Message 3 of 8
(2,491 Views)
Solution
Accepted by topic author concacid

I think you would benefit greatly from looking at the LabVIEW tutorials.

 

A few things right off the bat:

Try and get away from using Stacked Sequences to repeat code. You'll do much better with a state machine or by using a subVI.

Don't use a local variable for the FileRefnum. Use the wire itself.

Message 4 of 8
(2,474 Views)

Thanks. 

 

I know how to use a state machine but then this is a relatively simple program and runs peferctly but for the svaing option.

 

I would trying using the wire for the file refnum

 

Thanks

0 Kudos
Message 5 of 8
(2,472 Views)

Hi concacid,

 

even for this "relatively simple" program you should THINK DATAFLOW and use wires in favor of local variables…

In your case an autoindexing loop for your 6 channels would be ok too!

 

That being said:

- Using file refnums should append writes at the end of the file. Please test this after replacing all "refnum out" variables by wires.

- When you insist on using SetFilePosition you should set the write position before doing the actual write, not afterwards. Seems more logical to me…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 8
(2,466 Views)

@GerdW wrote:

Hi concacid,

 

even for this "relatively simple" program you should THINK DATAFLOW and use wires in favor of local variables…

In your case an autoindexing loop for your 6 channels would be ok too!

 

That being said:

- Using file refnums should append writes at the end of the file. Please test this after replacing all "refnum out" variables by wires.

- When you insist on using SetFilePosition you should set the write position before doing the actual write, not afterwards. Seems more logical to me…


Thank you!

Points noted

 

0 Kudos
Message 7 of 8
(2,449 Views)

The state machine and 'all wires' did the trick.

 

Scrap the local variable then. Its more or less useless.

 

Thanks guys

 

0 Kudos
Message 8 of 8
(2,433 Views)