star Posted February 23, 2009 Report Share Posted February 23, 2009 Hi all, I have made a code that sends a number to a file, however if i send another number the previous number gets deleted and the new number gets stored. So i was wondering if anyone can help me and i have attached my code. Thanks Quote Link to comment
star Posted February 23, 2009 Author Report Share Posted February 23, 2009 Sorry i forget to say what i want my code to do. I want it to keep on stored new numbers, while it keeps the old numbers stored in the same file (like a list). Quote Link to comment
2and4 Posted February 23, 2009 Report Share Posted February 23, 2009 Changing the "access (0:read/write)" Enum input to the "Open/Create Replace File" function from "write-only (truncate)" to "write-only" seemed to solve the problem. I don't know if that item was available with that Enum in an older version of LabVIEW, but on my copy of LV 8.6 that Enum caused a coercion dot. Here's a slightly cleaned up version of your VI and a screenshot (in case you don't have LV 8.6). You might also want to concatenate a LineFeed at the end of each number. Quote Link to comment
star Posted February 23, 2009 Author Report Share Posted February 23, 2009 Yeah i am using version 8.5(thats ok), but the new number which i saved is on the same line as the previous one and i want it to be save on the next line. And if i want to save more numbers, it would be on the next line. I was thinking of using the tab function but i don't have alot of knowledge about it. Thank you anyways Quote Link to comment
nicolasB Posted February 23, 2009 Report Share Posted February 23, 2009 if you want to write to the next line, write a end of line Constant to the file or concatanate it with the string you're writing. You can also use the write to spread sheet file.vi. It offers the parameters append and tronspose which could be useful for you. Quote Link to comment
star Posted February 23, 2009 Author Report Share Posted February 23, 2009 where can i find the write to spread sheet file.vi. Quote Link to comment
jdunham Posted February 23, 2009 Report Share Posted February 23, 2009 The old NI File functions used to append data by default, and now the new ones overwrite by default. NI are you listening? Its sucks! (Sorry to be so grumpy) Quote Link to comment
star Posted February 23, 2009 Author Report Share Posted February 23, 2009 QUOTE (nicolasB @ Feb 22 2009, 09:39 PM) if you want to write to the next line, write a end of line Constant to the file or concatanate it with the string you're writing.You can also use the write to spread sheet file.vi. It offers the parameters append and tronspose which could be useful for you. when i did it, it work however it takes a while to execute and i have to keep the write button on before i run it and leave it on until it the code finishes. Is it possible for the code to run faster and also when i run the code, i want to wait until the user press write button and then end when the information is saved to the file. QUOTE (star @ Feb 22 2009, 10:29 PM) where can i find the write to spread sheet file.vi. improved code Quote Link to comment
nicolasB Posted February 24, 2009 Report Share Posted February 24, 2009 QUOTE (star @ Feb 23 2009, 12:30 AM) when i did it, it work however it takes a while to execute and i have to keep the write button on before i run it and leave it on until it the code finishes. Is it possible for the code to run faster and also when i run the code, i want to wait until the user press write button and then end when the information is saved to the file. The code will be faster if you open the file once and work with the reference. Look at the event structure to realize the user interaction. regards, nicolas Quote Link to comment
star Posted February 24, 2009 Author Report Share Posted February 24, 2009 QUOTE (nicolasB @ Feb 23 2009, 07:19 AM) The code will be faster if you open the file once and work with the reference.Look at the event structure to realize the user interaction. regards, nicolas Hi nicolasB I have done some tutorials on events srtructures, however i don't know how to use it in this example. Quote Link to comment
nicolasB Posted February 24, 2009 Report Share Posted February 24, 2009 QUOTE (star @ Feb 23 2009, 10:02 AM) Hi nicolasBI have done some tutorials on events srtructures, however i don't know how to use it in this example. Just a 5 minute example of your code with an event structure. Without error handling etc. 1. open file 2. press write? Nicolas Quote Link to comment
ejensen Posted February 24, 2009 Report Share Posted February 24, 2009 QUOTE (nicolasB @ Feb 23 2009, 10:23 AM) Just a 5 minute example of your code with an event structure. Without error handling etc. You were faster than me, but mine keeps the filename constant and has comments which may be useful. I'll post it anyway since I've already done the work. Quote Link to comment
star Posted February 24, 2009 Author Report Share Posted February 24, 2009 I can't open because it's on the newest version. Quote Link to comment
nicolasB Posted February 25, 2009 Report Share Posted February 25, 2009 QUOTE (star @ Feb 23 2009, 08:35 PM) I can't open because it's on the newest version. ...saved for 8.5 Quote Link to comment
star Posted February 25, 2009 Author Report Share Posted February 25, 2009 It works, however this code was smaller part of a bigger code and when I executed the big code it work until it reached the writing file.vi. The reason why is the writing file.vi doesn't stop or the bigger code needs to be in an event structure. I attached the whole code so you could look it. Thank you for version 8.5 Quote Link to comment
star Posted February 28, 2009 Author Report Share Posted February 28, 2009 QUOTE (star @ Feb 24 2009, 03:09 PM) It works, however this code was smaller part of a bigger code and when I executed the big code it work until it reached the writing file.vi. The reason why is the writing file.vi doesn't stop or the bigger code needs to be in an event structure. I attached the whole code so you could look it.Thank you for version 8.5 Can someone start me off to make this code in a sequence structure and using event structure as well. Please Quote Link to comment
nitulandia Posted April 4, 2009 Report Share Posted April 4, 2009 I'm still using LV 8.2, therefore, I couldn't see the solutions posted. Here's one way of accomplishing this (see attachment) Quote Link to comment
Justin Reina Posted April 4, 2009 Report Share Posted April 4, 2009 Hello star, So are you saying the 'Write File Y.vi' or 'Write File X.vi' hangs? If so, where does it hang? To troubleshoot this, in a 'hung' piece of code, put the 'highlight execution' tool on. A green arrow will be over the 'vi' that is hung. Could you try this, and provide a little more detail with regards to your request? Best of Luck, Justin 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.