Skip to main content
Advanced pre-search relations set search constraints and element properties in a special FlexiLayout language. The pane where you can enter your code can be found 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 will use the properties you specified on the tabs to the left of the Advanced tab, and then it will run 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 will have 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 will be used.
The SearchText function (Static Text element) is an exception. This function willaddsearch 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. The generated code can then be copied or edited.
The additional constraints entered in the Advanced pre-search relations pane may only refer to elements located above the current element in the FlexiLayout tree. The only exception are the subelements of the same Repeating Group element, which may refer to previous instances of subelements located in the same group below the given element.

Examples

Sometimes you will need to assign different values to one and the same parameter. This can be done by using the “if… then” operator:if Element1.IsNull then {
MaxErrors: 3, 0.25;
} else {
MaxErrors: 5, 0.5;
}
The search area may be specified by using any of the types which define an image area: Rect, RectArray, Region. It can also be specified by using an expression which returns any of these types. The result of calculating the expression is passed as an argument to the RestrictSearchArea() function:a.RestrictSearchArea( Rect(Rect( Page( 1 ).RectGlobal.Left, Page( 1 ).RectGlobal.Top+20*mm, Element1.Left.Start, Element2.Ycenter.Start ) );b.let rect1 = Element1.Rect;
let rect2 = Element2.Rect;
RestrictSearchArea( rect1 or rect2 );
For some documents, the presence of one object on the image automatically excludes another object. In still other cases, you may wish 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 will formulate a null hypotheses for the corresponding object:if Element1.IsNull() then DontFind()
Sometimes several image objects meet the conditions specified in an element. This means that the program will formulate 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 the Nearest, NearestX, and NearestY functions:
  • Nearest( [name of element] ) - sets the name of the closest element.
  • Nearest( x1, y1 ) - sets the coordinates of the closest point.
  • NearestX( x1 ) - sets the X coordinate of the closes vertical line.
  • NearestY( y1 ) - sets the Y coordinate of the closest horizontal line.
Note. You cannot use several Nearest functions at a time.
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.For example:a. To specify that an element may be found in the bottom half of any page:Below: PageRect.Top + PageRect.Height / 2;(see the description of the PageRect function for details)b. 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):RestrictSearchArea( Page( PagesCount ).RectGlobal );c. To specify that an element is located on the page where an element named SearchElements.OtherElement begins:if SearchElements.OtherElement.IsFound then RestrictSearchArea( WholePage, SearchElements.OtherElement.Pages.Start );d. To specify that an element may be located on each page below the instances of the hypotheses for a repeating group named SearchElements.RepeatableGroup:Below: SearchElements.RepeatableGroup.AllInstances.PageAreaGlobal( PageNumber ).Region.Bottom;e. To specify that an element may be located on each page below the body of each subtable of a table named SearchElements.Table:Below: SearchElements.Table.AllSubTables.Body.PageAreaGlobal( PageNumber ).Bottom;

See also:

FlexiLayout language