04-16-2010 03:43 PM
I have a cluster of data that indicates tests failed. At the beginning of the main VI, I want to check if the file exists, if not create it, and if it does, read it. This file will be my saved cluster, indicating the tests that have previously failed.
I am using open/create/replace datalog and am having a problem with the cluster elements always becoming zero.
I also am trying to save the cluster to the file, every time a test fails. This does not seem to work either.
Is datalog sub vis the easiest thing to use here? Should I be using something other than a cluster?
Thanks
Solved! Go to Solution.
04-16-2010 05:18 PM
In your save vi, you have to set the operation input to open/create/replace to "replace or create". The first time you write, the datalog will be created and the data will be written.
After setting the operation to create on your save vi, I was able to run it and it created a datalog file. Then I ran the load vi with an error input so that it would read back the data. The data matched what I wrote. So there is no problem with the datalog functions.
But there is a problem with your logic. Why do you call it an error if the folder exists? When loading, you would hope that the folder does exist. So your error cases are backwards. If the folder doesn't exist, why do you write zeroes to the datalog? Also, when writing new data to the datalog, you have to set the operation to replace or nothing will happen and the new data will not be saved.
04-16-2010 10:42 PM
I was planning on the load vi to create the file, if the folder vi created the folder, the file does not exist and the no error case structure should run, and create the file,
You wrote: "But there is a problem with your logic. Why do you call it an error if the folder exists? When loading, you would hope that the folder does exist. So your error cases are backwards."
I'm sorry, I omitted the create folder from the vi, the error of which is connected to the loading cluster vi error out terminal (revised attached). If the folder does not exist, there is no error, the folder is created, the no error case structure will then create the history.dat file, and insert the cluster with all zeros.
You wrote: "In your save vi, you have to set the operation input to open/create/replace to "replace or create". The first time you write, the datalog will be created and the data will be written."
I was planning on the load cluster vi (no errror case) to create the file. I then wanted the cluster to be created and written to the file.
I tried using the save cluster vi to create or replace the cluster, and it worked like you said. I then loaded the cluster, but my path was wrong. After that was fixed, it worked.
Thanks for your help.