NI LabVIEW,CVI,数据采集等产品讨论区

取消
显示结果 
搜索替代 
您的意思是: 

why write value into txt file after read the txt file . sometimes the value changed.

Dear all

 

I come across a problem that confused me .

when i write a value into txt file ,then i read the txt file ,i find the value sometimes can be changed .it has probablity.

why txt file occurs thus phenomenon.if somedoby encounter thus problem as me.

 

Thanks.

0 项奖励
1 条消息(共 10 条)
6,890 次查看

i find the value sometimes can be changed

To what ??

 

Did you flash after write?

If the value is old one, then it must Windows is holding the new value in the buffer.

If the value is new meaningful value, you might have a race condition.

If the new value is garbage, you have a bug.

 

 

George Zou
0 项奖励
2 条消息(共 10 条)
6,886 次查看

Dear George Zou

 

Thands for you help

 

->Did you flash after write?

I don't know how to flash after write.

falsh after write will apply with which function ,if use the  FileI/O->Advanded Fies Functions->Flush File.

attach is a simple write/read function with Flush file funciton.

please point out  flaws in the program.

 

Thanks.

 

Best Regards

 

hoover

0 项奖励
3 条消息(共 10 条)
6,864 次查看

Sorry I made a typo.  I mean "flush".


You don't need to set file size.

Use error cluster to catch errors.

 

 

George Zou
0 项奖励
4 条消息(共 10 条)
6,852 次查看

Try this example:

C:\Program Files (x86)\National Instruments\LabVIEW 2013\examples\File IO\Text (ASCII)\Write to Text File and Read from Text File.vi

 

 

George Zou
0 项奖励
5 条消息(共 10 条)
6,849 次查看

You don't even need to flush, close file does it.

Are you writing 中文 to the file?

Maybe try binary file instead of text file.

 

George Zou
0 项奖励
6 条消息(共 10 条)
6,846 次查看

 

Dear George Zou

->Are you writing 中文 to the file?

I just write numerical value to the txt file ,for example ,12345.

 

Best Regards

 

hoover

0 项奖励
7 条消息(共 10 条)
6,802 次查看

Have you tried the above example yet?

 

George Zou
0 项奖励
8 条消息(共 10 条)
6,789 次查看

Dear George Zou

 

I have tried ,example is no problems

 

blow website is post program sourcecode  in the community,

please look over.

 

http://forums.ni.com/t5/LabVIEW/why-same-data-write-into-txt-file-and-write-csv-file-then-read/m-p/3...

 

Best Regards

0 项奖励
9 条消息(共 10 条)
6,788 次查看

Then it got to be a bug in your program.

Other people already gave you good advise.

Simplify your program, remove none relative items one by one, until the problem gone.

That's how you debug.

 

 

George Zou
0 项奖励
10 条消息(共 10 条)
6,774 次查看