LabWindows/CVI

Content Type
Programming Language
Current manual
Product DocumentationLabWindows/CVIChecking for Errors in LabWindows/CVICurrent page
Table of Contents

Checking for Errors in LabWindows/CVI

Checking for Errors in LabWindows/CVI

This section describes LabWindows/CVI error checking and how LabWindows/CVI reports errors in LabWindows/CVI libraries and compiled external modules.

When you develop applications in LabWindows/CVI, you usually have debugging and the Run»Break on»Library Errors option enabled. With these features enabled, LabWindows/CVI identifies and reports programming errors in your source code. Therefore, you might have a tendency to relax your own error checking. However, in compiled modules and release executables, debugging and the Run»Break on»Library Errors option are disabled. This results in smaller and faster code, but you must perform your own error checking. This fact is important to remember because many problems can occur in compiled modules and release executables, even if the program works inside the LabWindows/CVI environment.

It is important to check for errors that can occur because of external factors beyond the control of your program. Examples include running out of memory or trying to read from a file that does not exist. malloc, fopen, and LoadPanel are examples of functions that can encounter such errors. You must provide your own error checking for these types of functions. Other functions return errors only if your program is incorrect. The following function call returns an error only if pnl or ctrl is invalid.

SetCtrlAttribute(pnl, ctrl, ATTR_DIMMED, FALSE);

The Run»Break on»Library Errors feature of LabWindows/CVI adequately checks for these types of errors while you develop your program and external factors do not affect this function call. Therefore, it is generally not necessary to perform explicit error checking on this type of function call.

You can check for errors by checking the status of function calls upon their completion. Most functions in commercial libraries return errors when they encounter problems. LabWindows/CVI libraries are no exception. All the functions in the LabWindows/CVI libraries and in the instrument drivers available from National Instruments return a status code to indicate the success or failure of execution. These codes help you determine the problem when the program does not run as you expected. This section describes how LabWindows/CVI reports these status codes and some techniques for checking them.

Note  LabWindows/CVI libraries and National Instruments instrument drivers return status codes that are integer values. These values are either common to an entire library of functions or specific to one function. Each of these libraries contains a function you can call to translate the integer value to an error string. When an error code is specific to a function, you can find a description for it in the Library Reference section of the LabWindows/CVI Help.
Was this information helpful?