6.5

© 2007 ABBYY. All rights reserved.
53
Abs ({–2,`3.0`,`4b`}) is {2, 3, #Error}
Formatting operator: Format
Syntax. <MR>::= ( … | Format (<MR1> , <MR2>) | … )
Meaning. Before the operation begins, the value of the МE1 operand is converted to the string type. Then dimension matching is
performed. If it is successful, the result dimension is the maximum of the dimensions of the involved operands. The result itself will be
a string. Each element of the result value will be equal to the result of calling the VB Format function for the corresponding elements
of the operand values.
Example.
Format(Array(5459.4,`HELLO`,Now()), {`##,##0.00`,`<`,`h:m:s`}) is {5 459.40,`hello`, 17:16:52}
Progression operators: Inc, Dec, Mult
Syntax. <MR>::= ( … | <Progression operator> (<MR1> , <MR2> [, <MR3> ]) | … )
<Progression operator>::=( Inc | Dec | Mult )
Meaning.
Progression operators are, in a sense, the reverse of packing operators: packing operators return a single value for a value set,
whilst progression operators return a progression similar to an arithmetic or geometric progression for a single element. The first
operand serves as the first term of the progression, the second serves as the number of iterations, and the third is the common
difference. Before the operation begins, the type conversion is performed: the first and the third argument are converted to the real
type, the second – to the long type. If there is a third operand, the dimensions of the first and the third operand are matched. If all
these operations are performed successfully, the result will be calculated as follows:
Step 0: The value got at the zero step is the value of the first operand.
Step k:
1. All elements got at the previous step are added to the resulting collection.
2. If there is no third operand, the value got at this step is the value got at the previous step. If there is a third operand, the
value got at this step is the result of the binary operation of addition (for the
Inc operation), subtraction (for the Dec
operation) and multiplication (for the Mult operation) over the values of the first and the third operands.
The number of steps is equal to the first element of the second operand value (i.e. the second operand should be one–dimensional,
but if it is not, no error will occur, as the program takes only the first element).
Examples.
Inc(1,{3,4,–1},6) is {1, 7, 13}
Dec({2,20},5,1) is {2, 20, 3, 21, 4, 22, 5, 23, 6, 24}
Mult({1,4,5},{3,1},{–1,–2,2}) is {1, 4, 5, –1, –8, 10, 1, 16, 20}
Use examples.
Let all the document pages have the ‘Page number’ field, and the values of these fields must form the natural sequence
starting from 1. You can specify the following rule: #*!Page number #=Inc(1, Count(#*!Page number#), 1).
Cut operator: SubArray
Syntax. <MR>::= ( … |SubArray ( <MR1> , <MR2> [ , <MR3> ] ) | … )
Meaning.
The cut operator gets a range of elements form a collection. You can get, for example, only the second element, or all
elements from the third to the fifth one. Before the operation begins, the second and the third operands are converted to the integer
type. The second and the third operands should be one–dimensional, but if they are not so, no error occurs – the program only takes
their first elements. The result of the operation will be a value that contains the MR1 value of elements with numbers from N1 to N2,
inclusive, where N1 is the first element of the MR2 value, and N2 is the first element of the MR3 value if there is such operand, and the
number of the MR1 elements if there is no MR3. If N2<N1, or N1 is more than the number of elements, or N2<1, the result will be an
empty collection.
Examples.
SubArray({2,3,`ddf`,–1,3,45}, {2,1}, 3) is {3,`ddf`}
SubArray({2,3,`ddf`,–1,3,45}, –1, {3,–2}) is {2,3,`ddf`}
SubArray({2,3,`ddf`,–1,3,45}, 4, 4) is {–1}
SubArray({2,3,`ddf`,–1,3,45}, 4) is {–1,3,45}
SubArray({2,3,`ddf`,–1,3,45}, 7) is {} (empty collection)
Use examples.
Suppose we have a rule: the «Summa» field on the second page corresponding to the «А» template must be equal to the
sum of the «RevenueSum» fields of the third and fourth pages corresponding to the same template. You can specify the following rule:
CDbl(SubArray(#A!Summa#,2,2))=Sum(SubArray(#A!RevenueSum,3,4)).
Substring cut operator: SubStr
Syntax. <MR>::= ( … | SubStr (<MR1> , <MR2> [ , <MR3>])| … )
Meaning. Before the operation begins, the first operand is converted to the string type, and the second and the third are converted to
the long type. Then the dimensions of all the three operands are matched. If all these operations are performed successfully, the
element–by–element operation of substring cutting is performed; this operation is similar to the Visual Basic Mid operation. It works
as follows: let the respective operands’ values equal s, n1 [, n2]. A substring is cut from the string; this substring begins with the n1–th
character of the source string inclusive and has the n2 length (if there is a third operand) or stretches to the end of the source string
otherwise. The substring is added to the resulting value.
Examples.