LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error when user hits Cancel in File Dialog Box

Error 43 occurs when the user hits cancel about saving a file. I have a simple state machine, and when the user hits "RUN", the dialog box comes up. What if they change their mind? I have tried to use the "exception code" in the General Error Handler for Error 43 but I still end up with an error message or my VI stopping.

Are there any templates for VIs that save your data only when you press a "SAVE" button, or either that don't freak out if you hit Cancel?

p.s. I have LabVIEW 6.1.

THANK YOU
Lauren
0 Kudos
Message 1 of 14
(6,250 Views)
I suspect that you are using a high level save function such as "Write to spreadsheet file" or "Write characters to file" which give you a dialogue box when the path is empty. The error message is coming from the error handler inside the this VI. There are a couple of ways that you can easily modify these VIs to meet your needs. One way is to move the error handling outside of that VI. You can also change the code such that there is no error. One way to do this is given in the attached modification for the "Write characters to file" VI. While I haven't done it with this example modification, I typically like to move as much of the error handling as possible into the main algorithm.
Message 2 of 14
(6,247 Views)
Are you using one of the NI provided file I/O functions like Write Characters to File or Write to Spreadsheet File? These and others have the General Error Handler inside and you might want to make your own copy of the VI and do your own error trapping and remove the General Error Handler. File Dialog itself returns a Boolean for cancel which Open/Create/Replace File converts to an error 43. You can have a separate File Dialog function and jump to the next state based on the canceled Boolean or use an unbundle by name and jump to the next state based on the error code returned by Open/Create/Replace File.
Message 3 of 14
(6,247 Views)
I always use the file dialog. Then you can filter on the "cancelled" boolean before handing the path to your high-level read or save operation. (See attached example in LAbVIEW 6.1).
Message 4 of 14
(6,247 Views)
Hmm these ideas seem like they'll work, I looked at them all. Thanks.
0 Kudos
Message 5 of 14
(6,247 Views)

Hey, I got the same problem, Error 43 when cancel button is clicked, as I was going through one of the examples from "LabView for Everyone" book. I downloaded the Cancelled.vi example and constructed a case structure for it. However, the problem still occurs. When i ran highlight execution for the cancelled.vi example, as the cancel button is pressed the file dialog goes through and sends out boolean value of the cancel status. But for the file I'm working with, the boolean value is not send when cancel button is entered. File dialog sends out an error before the values are send out... Can someone explain? Thanks.

Download All
0 Kudos
Message 6 of 14
(5,879 Views)

You have automatic error handling enabled, and since the file dialog ends with an error code (due to the cancelation!), you get the automatic error popup. You have two choices:

  1. disable automatic error handling (On "Tools...options...block diagram". not really recommended!)
  2. Wire the "error out" of the file dialog to the error in of the invoke node. (recommended!).

In general, you should always untilize the error cluster. 🙂

Automatic error handling will create a popup for any node that (1) has the error-out unwired AND (2) completes with an error.

Message Edited by altenbach on 07-12-2007 08:43 AM

0 Kudos
Message 7 of 14
(5,870 Views)
Actually, the regular file dialog does not generate an automatic error popup if canceled. Something is screwed up in your VI, also from the way it shows the connector pattern instead of the icon on the diagram. Do you know where you got that from or what could have happened?
 
I would delete the current file dialog and substitute a fresh version from the file i/o palette.
0 Kudos
Message 8 of 14
(5,858 Views)
Hey thanks for the suggestion. It worked when I connected the file dialog's error out with invoke's error in. The connector icon was an option [pop->visible>terminal] ]that I used instead of the icon because I saw that your file dialog was different from the file dialog I used and they had different terminals. However, the different version of the file dialog was not the problem, I think, because I interexchange them and the same event occured. 
0 Kudos
Message 9 of 14
(5,853 Views)

is it possible that we can add to the exe file? bcoz after i make this a exe file this vi is not working

 

0 Kudos
Message 10 of 14
(4,452 Views)