CheckNumericRange

IVI Library

Ivi_CheckNumericRange

Usage

ViStatus Ivi_CheckNumericRange(ViReal64 value, ViReal64 minimum, ViReal64 maximum, ViStatus errorCode);

Purpose

This function verifies that a ViInt32 or ViReal64 value falls within the a range you specify.

If it the value does not fall with the range, the function returns the error code you specify. The range is inclusive. In other words, the function returns the error code if the value is less than the minimum value or greater than the maximum value. When you use this function on a parameter to a user-callable function in your instrument driver, use the viCheckParm macro around this function.

The following example shows how to use the viCheckParm macro around this function:

viCheckParm( Ivi_CheckNumericRange(parmVal,min,max,errorCode) , parmPosition, parmName);

In this example, parmPosition is the 1-based position of the parameter in the parameter list of the user-callable function, and parmName is a string that contains the name of the parameter. Ivi_CheckNumericRange stores the errorCode you pass to it as the primary error code. viCheckParm converts the parmPosition to one of the VXIplug&play error codes for invalid parameters and stores it as the secondary error code.

It stores the parmName as the error elaboration string.

Parameters

Name Type Description
value ViReal64

Specify the value you want to check.

minimum ViReal64

Specify the minimum value of the range.

maximum ViReal64

Specify the maximum value of the range.

errorCode ViStatus

Specify the error code the function returns if the value you specify does not fall within the range you specify.

Return Value

Contains the status code that the function call returns. IVI engine functions can return error and warning values from several sets of status codes. Some status codes are unique to the IVI engine. Other status codes are the same codes that VISA Library functions return. Still others are error or warning values that functions in specific instrument drivers return. Each set of status codes has its own numeric range.

Regardless of the source of the status code, 0 always indicates success, a positive value indicates a warning, and a negative value indicates an error.

Related Topic

IVI Status Codes