Back to Adaptive Vision Studio website

You are here: Start » Filter Reference » Conditional Processing » ChooseByRange

ChooseByRange


Returns one of the three input objects depending on whether the associated input value falls below, in or above the specified range.

Name Type Description
inObjectIfLower <T> Object to be chosen when the value is below the range
inObjectIfInRange <T> Object to be chosen when the value is in the range
inObjectIfHigher <T> Object to be chosen when the value is above the range
inValue Real Value which is compared against the range
inMinimum Real* Lower end of the range
inMaximum Real* Upper end of the range
outObject <T> Chosen object

The type of this filter is defined using the type variable T which represents any valid type. Read more.

Applications

E.g. to choose GREEN, YELLOW or RED color for visualization on the basis of three ranges of some value: OK, WARNING, NOK.

Description

The filter accepts three objects of the T type (decided on filter creation), and passes exactly one of them onto outObject output. The object to pass is selected depending on whether the inValue fits the (inMin, inMax) range.

  • If inValue is smaller than inMin, inObjectIfLower is selected.
  • If inValue fits closed range (inMin, inMax), inObjectIfInRange is selected.
  • If inValue is larger than inMax, inObjectIfHigher is selected.

In the special case of inMin being greater than inMax, first matching condition is applied, which means that if inValue is higher than inMax and lower than inMin, inObjectIfLower is selected.

Hints

  • Also consider the ternary operator ?: in Formula Blocks.
  • This filter creates a full copy of one of the input objects. Thus, if you need the highest possible speed, use this filter only with primitive types. An alternative is to use Variant Step macrofilters which are fast and elegant.

Examples

inObjectIfLower = "Mike"
inObjectIfInRange = "Bill"
inObjectIfHigher = "Alice"
inValue = 10.0
inMin = 0.0
inMax = 10.0
outObject = "Bill"
inObjectIfLower = "Mike"
inObjectIfInRange = "Bill"
inObjectIfHigher = "Alice"
inValue = 10.1
inMin = 0.0
inMax = 10.0
outObject = "Alice"

Errors

This filter can throw an exception to report error. Read how to deal with errors in Error Handling.

List of possible exceptions:

Error type Description
DomainError Incorrect (NaN) float value on inValue input in ChooseByRange.

Complexity Level

This filter is available on Basic Complexity Level.

Filter Group

This filter is member of Choose filter group.

See Also

  • ChooseByCase – Returns one of the input objects depending on the specified case index.
  • ChooseByPredicate – Returns one of the two input objects depending on the specified condition.