English (English)

Global functions

Important!Do not use variables as arguments of global functions that interact with external files or databases.

Definition Description
Area Max( Area a1, Area a2 ) Returns the maximum value from a1, a2.
Area Min( Area a1, Area a2 ) Returns the minimum value from a1, a2.
Area ObjectsArea( Rect, ImageObjectType ) The area of the objects of the specified type within the specified rectangle. Works in global coordinates.
Area ObjectsIntersectionArea( Rect, ImageObjectType ) The area of the objects of the specified type within the specified rectangle and the intersection area of objects of the specified type going beyond the specified rectangle. Works in global coordinates.
Distance abs( Distance ) Returns the absolute value of a distance.
Distance AverageLineHeight()

The average height of the text lines on the page.

Important!The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, i.e. the detected document has only one page. If you use this function for a multi-page document, matching a FlexiLayout will return an error. For a multi-page document, use the corresponding method of the type Page: Page( N ). AverageLineHeight.

Distance AverageInterLineInterval()

The average distance between the text lines on the page.

Important!The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, i.e. the detected document has only one page. If you use this function for a multi-page document, matching a FlexiLayout will return an error. For a multi-page document, use the corresponding method of the type Page: Page( N ). AverageInterLineInterval.

Distance Min( Distance d1, Distance d2 ) Returns the minimum value from d1, d2.
Distance Max( Distance d1, Distance d2 ) Returns the maximum value from d1, d2.
Int abs( Int ) Returns the absolute value of a number.
Int Ceil( Real ) Returns the smallest integer that is not less than the argument.
Int Floor( Real ) Returns the largest integer that is not greater than the argument.
Int LogicToInt( Logic value ) Returns "1" if the value is true and "0" if the value is false.
Int Max( Int n1, Int n2 ) Returns the maximum value from n1, n2.
Int Min( Int n1, Int n2 ) Returns the minimum value from n1, n2.
Int PagesCount() Returns the number of pages in the document.
Int RecordCount( String connectionString, String selectString ) Returns the number of records of the request. E.g. See the example for the Record function below.
Int Round( Real ) Returns an integer closest in value to the argument.
Int StrToInt( String inputString, Logic isStrictMode = false )

Returns the result of converting the inputString string value to an integer number. Spaces are omitted. The isStrictMode parameter (by default = false) defines whether the string can include characters other than digits and spaces. If isStrictMode = false, and the string contains a character which is not a digit or space, all subsequent characters are omitted. It is recommended to check the possibility of conversion before invoking it. To do it, use the IsInt function.

E.g.

Int StrToIntFuzzy( String, Logic isStrictMode = false ) Returns the result of converting the value of the string inputString into an integer taking into account possible recognition errors in the string (see the description of IsIntFuzzy function for details). Spaces are ignored during conversion. The isStrictMode parameters (which is set to false by default) determines if the string may contain characters other than digits, characters that look like digits, or spaces. If isStrictMode = false and a character other than a digit is encountered, all the characters after it will be ignored. Before starting the conversion, we recommend calling the IsIntFuzzy function to check if the string can be safely converted.
Logic ExecuteSQL( String connectionString, String queryString )

Carries out the user’s SQL query: queryString. The connectionString argument sets the database connection string.

E.g.

