LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple open File then CANCEL Example

Solved!
Go to solution

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

0 Kudos
Message 1 of 11
(6,142 Views)

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.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 11
(6,137 Views)

Hi

Attached is an example .VI   What I would like to have take place is:

 

  1. Start up VI
  2. If File Dialog box is cancelled - Don't write file but update screen
  3. If File Dialog is OKed - write file & update screen

Thanks

Jim

0 Kudos
Message 3 of 11
(6,108 Views)
Solution
Accepted by topic author JCRonSaratoga

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.

Message 4 of 11
(6,103 Views)

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.

Message 5 of 11
(6,102 Views)

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.

 

FileWriteCancel.png

 

LabVIEW 5.0 seems so long ago...
Message 6 of 11
(6,090 Views)

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.

0 Kudos
Message 7 of 11
(6,075 Views)

JCRon...  you missed the target on the accepted solution selection.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 11
(6,062 Views)

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.

 

 

LabVIEW 5.0 seems so long ago...
0 Kudos
Message 9 of 11
(6,054 Views)

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.

Message 10 of 11
(6,033 Views)