6.5

© 2007 ABBYY. All rights reserved.
48
Descriptive multipage rule language
Multipage rules (MRs) are written in а special descriptive multipage rule language.
Below follows а formalized description of the multipage rule language in terms of the meta–linguistic formulas. Terminal symbols are
boldfaced.
<Rule description>::= ( <MR> | < Operator calling automation–rule > (`<String>`) )
<MR>::= ( <Elementary expression> |
( <MR> ) |
<MR> <Binary operator> <MR>|
<Unary operator> <MR>|
<Zero–argument operator> () |
< Single–argument operator > (<MR>) |
< Formatting operator > (<MR> , <MR>) |
< Binary or ternary operator > (<MR> , <MR> [, <MR> ] ) |
< Ternary operator > (<MR> , <MR> , <MR>) |
< Glue operator > (<MR> { , <MR> } ) )
<Elementary expression>::=(<Reference to field> | <Reference to document MR> | <One–dimensional constant> | <Multi–
dimensional constant>)
<Reference to field>::= # ( <Template name> | * ) ! <Field name> #
<Reference to document MR>::= #^ ( <Document type name> | * | me ) ! <MR name>#
<One–dimensional constant>::= ( <Number> | `<String>` | False | True )
<Multi–dimensional constant>::= { <One–dimensional constant> { , <One–dimensional constant>} }
<Binary operator>::=( + | – | / | * | ^ | & | Or | And | = | < | <= | > | >= | <>| In | Like | Mod)
<Unary operator>::=( – | !)
< Zero–argument operator > ::= ( Now | Date )
< Single–argument operator > ::= (<Type conversion operator> | <String processing operator>| < Packing operator > |<Part–of–date
operator> | IsError | Error | Abs )
<Type conversion operator>::=( CDbl | CBool | CStr | CLng | CDate)
<Packing operator>::= ( Sum | Prod | Avg | Max | Min | Count | First | Last| NumMax | NumMin | Same | Unique)
< String processing operator > ::= ( UCase | LCase | Len | Trim )
< Part–of–date operator> ::=( Year | Month | Day )
<Formatting operator> ::= Format
<Binary or ternary operator>::=( < Progression operator > | <Cut operator>| < Substring cut operator >)
<Progression operator>::=( Inc | Dec | Mult )
<Cut operator>::= SubArray
<Substring cut operator>::= SubStr
<Ternary operator > ::= ( < Select operator > | <Substring replace operator> | <Data creation operator> )
<Select operator>::= IIf
< Substring replace operator > ::= Replace
<Data creation operator> ::= DateSerial
<Glue operator>::= Array
< Operator calling automation–rule > ::= AutoRule
A multipage rule is a function that depends on the page field values and the document parameter values and returns a value.
The Value of a multipage rule
The value of a multipage rule can be a constant or a collection of constants. For example, if a multipage rule is a simple reference to
the “Number” field of the “Card” page template, then its value is a collection of the “Number” field values of all document pages that
correspond to the “Card” template (there may be more than one such page). In general, the value of a multipage rule is a collection of
constants that can consist of one or several elements or be empty (if, for example, there are no pages with the given template in the
batch). The dimension of the multipage rule value is the number of elements it contains. The dimension of an empty collection is 0.
There are standard value types – long, real, string, Boolean, data – and a special Error type. The cases when an error value is returned
are described below.
The verity of a multipage rule
A multipage rule is executed successfully if its value is an empty collection or a collection all elements of which are either logical
constants True or string constants “true.”
Let us now consider several types of multipage rule and how their values are calculated. For each type of rule the following
information is provided: rule syntax, its meaning, sample rules, and examples of use (in complicated cases).
Note: The command words are not case–sensitive. A multipage rule may be enclosed in brackets; in this case its meaning will not
change.
Elementary multipage rules:
One–dimensional constant
Syntax. ( <Number> | `<String>` | False | True )
Comments on syntax
. String constants are enclosed in single quotes «`». Number constants are separated by a full stop.
Value
. The value of this simple expression is a collection containing a single element – a numeric, string or Boolean constant.
Sample expression. 32.43