04-30-2010 11:55 AM
Hi
Can someone please post a simple open file then cancel example VI? I am trying to open a file to write ASCII text. I have that working. Now I want to catch the "CANCEL" option and NOT write the file, but do the other stuff I have done.
Thanks
Jim
Solved! Go to Solution.
04-30-2010 12:04 PM
Can you post your vi? Are you using a cancel button on the front panel or an express vi that has a cancel button on it? If you have some sort of cancel button, wire the output to a case structure. If cancelled, put whatever you want inside that case. If not cancelled, put the write to file stuff there.
04-30-2010 02:04 PM
Hi
Attached is an example .VI What I would like to have take place is:
Thanks
Jim
04-30-2010 02:19 PM
Well, the File Dialog Express VI has a "cancelled" output - so just use that. You can simply drive a case structure around your file writes.
Also, what in the world are you trying to do with the Feedback Node and that inner while loop?
Also, pleeeease read the LabVIEW Style Guide.
04-30-2010 02:21 PM
The express VI has a boolean output called Cancelled. If you cancelled the dialog box, that value is true. Put your file writing inside the false case of a case structure. Do nothing in the true case. Wire that boolean to the selector of the case structure.
I don't understand the purpose of your inner most while loop. It looks like it just writes the same data to the file 10 times in a row. And the stop condition for that loop where you have the feedback node seems very odd. I don't understand your logic there.
04-30-2010 02:53 PM
WOW!!! That isn't was LabVIEW should ever look like.
I agree with the suggestions already provided, especially reading the LabVIEW Style Guide!!
However, here's a snippet of what might be what you want to do.
I was just guessing on some of my changes to your logic.
04-30-2010 04:09 PM
Thanks for all your help, my problem is now solved. The code I provided was quickly carved out of a much larger project. I changed some of the items just so that anyone, down the road, who grabbed the code could run it. I did find it interesting that for the CASE STRUCTURE, if you changed the case to TRUE, you could drag & drop it over exisiting code. So I just changed the "CANCELLED" boolean from false to true. Attached is my revised VI which does what I want.
The comment about following style & structure are good. But since I rarely use LabVIEW, it is nice to have a simple example that anyone can follow.
Thanks again,
Cheers.
04-30-2010 04:51 PM
JCRon... you missed the target on the accepted solution selection.
04-30-2010 05:05 PM
tbob,
No he thinks his solution and coding style is "...a simple example that anyone can follow."
That mess is the type of code that gives LabVIEW a bad reputation.
And the thought that this is going to be shared with others as an example?
Oh well, I just couldn't start the weekend without trying to fix that mess.
It's 5 o'clock for me!! I'll forget about it very soon.
04-30-2010 08:12 PM
JCRon,
Go to the options menu to the upper right of your message and select unmark as solution. What you posted really is not the solution. Either mark Smercurio's who told you how to do it first, or mark JRJones who happened to GIVE YOU the correct solution and also cleaned up the mess that was once your code.
Yours isn't the solution because all you did was somewhat follow what Smercurio and I told you, but also happened to add even more code of your own that made it even messier.