09-02-2010 06:10 AM
Hi guys:)
My first big application is now finished and I'm about to make an installer of all my files. In the attempt to make my application bulletproof I came across a possible scenario with a bad outcome.
A little info: My application collects a number that the user inputs and some voltage readings from a DAQ. Since I don't have so much skill in formatting an Excel-sheet in Labview, I did everything in Excel. When data comes appending form Labview, my Excel-sheet formats cellcolors, calculates data and creates some dynamic graphs that expands whenever data is added. So as you can understand I spent my whole day formatting this Excel-sheet-monster-file.
Users can open the Excel-sheet form the push of a button in the Labview program. I've not made a dialog for the user to choose the filepath for the excel-sheet, in other words the path is static in my code.
BUT.. Then it hits me. What if the user deletes the file or destroys the formatting?
Since I've already choose to format the excel-sheet in Excel I'm going to stick with that. Therefore I ask you; How do you handle this with your applications?
Can Labview access a read-only-file, insert data and when users open the file they can't edit it? Like changing a file from read-only to write, insert data and then change it back to read-only.
What would be the best way of handling datafiles?
Regards,
Even
Solved! Go to Solution.
09-02-2010 07:04 AM
Hmm are you using Excel as calculating and charting software, and data from Labview? To me that sounds a Rube Goldberg machine. It will also make your setup quite vulnerable. As everybody may save and change and save an Excel file. Anyway it is very hard to prevent users from deleting files. I can mess up my Labview by deleting files I should not have deleted, quite easy
09-02-2010 07:08 AM
Just brainstorming:
You can copy the spreadsheet and only let them look at the copy.
You can try protecting the spreadsheet and prevent changes to it. This is probably doable through ActiveX but I'm not sure.
I think making a copy of your 'database' is probably the best approach, assuming it's feasible for your project.
09-02-2010 07:46 AM
A somewaht dirty trick I often use, is to give files I want give some "protection" dll as filtype. Even if it is only a text file.
09-02-2010 08:18 AM
Another option that I have used in the past is to store a copy of the file within the VI itself (I will explain that in a minute). When the program needs to access the file, if the file does not already exist on the disk, LV will automatically create the file.
To store the data file within your LV code, you essentially read the file as a text file and output to a string indicator. Copy the data from the string indicator and paste it into a string constant on the block diagram. When you need access to the file, take the contents of the string constant and write them to disk using the write to text file function. Volia! the data file you need is now on disk and ready to be read. It is significantly easier to manage when dealing with a text file however it works just as well for binary files.
While this option does work very well, it is somewhat inelegant as it requires modification of the actual LV code to modifiy the data file. Not such a big deal for a text file, but modifying a binary file requires a couple of extra steps.
09-02-2010 11:22 AM - edited 09-02-2010 11:22 AM
Make a backup copy of your file everytime your Labview code runs. Don't tell anyone where the backup is located. If the main file gets corrupted, changed, or deleted, you have a backup. You can use SysExec to issue the copy command or you can use the Copy function in the Files - Advanced palette.
For extra proctection, make your backup copy to some server location that only you know of.
09-02-2010 03:21 PM
@emyh wrote:
BUT.. Then it hits me. What if the user deletes the file or destroys the formatting?
Regards,
Even
That's what manuals and training is for, it's like saying, "what if my busdriver slashes his the tire of the bus?", if the file is that important, just tell that to the users. (i'm not saying you shouldn't think about preventing the issue)
You can set the access properties for files (make it readonly for instance), however that's quite easily bypassed in Windows
Ton
09-03-2010 01:58 AM
Hi again guys:)
Thanks for the tips!
I thought about this issue during a good nights sleep. Today I spoke to my boss and he said I had about one month extra to finish the project due to some latency at the customers side. So I'm thinking of using all of your tips:
1. Do all the formatting in Labview and create a new file if the original file does not exists or is moved.
2. Copy the datafile and let the user view it, than make a backup from the local machine to our server.
3. Write a good manual and inform users how to use the software.
I had this in mind from the beginning, but when I got the original deadline, time started running and I had to make a quick fix and do all the formatting in Excel. Specially the Excel Board on this forum will help me alot:)
Thanks and have a nice day and weekend
-Even
09-03-2010 09:46 AM
I'm glad it's working for you. But you really should credit whichever user gave you the solution by marking there message as the solution rather than your own thank you message.
You can unmark your post as the solution first by going to the options menu to the upper right of your message.