Back to Aurora Vision Studio website

You are here: Start » Filter Reference » Data Flow » Conditional Processing » MergeDefault


Module: FoundationLite

Copies an object from a conditional input to an non-conditional output, replacing Nil with a predefined default value.


Usually used to create a definite result for the special cases represented by the Nil value.
Name Type Description
Input value inConditionalObject <T>? Input conditional object
Input value inDefaultObject <T> Object to be used if the conditional object is empty
Output value outObject <T> Value of the conditional object, if it exists, or the default otherwise

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


This filter is a tool of the Conditional Execution mechanism. It receives a conditional value and:

  • if it is Nil, replaces it with a specified default value;
  • otherwise, copies the input value to the output.


  • Connect a conditional value to the inConditionalObject input.
  • On the inDefaultObject input define a value that will be substituted for Nil on the inConditionalObject input.
  • Also consider the coalescing operator (??) in Formula Blocks.
  • Also consider using a Variant Step macrofilter with two variants: "Nil" and "default". This may be more elegant and also faster.


Description of usage of this filter can be found in examples and tutorial: Hand-Eye Calibration - On Filters, OCR text validation.

Here is a simple demonstration how this filter works, replacing Nil with 0:

inConditionalObject = 5
inDefaultObject = 0
outObject = 5
inConditionalObject = Nil
inDefaultObject = 0
outObject = 0

MergeDefault filter can be used to replace a numeric display in HMI with a label indicating a reading error, such as "(unknown)" or "N/A". Here, we are reading some value from an XML node. If it cannot be parsed (e.g. because there is incorrect syntax), then a special text will be displayed instead.


This filter is a counterpart of the IFERROR function from Microsoft Excel.

This filter can be replaced with the following formula:

Complexity Level

This filter is available on Basic Complexity Level.

See Also

  • MakeConditional – Checks a condition and: if the condition is True, then it copies the input object to the output; otherwise returns Nil.
  • MergeBranches – Chooses the first non-Nil object, or reports an error if there is no such object.
  • MergeIntoArray – Creates an array from all the non-Nil input elements.