Back to Adaptive Vision Studio website

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

ChooseByPredicate


Returns one of the two input objects depending on the specified condition.

Name Type Description
inObjectIfTrue <T> Object to be chosen if the condition is met
inObjectIfFalse <T> Object to be chosen if the condition is NOT met
inCondition Bool Determines which object is to be chosen
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 color to visualize correct objects or RED to visualize defective ones.

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

Description of usage of this filter can be found in examples and tutorial: Cap (Easy), HMI Configuration Page, HMI Recorder, IO Serial Port Communicator, Waffles, Brick destroy (Game), Using HMI multipanel control.
inObjectIfTrue = "Mike"
inObjectIfFalse = "Bill"
inCondition = False
outObject = "Bill"

Remarks

This filter can be replaced with the following formula:

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.
  • ChooseByRange – Returns one of the three input objects depending on whether the associated input value falls below, in or above the specified range.