02-04-2015 01:46 PM
Hi everyone,
I have a program that runs a DC and AC test. I want to label each run by a number, which I call run number, and which I want to save in a file along with the data taken. i tried to implement this by adding to my program the code attached to this email. In the path string I want to put the name of the file where I will save the data. How can I "tell" the program to get the name of the file from the last run?
Also, is this a good way of doing it or does anyone have a better way of implementing this?
Thank you,
Christian
Solved! Go to Solution.
02-04-2015 01:53 PM - edited 02-04-2015 01:54 PM
Very simple... if you just add a little bit of code, that will do it. When you want your VI to take name from the last run, don't enter anything through path input and it will use last path. When you want a new path, simply supply that.
-BTC
02-04-2015 02:08 PM
Thank you. I tried it, but if I don't give it an input in the path string, it gives me an error saying that the path is either empty or relative.
Christian
02-04-2015 02:14 PM - edited 02-04-2015 02:15 PM
@christianwos wrote:
Thank you. I tried it, but if I don't give it an input in the path string, it gives me an error saying that the path is either empty or relative.
Christian
Sounds like you're entering a filename that does not exist... or maybe you switched wires in "Select" function? Also, are you stopping and then restarting the VI for each filename? (If so, that may require a bit different code)
-BTC
02-04-2015 02:21 PM - edited 02-04-2015 02:28 PM
- Sounds like you're entering a filename that does not exist... or maybe you switched wires in "Select" function?
No, I wired the select function just like you did.
- Also, are you stopping and then restarting the VI for each filename? (If so, that may require a bit different code)
Well, I don't really stop the VI. The VI jus stops automatically when the test is over. I am not sure whether that makes a difference or not. If you don't mind, I attached the VI to this message. I was working on the run number logic separately, before adding it to the main VI. I am not sure where to place it in the main VI, though.
Thanks again,
Christian
02-04-2015 02:41 PM - edited 02-04-2015 02:42 PM
@christianwos wrote:
- Sounds like you're entering a filename that does not exist... or maybe you switched wires in "Select" function?
No, I wired the select function just like you did.
- Also, are you stopping and then restarting the VI for each filename? (If so, that may require a bit different code)
Well, I don't really stop the VI. The VI jus stops automatically when the test is over. I am not sure whether that makes a difference or not. If you don't mind, I attached te VI to this message. I was working on the run number logic separately, before adding it to the main VI. I am not sure where to place it in the main VI, though.
Thanks again,
Christian
Ah, I see. Your VI essentially goes through that state machine and then ends so I'm guessing that for the next run you're running the VI again. (essentially you're restarting the VI and you want next run of the VI to remember filename from last run).
You could save filename in a text file and read back in the next run, otherwise I don't believe there is any guarantee that last run name will be retained in that VI. Please check the following images (true/false case in each):
Please note that above logic is a bit raw, it may require you to add error-handling/etc. Hope that helps!
-BTC
02-04-2015 02:56 PM
Thank you so much for all your help. I will try it and let you know if it works.
Christian
02-04-2015 03:24 PM
I would have thought that if you were going to be working in a single folder you could also take the last edited item to be the last file.
02-06-2015 01:25 PM
Sorry to bother again, but now the VI gives me a different error. When I run it it says that an error occurred at the "Scan From String" funtion. The error is: "Scan failed. The input string does not contain data in the expected format." But I am using an I32 as sink and the format should be %d, shouldn't it?
- Christian
02-09-2015 03:36 PM
Hi Christian,
Try using %s as the format for the Scan From String function.
If I understand the situation correctly, you should be reading in a String value in the Scan From String function "input string" node.
Regards,
Daniel