Logic IsInt( String inputString, Logic isStrictMode = false ) Checks that the inputString string can be securely converted to an integer number. The isStrictMode parameter (by default = false) defines whether the string can include characters other than digits and spaces.
Logic IsIntFuzzy( String inputString, Logic isStrictMode = false ) Checks if the string inputString can be safely converted into an integer taking into account possible recognition errors in the string. This type of conversion converts to integers not only digits (i.e. characters "0123456789"), but also characters that look like digits (e.g. “oOBsl”). The isStrictMode parameters (which is set to false by default) determines if the string may contain characters other than digits, characters that look like digits, or spaces.
Logic IsOnSameLine( Hypothesis, Hypothesis ) Checks if the hypotheses intersect vertically.
Logic IsReal( String numberString, String separators = “.,”, Logic isStrictMode = false ) Checks that the inputString string can be converted to a real number. The list of allowed decimal separators is set by the “separators” argument. By default, the point, comma and user-defined separator (configured in the regional settings of the OS, see RegionalDecimalPoint). The isStrictMode parameter (by default = false) defines whether the string can include characters other than digits, spaces and separators.
Logic IsRealFuzzy( String, String separators = defaultDecimalSeparators, Logic isStrictMode = false ) Checks if the string inputString can be safely converted into a real number taking into account possible recognition errors in the string. (see the description of IsIntFuzzy function for details). The list of allowed decimal separators is specified by the “separators” argument. By default, the following separators are allowed: point, comma, and the separator specified in the regional settings of the user’s operating system (see RegionalDecimalPoint). The isStrictMode parameters (which is set to false by default) determines if the string may contain characters other than digits, characters that look like digits, spaces, or separators.
Logic TestDBConnection( String connectionString ) Tests the database connection. The connectionString argument contains the connection string.
Logic TestDBSelect( String connectionString, String selectString ) Checks if the database is accessible and if the SQL query is correct (if the specified table and field exist). The connectionString argument contains the connection string. The selectString argument contains the SQL query, which starts with the SELECT command.
Logic TestFileAccess( String fileName ) Checks if the text file is accessible.
Logic WriteToFile( String filename, String text )

Adds the “text” string to the “filename” file. If there is no file with this name, a new file will be created.

E.g.

Page Page( Int PageNumber ) Returns the type that described the given page.
Quality ValidateByDB( String word, String connectionString, String selectString, Int maxErrors, Real maxErrorsPart, Logic ignoreSpaces, Int maxRecordsCount = 1000 )

Checks the specified word by comparing it against a database (see Using databases and text files in the FlexiLayout language). The connectionString argument sets the string for connecting to the database. The selectString argument sets an SQL query, which starts with the SELECT command. The maxErrors argument sets the absolute maximum number of errors in the word, and the maxErrorsPart sets the relative maximum number of errors in the word. The ignoreSpaces determines whether spaces should be taken into account when comparing. To speed up the search, only the first maxRecordsCount variants are used (the default setting is 1000). Returns the quality of matching between the specified word and the best match from the database.

E.g.

Note.This function may be used in the Advanced Post-Search Relations field for fuzzy matching of the string value of a hypothesis returned by the Value method with specified variants.

Quality ValidateByFile( String word, String fileName, Int maxErrors, Real maxErrorsPart, Logic ignoreSpaces, Int maxRecordsCount = 1000 )

Checks the specified word by comparing it with the variants in the fileName file, which lists possible phrase variants (see Using databases and text files in the FlexiLayout language). The maxErrors argument sets the absolute maximum number of errors in the word, and the maxErrorsPart sets the relative maximum number of errors in the word. The ignoreSpaces determines whether spaces should be taken into account when comparing. Returns the quality of matching between the specified word and the best match from the text file. To speed up the search, only the first maxRecordsCount variants are used (the default setting is 1000).

E.g.

Note.This function may be used in the Advanced Post-Search Relations field for fuzzy matching of the string value of a hypothesis returned by the Value method with specified variants.

Quality ValidateByText( String word, String variants, Int maxErrors, Real maxErrorsPart, Logic ignoreSpaces )

Checks the specified word by comparing it with the listed variants. The maxErrors argument sets the absolute maximum number of errors in the word, and the maxErrorsPart sets the relative maximum number of errors in the word. The ignoreSpaces determines whether spaces should be taken into account when comparing. Returns the quality of matching between the specified word and the best match from the variants listed in the variants argument.

E.g.

Note.This function may be used in the Advanced Post-Search Relations field for fuzzy matching of the string value of a hypothesis returned by the Value method with specified variants.

