Skip to main content
Advanced pre-search relations set search constraints and element properties in the FlexiLayout language. The pane where you enter your code is on the Advanced tab of the Properties dialog box. The code you enter into the Advanced pre-search relations pane is executed immediately before searching for the image object that corresponds to the FlexiLayout element. First, the program uses the properties you specified on the tabs to the left of the Advanced tab, and then it runs the code. If a particular parameter is specified both on a tab to the left of the Advanced tab and in the code on the Advanced tab, the code has priority. If a parameter is specified on a tab to the left of the Advanced tab but is not specified in the code, the value of the parameter from the relevant tab is used.
The SearchText function (Static Text element) is an exception. This function adds search words to those already specified on the Static Text tab.
If you have specified some properties on any of the tabs to the left of the Advanced tab, you can translate them into code by clicking the Code button on the Advanced tab. You can then copy or edit the generated code.
The additional constraints entered in the Advanced pre-search relations pane can only refer to elements located above the current element in the FlexiLayout tree. The only exceptions are the subelements of the same Repeating Group element, which can refer to previous instances of subelements located in the same group below the given element.

Examples

Specify different values for the same parameter

Sometimes you need to assign different values to the same parameter. To do this, use the if... then operator:

Limit the search area

The search area can be specified by using any of the types that define an image area: Rect, RectArray, Region. It can also be specified by using an expression that returns any of these types. The result of calculating the expression is passed as an argument to the RestrictSearchArea() function:
You can also pass an expression that combines the regions of several elements:

Cancel the search for an object

For some documents, the presence of one object on the image automatically excludes another object. In other cases, you might want to look for a particular object only if certain conditions have been met. You can tell the program not to look for a specific object by using the DontFind() command. Once the command is executed, the program formulates a null hypothesis for the corresponding object:

Select a hypothesis

Sometimes several image objects meet the conditions specified in an element. This means that the program formulates several hypotheses. If you need to select from this set only the hypothesis that is located closest to some other object or point on the image, you can use one of the following functions:
You cannot use several Nearest functions at once.

Search on multi-page documents

The program treats a multi-page document as a single entity and can look for an element of a multi-page document without reference to an exact page. To specify that an element can be found in the bottom half of any page:
For more information, see the description of the PageRect function. To specify that an element is located on the last page of a document (you can write this code only in the principal part of the FlexiLayout, after the Header and Footer elements, if any):
To specify that an element is located on the page where an element named SearchElements.OtherElement begins:
To specify that an element can be located on each page below the instances of the hypotheses for a repeating group named SearchElements.RepeatableGroup:
To specify that an element can be located on each page below the body of each subtable of a table named SearchElements.Table: