Do not use variables as arguments of global functions that interact with external files or databases.
Math and comparison functions
| 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. |
Distance abs( Distance ) | Returns the absolute value of a distance. |
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 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 Round( Real ) | Returns an integer closest in value to the argument. |
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. |
Coordinate and interval functions
| Definition | Description |
|---|---|
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. |
Logic IsOnSameLine( Hypothesis, Hypothesis ) | Checks if the hypotheses intersect vertically. |
Region FormRegion( RectArray included, RectArray excluded ) | Creates a region that includes the array of included rectangles and excludes the array of excluded rectangles. |
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 x1, 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. |
String functions
| Definition | Description |
|---|---|
String Chr( Int ) | Returns a string using the specified Unicode code of the character (the code must be written in the decimal system). |
String LCase( String ) | Returns a string obtained from the specified string by changing all of its characters to lower case. |
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. |
Conversion and validation functions
| Definition | Description |
|---|---|
Int LogicToInt( Logic value ) | Returns 1 if the value is true and 0 if the value is false. |
Int StrToInt( String inputString, Logic isStrictMode = false ) | Returns the result of converting the inputString string value to an integer. Spaces are omitted. The isStrictMode parameter (false by default) 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. Check that the string can be converted before invoking this function. To do this, use the IsInt function. |
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 the IsIntFuzzy function). Spaces are ignored during conversion. The isStrictMode parameter (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, call the IsIntFuzzy function to check if the string can be safely converted. |
Logic IsInt( String inputString, Logic isStrictMode = false ) | Checks that the inputString string can be safely converted to an integer. The isStrictMode parameter (false by default) 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 (that is, the characters 0123456789), but also characters that look like digits (for example, oOBsl). The isStrictMode parameter (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 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, the comma, and the user-defined separator (configured in the regional settings of the operating system, see RegionalDecimalPoint) are allowed. The isStrictMode parameter (false by default) 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 the IsIntFuzzy function). The list of allowed decimal separators is specified by the separators argument. By default, the following separators are allowed: the point, the comma, and the separator specified in the regional settings of the user’s operating system (see RegionalDecimalPoint). The isStrictMode parameter (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. |
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. For more information, see 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 maxErrorsPart sets the relative maximum number of errors in the word. The ignoreSpaces argument 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. 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. For more information, see Databases and text files in the FlexiLayout language. The maxErrors argument sets the absolute maximum number of errors in the word, and maxErrorsPart sets the relative maximum number of errors in the word. The ignoreSpaces argument 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). 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 maxErrorsPart sets the relative maximum number of errors in the word. The ignoreSpaces argument 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. 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 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 (false by default) 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. Check that the string can be converted before invoking this function. To do this, use the IsReal function. |
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 the IsIntFuzzy function). Spaces are ignored during conversion. The isStrictMode parameter (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, call the IsRealFuzzy function to check if the string can be safely converted. |
StrToInt:
Int integralValue;
String valueFromDocument = SearchElements.StaticText.Value();
Logic canBeConverted = IsInt(valueFromDocument, true);
if(canBeConverted) then integralValue = StrToInt(valueFromDocument, true);
ValidateByDB:
if not IsNull then ValidateByDB(Value(), "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\\FCS\\Companies.mdb", "SELECT Name FROM Companies", 1, 0.3, true, 500);
ValidateByFile:
if not IsNull then ValidateByTextFile(Value(), "Companies.txt", 1, 0.3, true, 500);
ValidateByText:
if not IsNull then ValidateByText (Value(), "ABBYY|Flexi Capture", 1, 0.3, true);
StrToReal:
Real realValue;
String valueFromDocument = SearchElements.StaticText.Value();
Logic canBeConverted = IsReal(valueFromDocument, ".");
if(canBeConverted) then realValue = StrToReal(valueFromDocument, ".");
Database and file functions
| Definition | Description |
|---|---|
Int RecordCount( String connectionString, String selectString ) | Returns the number of records returned by the request. See the example for the Record function in this section. |
Logic ExecuteSQL( String connectionString, String queryString ) | Runs the user’s SQL query queryString. The connectionString argument sets the database connection string. |
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. |
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. |
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. |
Void PrepareRecordset( String connectionString, String selectString, Int maxRecordsCount = 1000 ) | Prepares the request for quick access. See the example for the Record function in this section. |
ExecuteSQL:
ExecuteSQL("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\\FCS\\Companies.mdb", "UPDATE Companies SET total=0");
WriteToFile:
WriteToFile("D:\\FCS\\logFile.txt", SearchElements.Tag.Value());
Record:
String connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\1.mdb;";
String selectString = "SELECT SearchText, LeftPos, TopPos, RightPos, BottomPos from SearchPositions WHERE ElementName = 'DocID'";
PrepareRecordset(connectionString, selectString);
Int recordCount = RecordCount(connectionString, selectString);
String searchString;
RectArray searchArea = RectArray();
for recordIndex from 0 to recordCount - 1 {
StringArray recordArray = Record(connectionString, selectString, recordIndex);
if recordIndex == 0 then {
searchString = recordArray.GetAt(0);
} else {
searchString = searchString + "|" + recordArray.GetAt(0);
}
searchArea.Add(Rect(StrToInt(recordArray.GetAt(1)) * dt, StrToInt(recordArray.GetAt(2)) * dt,StrToInt(recordArray.GetAt(3)) * dt, StrToInt(recordArray.GetAt(4)) * dt));
}
SearchText: searchString;
RSA: searchArea;
| operator. The LeftPos, TopPos, RightPos, and BottomPos coordinates from the table fields are used to generate coordinates in dots for the rectangles. Generated coordinates are added to the search area of the DocID element.
Page and document functions
| Definition | Description |
|---|---|
Distance AverageLineHeight() | The average height of the text lines on the page. The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, that is, 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 Page type: Page( N ).AverageLineHeight. |
Distance AverageInterLineInterval() | The average distance between the text lines on the page. The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, that is, 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 Page type: Page( N ).AverageInterLineInterval. |
Int PagesCount() | Returns the number of pages in the document. |
Page Page( Int PageNumber ) | Returns the type that describes the given page. |
Rect DocumentRect() | Returns the rectangle of the entire document (in global coordinates). |
Rect PageRect() | The rectangle of the entire image. The function may only be used if the maximum and minimum numbers of pages in the document are set to 1, that is, 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, this function may only be used in the Pre-search relations section. For more information, see Functions which limit the search area. |
Void SetPagesCount( Int pagesCount ) | Sets the number of pages in the document. It is used in the 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). |
SetPagesCount:
If the given element was matched, the document ends on the next page:
if IsFound then SetPagesCount(PagesCount + 1);
if PageNum.IsFound and IsInt(PageNum.Value) then SetPagesCount: StrToInt(PageNum.Value);
Pre-recognition functions
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).| Definition | Description |
|---|---|
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 argument 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 argument 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 argument are included in the recognition. |
Void RecognizeText( Rect rect, SearchAreaPageSetType pageSetType ) | Recognizes text in the rect rectangle. Only the pages specified by the pageSetType argument are included in the recognition. |
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 argument 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 argument 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 argument are included in the recognition. |
Void RecognizeText( Region region, SearchAreaPageSetType pageSetType ) | Recognizes text in the region region. Only the pages specified by the pageSetType argument are included in the recognition. |
RectArray RecognizedRects() | A debugging function that allows printing an array of pre-recognized rectangles. |