Real Min( Real d1, Real d2 ) Returns the minimum value from d1, d2.
Real Max( Real d1, Real d2 ) Returns the maximum value from d1, d2.
Real StrToReal( String numberString, String separators = “.,”, Logic isStrictMode = false )

Returns the result of converting the inputString string to a real number. Spaces are omitted. The isStrictMode parameter (by default = false) defines whether the string can include characters other than digits, spaces and separators. If isStrictMode = false, and the string contains a second decimal separator or a character which is not a digit or space, all subsequent characters are omitted. It is recommended to check the possibility of conversion before invoking it. To do it, use the IsReal function.

E.g.

Real StrToRealFuzzy( String, String separators = defaultDecimalSeparators, Logic isStrictMode = false ) Returns the result of converting the value of the string inputString into a real number taking into account possible recognition errors in the string (see the description of IsIntFuzzy function for details). Spaces are ignored during conversion. The isStrictMode parameters (which is set to false by default) determines if the string may contain characters other than digits, characters that look like digits, spaces, or separators. If isStrictMode = false and a second decimal separator or a character other than a digit is encountered, в all the characters after it will be ignored. Before starting the conversion, we recommend calling the IsRealFuzzy function to check if the string can be safely converted.
Rect DocumentRect() Returns the rectangle of the entire document (in global coordinates).
Rect PageRect()

The rectangle of the entire image.

Important!The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, i.e. the detected documents has only one page. If you use this function for a multi-page document, matching a FlexiLayout will return an error For a multi-page document, this function may only be used in the Pre-search relations section. See Functions which limit the search area.

Region FormRegion( RectArray included, RectArray excluded ) Creates a region that includes the array of included rectangles, and excludes the array of excluded rectangles.
StringArray ReadFromXML( String filename, String xPathQuery ) Reads the array of strings from the “filename” XML file. The strings are obtained by calculating the passed xPath query “xPathQuery.”
StringArray Record( String connectionString, String selectString, Int index )

Retrieves data on a specific record. For a cell with the NULL value, an empty string is returned.

E.g.

String Chr( Int ) Returns a string using the specified Unicode code of the character (code must be written in decimal system).
String LCase( String ) Returns a string obtained from the specified string by changing all of its characters to lower case.
String ReadSingleStringFromXML( String filename, String xPathQuery ) Reads the string from the “filename” XML file. The string is obtained by calculating the passed xPath query “xPathQuery.”
String RealToStrVariants( Real value, String fractionalPartSeparators, Int maxDigitsCountInFractionalPart = 2 ) Creates string representations, separated by a vertical bar (“|”), for the specified real number “value,” decimal separators fractionalPartSeparators, and the maximum number of digits in the fractional part. For example, for the arguments 19, ".,", 2 the result is "19|19.0|19.00|19,0|19,00".

String Str( Int );

String Str( Logic );

String Str( Real );

String Str( XInterval );

String Str( YInterval );

String Str( DistInterval );

String Str( FuzzyRect );

String Str( Hypothesis );

String Str( RectArray );

String Str( Region );

String Str( Area );

String Str( Quality );

String Str( Distance );

String Str( PageInterval ).

String representation of a data type.
String RemoveSpaces( String ) Returns a string obtained from the specified string by removing all of the spaces in the string.
String UCase( String ) Returns a string obtained from the specified string by changing all of its characters to upper case.
Void PrepareRecordset( String connectionString, String selectString, Int maxRecordsCount = 1000 ) Prepares the request for quick access. E.g. See the example for the Record function below.
Void SetPagesCount( Int pagesCount )

Sets the number of pages in the document. It is used in “Pre-search” or “Post-search advanced code” sections. This function must be invoked from the Header or Footer elements or their sub-elements. The function applies to documents that do not have the end-of-document indicator (the footer is either missing or optional).

E.g.

