6.5

© 2007 ABBYY. All rights reserved.
50
1. Suppose we have the following expression: #A!Summa#>5
If there are no pages corresponding to the «À» template in the document, the result will be an empty collection.
If there is only one page corresponding to the «À» template, the value will be True if the value of the «Summa» field of the
page is more than 5, and False otherwise.
If there is more than one page corresponding to the «À» template, the second operand (5) will be supplied with the
additional constants of 5 until the necessary dimension is reached. The value of the expression will be a collection with
the dimension equal to the number of pages corresponding to the «À» template, and each element of the collection will
be True if the value of the «Summa» field of the respective page is more than 5, and False otherwise.
2. Suppose we have the following expression: #A!Number# >{3,5}
If the document has no pages corresponding to the «À» template, the result will be an empty collection.
If the document has only one page corresponding to the «À» template, the value of the first operand will be
complemented to the dimension of the second operand (i.e. to 2). The value of the expression will be a collection with
2 elements. The first one will be True if the value of the «Number» field of the page is more than 3, and False otherwise.
The second will be True if the value of the «Number» field of the page is more than 5, and False otherwise.
If the document has two pages corresponding to the «À» template, the value of the expression will be a collection with
2 elements. The first one will be True if the value of the «Number» field of the first page is more than 3, and False
otherwise. The second element will be True, if the value of the «Number» field of the second page is more than 5, and
False otherwise.
If the document includes more than two pages corresponding to the «À» template, the result will be an expression
containing a single Error constant – the dimensions of operands cannot be matched. To avoid the dimension matching
error, you may use the cut operator (SubArray): SubArray(#A!Number#,1,2)>{3,5} – the pages will be taken two by two
starting from the first page, and then the program will check if the value of the «Number» field on the first page is more
than three, and on the second page is more than five.
Type conversion
Many operations require that the operands be of a certain type. Type conversion is performed to ensure that the operands meet this
requirement. An operand may be converted to one of the four types: long, real, string, and Boolean. If a value is converted to a certain
type, it means that every element of the value will be converted to the type:
If there are elements that cannot be converted to the required type, they are converted to the Error type (type
conversion error).
If you try to convert an element into the long, real or Boolean types, and the source element is an empty string, no error
will occur, and the element will be converted to 0 and False, respectively.
Example. Suppose we have the expression: #A!Summa#*10.
Let us consider a document that has 5 pages corresponding to the «А» template, and the values of the «Summa» fields on them are
equal to 1, 23, 4^^, , and 4, respectively (the «Summa» field of the third page contains uncertain characters, while the same field of the
fourth page is empty). Then the value of the expression will be a collection of five elements the values of which will be as follows: 10,
230, #Error, 0, 40.
Binary operators: + , – , / , * , ^ , & , Or , And , = , < , <= ,
> , >= , <> , In , Like , Mod
Syntax. <ME>::= ( … | <MR1> <Binary operator> <MR2>| … )
<Binary operator>::= ( + | – | / | * | ^ | & | Or | And | = | < | <= | > | >= | <> | In | Like | Mod)
Meaning. Once the values of the MR1 and MR2 operands have been calculated, dimension matching is performed for both (in all
cases, except for the In operation). If matching fails, the expression value will be a single Error constant (the text will be ‘The
dimensions of the operands cannot be matched.’).
Then the operands are converted to the required type (depending on the operator type):
To the real type in the case of + , – , / , * , ^ , < , > , <= , >=, and MOD,
To the Boolean type in the case of Or and And,
To the string type in the case of Like and &.
No type matching is performed for In, = and <>.
Then the specified operation is performed for each element (if an element is of the Error type, the respective element of the resulting
collection will also be of the Error type). The dimension of the result will be equal to the maximum dimension of the operands (for all
operations, except for In).
Descriptions of the operations follow:
1. + , – , / ,* are the arithmetical operations of addition, subtraction, multiplication and division,
2.
^ is the involution operation,
3.
Mod is integer division,
4.
& is string concatenation,
5.
And and Or are the Boolean operations “AND” and “OR.”,
6.
< , <= , > , >= , = and <> are comparison operations,