From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Clear Specific Error in LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Download All

Overview

Occasionally, it can be desirable to clear a specific error when we run our VI. The code below will clear a specific error using Clear Specific Error.vi, and is adaptable to be used as a subVI within a larger application.

 

Description

First we use the Error Cluster from Error Code.vi to create two different error clusters, -20 and -20315. (The errors chosen are arbitrary and do not match any of those in the General LabVIEW Error Code list.) Depending on which position the rocker switch is in, the case structure passes one of these errors through for us to check whether the error code matches the error we are looking to clear, whose value is selected on the front panel. We also check that the status of the error is true, in case there is no error or a warning. If the error satisfies both of these conditions, the error is cleared using Clear Errors.vi within a case structure.

 

If however the error is not cleared, it is then shown on the Error out Indicator and a description of the error is displayed in a dialog box by Simple Error Handler.

 

Software requirements

LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute code

1. Using the rocker switch, select which error you want to simulate.
2. Run the VI.
3. If the error you are simulating matches 'Error to clear', notice that no error is reported and that 'error out' reports no error.
4. If the error you are simulating does not match 'Error to clear', notice that the Simple Error Handler displays a dialog box and that the 'Error out' indicator shows an error.
5. You can adjust 'error to clear' by changing the value on the Front Panel.

 

Additional information or References

If you were using this as a subVI within your code, you would replace Sections 1 and 2 with an error control and wire the connector pane terminals to allow you to pass your errors in. It would also be best practice to remove the Simple Error Handler in this case and instead to use it in your Main VI.

 

Front Panel of the VI

Front Panel.PNG

 

 Block Diagram of the VI

Clear Specific Error 2012 NIVerified Block Diagram.png

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

 

Andrew McLennan
Applications Engineer
National Instruments

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Rod42
Active Participant
Active Participant
on

No need to test for 'status' equals True. Just use 'status'

PalanivelThiruvenkadam
Active Participant Active Participant
Active Participant
on

Hope clear error itself contains a input node (specific error code to clear (0: all) Seems like invalid statement , Correct me if i am wrong

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------