XCoordinate Min( XCoordinate x1, XCoordinate x2 ) Returns the minimum value from x1, x2.
XCoordinate Max( XCoordinate x1, XCoordinate x2 ) Returns the maximum value from x1, x2.
XCoordinate MiddleBetween( XCoordinate x1, XCoordinate x2 ) Returns the X-coordinate calculated as ( x1+ x2 ) / 2.
XCoordinate Between( XCoordinate x1, XCoordinate x2, Real ratio ) Returns the X-coordinate calculated as x1+ ( x2 – x1 ) * ratio.
YCoordinate Min( YCoordinate y1, YCoordinate y2 ) Returns the minimum value from y1, y2.
YCoordinate Max( YCoordinate y1, YCoordinate y2 ) Returns the maximum value from y1, y2.
YCoordinate MiddleBetween( YCoordinate y1, YCoordinate y2 ) Returns YInterval calculated as ( y1+ y2 ) / 2.
YCoordinate Between( YCoordinate y1, YCoordinate y2, Real ratio ) Returns YInterval calculated as y1+ ( y2 – y1 ) * ratio.
XInterval MiddleBetween( Xinterval x1, XInterval x2 ) Returns XInterval calculated as ( x1+ x2 ) / 2.
XInterval Between( Xinterval x2, Xinterval x2, Real ratio ) Returns XInterval calculated as x1+ ( x2 – x1 ) * ratio.
YInterval MiddleBetween( Yinterval y1, Yinterval y2 ) Returns YInterval calculated as ( y1+ y2 ) / 2.
YInterval Between( Yinterval y1, Yinterval y2, Real ratio ) Returns YInterval calculated as y1+ ( y2 – y1 ) * ratio.
The following functions invoke pre-recognition during FlexiLayout matching. The text lines intersecting with a given pre-recognition area are recognized as a whole (including the line parts that fall out of the area boundaries).
Void RecognizeText() Recognizes text in the relative rectangle specified in the “Pre-recognition area” property in the project settings. All document pages are included in the recognition.
Void RecognizeText( IntArray pages ) Recognizes text in the relative rectangle specified in the “Pre-recognition area” property in the project settings. Only the pages specified by the “pages” part of the string are included in the recognition.
Void RecognizeText( SearchAreaPageSetType pageSetType ) Recognizes text in the relative rectangle specified in the “Pre-recognition area” property in the project settings. Only the pages specified by the “pageSetType” part of the string are included in the recognition.
Void RecognizeText( Rect rect ) Recognizes text in the “rect” rectangle.
Void RecognizeText( Rect rect, IntArray pages ) Recognizes text in the “rect” rectangle. Only the pages specified by the “pages” part of the string are included in the recognition.
Void RecognizeText( Rect rect, SearchAreaPageSetType pageSetType ) Recognizes text in the “rect” rectangle. Only the pages specified by the “pageSetType” part of the document.
Void RecognizeText( RectArray rectArray ) Recognizes text in the “rectArray” array of rectangles.
Void RecognizeText( RectArray rectArray, IntArray pages ) Recognizes text in the “rectArray” array of rectangles. Only the pages specified by the “pages” part of the string are included in the recognition.
Void RecognizeText( RectArray rectArray, SearchAreaPageSetType pageSetType ) Recognizes text in the “rectArray” array of rectangles. Only the pages specified by the “pageSetType” part of the string are included in the recognition.
Void RecognizeText( Region region ) Recognizes text in the “region” region.
Void RecognizeText( Region region, IntArray pages ) Recognizes text in the “region” region. Only the pages specified by the “pages” part of the string are included in the recognition.
Void RecognizeText( Region region, SearchAreaPageSetType pageSetType ) Recognizes text in the “region” region. Only the pages specified by the “pageSetType” part of the string are included in the recognition.
RectArray RecognizedRects() A debugging function allowing printing of an array of pre-recognized rectangles.

4/12/2024 6:16:02 PM

Please leave your feedback about this article

Usage of Cookies. In order to optimize the website functionality and improve your online experience ABBYY uses cookies. You agree to the usage of cookies when you continue using this site. Further details can be found in our Privacy Notice.