bulebell Posted October 21, 2011 Report Share Posted October 21, 2011 when use this vi to write my data,why the data i had written don‘t exist。it just remain the data i just write。what did it happen? why this vi don't need close vi but the key need ?thanks very much Quote Link to comment
Mellroth Posted October 21, 2011 Report Share Posted October 21, 2011 (edited) when use this vi to write my data,why the data i had written don‘t exist。it just remain the data i just write。what did it happen? why this vi don't need close vi but the key need ?thanks very much I'm not sure I completely understands your question, but just calling the "Write To Text" method replaces any previous content (see help). If you want to append new data to the file you'll have to; Open the file with "Open/Create/Replace file" Move the pointer to the end of file using the "Set File Position" Write new data with "Write To text file" Close file refnum /J Edited October 21, 2011 by Mellroth Quote Link to comment
bulebell Posted October 21, 2011 Author Report Share Posted October 21, 2011 I'm not sure I completely understands your question, but just calling the "Write To Text" method replaces any previous content (see help). If you want to append new data to the file you'll have to; Open the file with "Open/Create/Replace file" Move the pointer to the end of file using the "Set File Position" Write new data with "Write To text file" Close file refnum /J for your information,i understand i maybe forget the "Set File Position"。 but i’m puzzled because i didn't Close file refnum, its running is ok. so whether i must add “close File”,if i don‘t use it,what will happen? Quote Link to comment
Mellroth Posted October 21, 2011 Report Share Posted October 21, 2011 for your information,i understand i maybe forget the "Set File Position"。 but i’m puzzled because i didn't Close file refnum, its running is ok. so whether i must add “close File”,if i don‘t use it,what will happen? You should always close references that you open (better safe than sorry), this is true for Files as well as Queues, Notifiers etc.. If you don't close a refnum, and continuously open new references you have introduced a memory leak, that in the end can lead to a crash. /J Quote Link to comment
jgcode Posted October 21, 2011 Report Share Posted October 21, 2011 for your information,i understand i maybe forget the "Set File Position"。 but i’m puzzled because i didn't Close file refnum, its running is ok. so whether i must add “close File”,if i don‘t use it,what will happen? That API is 'smart' it allows you to read/write using the single VIs and LabVIEW handles all the opening and closing of references in the background. However if you want more control e.g. streaming data to disk in a loop - so you dont want to open and close a reference everytime - you can explicitly handle it yourself. Quote Link to comment
bulebell Posted October 24, 2011 Author Report Share Posted October 24, 2011 That API is 'smart' it allows you to read/write using the single VIs and LabVIEW handles all the opening and closing of references in the background. However if you want more control e.g. streaming data to disk in a loop - so you dont want to open and close a reference everytime - you can explicitly handle it yourself. oh,i see, thanks very much 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.