LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cancelling prompt terminates VI

I have constructed a VI that has the capability of saving data or printing data during runtime. Basically the program runs continuously until the user presses the "stop" button. A boolean control allows the user, during run time, to select to print or save data. However, if the user decides to not save by pressing "cancel" in the save dialog box, LabVIEW returns an error message and the VI terminates. Thus the recently acquired data is lost. I realize that I could perform an autosave to work my way around the error, but i would prefer no error. Is there another solution? Such that if one decides to cancel saving data, the VI will not terminate?

Thanks in advance,

Philip
0 Kudos
Message 1 of 9
(3,628 Views)
What VI are you using? As an example, Open/Create/Replace File has an input called Advisory Dialog?. Set it to false and the user can select cancel without a pop-up dialog box appearing. It will generate an error with code 43. If you set a trap for this condition, you can proceed as you like.
Message 2 of 9
(3,628 Views)
Hi Philip,
I guess you are conditionally stopping a main while loop both when you hit the stop button and an error occurs.
When you hit cancel on the file dialog an error code 43 is generated, this stops your loop with the loss of data.
To avoid it simply let the error occurence to stop the loop only when the error code is different than 43.
Hope it was clear,

Alberto
Message 3 of 9
(3,628 Views)
For all file operations that must query the user for a file name, I find it easiest to prepend the generic "File Dialog", then bypass the "save" operation if cancelled is true.

See attached image ("true" case is empty of course).
Message 4 of 9
(3,628 Views)
If you're using the simple/upper level vi's, they typically have error handling routines. For example, in the Write to Spreadsheet.vi you can delete the General Error handler (then use Save As and put it somewhere other than the default library). This is one of the easier work arounds until you start getting into the intermediate/advanced vi's.


2006 Ultimate LabVIEW G-eek.

Message 5 of 9
(3,628 Views)
I am using Write to Spreadsheet.vi which I don't believe has error handling capabilities. I am not yet familiar with the Open/Create/Replace File. The data that I am trying to save is a 2D array, so I assumed that I should use the Write to Spreadsheet.vi. Any other suggestions? Thanks very much to all of you for the help.


Philip
0 Kudos
Message 6 of 9
(3,628 Views)
It does if you modify it. The function uses Open/Create/Replace file but the incput "Advisory Dialog" is not used. Create a control and save the VI under a different name. You'll also want to delete the General Error Handler function and do your own error trapping.
0 Kudos
Message 7 of 9
(3,628 Views)
"Error trapping?" Will i need to do the trapping inside the new write spreadsheet file vi? thanks
0 Kudos
Message 8 of 9
(3,628 Views)
You could by checking for error 43 and passing any other error as a real error or you could do like the example from attenbach. Its up to you to either modify write to spreadsheet or modify your VI that calls it.
0 Kudos
Message 9 of 9
(3,628 Views)