National Instruments 320685D-01 Drums User Manual


 
©
National Instruments Corporation 9-1 LabWindows/CVI Programmer Reference Manual
9
Checking for Errors in
LabWindows/CVI
This chapter 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
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 standalone
executables, debugging and the Break on Library Errors 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 standalone
executables even if the program works inside the 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 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.
One method of error checking is to check 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 it to. This chapter describes how
LabWindows/CVI reports these status codes and some techniques for checking them.
00ProRef.book : 06chap09.fm Page 1 Monday, March 9, 1998 3:23 PM