11-16-2015 03:55 AM
Is there a way to stop a vi, if for some reason you forgot to clear an error and now bomb the user with the same error message each run of a loop?
I try alternately pressing escape and mouse clicking onto the stop button in the tool bar. However, the message appears again before the stop button is activated.
The task manager kills the vi, however couldn't be there a more simple way?
Solved! Go to Solution.
11-16-2015 04:04 AM - edited 11-16-2015 04:12 AM
You try to go in the wrong direction. Do not eliminate the error msg itself, but handle the error. If you put clear error in your code without beeing careful you just mask out the problems in your VI.
Do not create a loop which does not stop if an error happens. At least you should stop the running loop, and report about the error. If the error due to wrong programming, you fix this based on the error info. If for example this error is hardware specific (the user accidently pulls out a USB cable, etc...), you can handle it nicely in a State Machine: you move to an error state, reporting to the user there is some problem. After this you can give the option to the user to abort the whole application, or try to re-initialize the hardware. this is of course just one possible example...
Edit1: but if you show your actual problem, and post your VI which has this problem, we can give you more specific help...
Edit2: So just to clarify: what you explain in your post, is only due to a bad programming design. Instead of trying to treat the symptomes, why not heal the patient??
11-16-2015 04:30 AM
You are right in the end, besides that i don't agree that the application should terminate completely on error.
It should of course report the error and keep running to let the user (or the programmer) be able to fix runtime errors (f.e. due to
wrongly configured input elements) and try again. Thats why i like to clear the error after it has been reported and then keep running.
Anopther case where this occurs is, when an error is produced again and again each run of the loop.
During programming, i believe, every programmer will be confronted with such situations at least sometimes.
This is due to being confronted with some intermediate state of the program code which is about to become error tolerant but is not
at the moment.
There should be a more simple way than using the task manager to break a vi while it displays an error message.
11-16-2015 04:38 AM
Have a look at the attached document - it covers everything that you might want to do with errors.
11-16-2015 04:39 AM
"You are right in the end, besides that i don't agree that the application should terminate completely on error."
I did not say this only, did you read my entire post?
You write about two cases: when the programer develops, and when the end user runs the application. I explained what I do in the second case: I have error states, and I report, and if possible, give the option to the user to re-initialize.
In the first case, when I program, I just do not create loops which can become infinite, if error happens the loop should stop, and the programmer can fix it. You can also use other debugging techniques to find the solution easier. But using the red Abort button? It is very rare I need to use it...
11-16-2015 04:50 AM
Although it is good to avoid making situations with infinite loops and errors showing, it sometimes happens by oversight or unexpected behaviour.
If you do end up in a loop a trick that works half of the time is to hold "ctrl + ." while you are pressing ok to confirm the dialogue message generated by an error or something similar. This key combination is the shortcut for abort but being held on a keyboard oftern injects the command inbetween the offending loops iterations.
Kind Regards,
Larry
11-16-2015 05:28 AM
@ Larry C.:
Thank you. This was the answer to my original intention of the question.
Although i try to handle errors i maybe should be a little bit more careful during programming.
I got more sensitive to the prevention of unlimited errors, now.
11-16-2015 06:14 AM
@Larry.C wrote:
[...]
If you do end up in a loop a trick that works half of the time is to hold "ctrl + ." [...]
Another trick that works half the time is to use this - https://lavag.org/topic/11674-cr-abort-vi/. It will allow you to stop modal messages.
11-16-2015 07:50 AM
Thats cool. We're now get into LabView hacking, aren't we? Just kidding.
😉
11-16-2015 09:55 AM - edited 11-16-2015 09:55 AM
@Labuser16383 wrote:
Thats cool. We're now get into LabView hacking, aren't we?
Oh we can keep this going if you really want. I've made a tool years ago that encorporate the abort VI posted earlier (or a variation of it) to abort all VIs in all running versions of LabVIEW (2011 and newer) along with other task kill, launch, restart, and file extention taking over functions and put them into the system tray. Earlier versions had issues with projects but I'm pretty happy with the latest version
https://lavag.org/topic/11333-labview-tray-launcher/
http://www.brian-hoover.com/Navigation/Code%20Repository/LabVIEW/LabVIEW%20Tray%20Launcher.php
But yeah you get the point, handle errors to avoid this.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord