07-26-2010 03:17 PM
Hello,
I am new to this forum and relatively new to labview. I am having an issue with the subvi "write to speadsheet." When a file is finished running, I choose to save the file in a certain directory. However, if (by accident) a pre-existing filename is chosen I will receive the prompt to either replace or cancel the save. If I choose replace I lose the old file. If I choose cancel I loose the new file's data. How can I modify the package subvi to prevent this.
Ideally I would like the options: replace, choose other name, or cancel.
Any suggestions.
Thanks
07-26-2010 03:31 PM
I'd check for uniquesness of filename before doing the Save.
07-26-2010 03:36 PM - edited 07-26-2010 03:38 PM
If I enter a name that is already taken, it is usually an accident.
I hate to lose hours worth of data over an inadequate program function.
07-26-2010 03:44 PM - edited 07-26-2010 03:46 PM
People have and solved it by checking the file name before calling the Write to Spreadsheet. Don't you have a path control on the front panel? You could use the Check if File or Folder Exists function. You can also show the Browse button and only allow new files. Lots of ways including modifyint the Write to Spreadsheet function itself (be sure to rename and save in a new location).
07-26-2010 03:57 PM
I am leaning toward the modify "write to spreadsheet" function itself. It seems like the other options are external fixes of the original function. I am looking into rewriting it now. If you know of a post or tutorial that has already done this please let me know.
Thanks
07-26-2010 04:17 PM
The original function really does not need a 'fix' and I don't know of any examples of modifications. I'll bet you could find some examples of specifying the file before calling the function, though. As I said, I think thats the more typical usage.
07-28-2010 05:48 PM
As a matter of fact it a very simple 'fix' to an annoying problem. I'd had times were I would loose experimental data because I accidently select a file that I don't want replaced.
The error that you get when this happens is 43. In the write to spreadsheet file vi I added a loop and told it to repeat writing the file if this error occurred. There are a few messages that you just have to press continue but those can be changed if you dig in a little deeper. Also, the three button idea is good, I 'm pretty new in LV and using LV 7 express, so I don't know if later version have remedied this annoying bug, but I'll dig in a little deeper to see how i can intergrate the 3 button idea.
07-28-2010 07:04 PM
Thanks!!!! This is exactly what I was talking about.
07-28-2010 07:06 PM
It is a really bad idea to write to the file at the end of the program (after the main loop) with no mechanism of recovery. If you architect your program as a proper state machine, you data is stored e.g. in a shift register and saving to a file just executes another state, without stopping the loop or modifying the data in the shift register.
07-28-2010 07:08 PM - edited 07-28-2010 07:10 PM
Say what?
I don't know what that meant.
Are you refering to when we write the original program or the re-writing of the "write to speadsheet" subvi?