Determining Range Values and Coercing Data

Complete the following steps to determine if a value falls within a range specified by the upper limit and lower limit inputs and optionally to coerce the value to fall within the range.

Note  The following steps use numeric values as an example. You can determine if a value in a string or Boolean object falls within a range and optionally coerce the value to fall within the range. Refer to Appendix C, Comparison Functions, in the LabVIEW User Manual for information about using data types in Comparison functions.
  1. Select the In Range and Coerce function located on the Functions»Comparison palette and place it on the block diagram.
  2. Wire a numeric value to the x input of the function.
  3. Wire the maximum value to the upper limit input of the function. If x is greater than this value, the function coerces the number to the upper limit. The default value is positive infinity.
  4. Wire the minimum value to the lower limit input of the function. If x is less than this value, the function coerces the number the number to the lower limit. The default value is negative infinity.
  5. Wire the coerced output of the function to a subVI, function, or indicator that accepts a number. If x is within the range set by the upper limit and lower limit inputs, the value in x is unchanged. If the number is not in range, it is converted to either the upper limit or lower limit.
  6. Wire the In Range output of the In Range and Coerce function to a Boolean indicator to determine if the number is within the range set by the upper limit and lower limit inputs, or wire the In Range output to a subVI or function that accepts a Boolean value as an input. If the number is within the range, In Range passes a TRUE value. If the number is not within the range, In Range passes a FALSE.
  7. Run the VI.