On the whole this section does not apply to character operands. A character field is always treated as a single string: for instance if ADDRESS is C30*4, it is treated by the formula processor as a string 120 long. Most operators and functions that accept character operands treat the character operand as a single string. So while the > operator applied to two instances of the budget field returns an array of 12 Boolean values, applied to two address fields it returns a single Boolean.
Most operators and functions in the DP4 formula processor accept multi-occurrence fields and expresions as operands as well as single-occurrence fields; though there are a few exceptions to this it is extremely unlikely you would ever want to use a multi-occurs expression where one is not allowed. This page explains how multi-occurrence operands are treated by the formula processor.
Except for functions that are specifically designed to process a
multi-occurs field and return a single value (SUM, EVERY, ANY,
MINIMUM, MAX) or perform some other special action on a
multi-occurs field, the result of unary arithmetic
operators/functions is that produced by applying the operator to
each occurrence of the operand in turn. Thus
ABS(-1|-2|-3) returns 1 | 2 | 3.
The formula budget+1 has as its result an occurs 12
field where the i'th occurrence is budget[i]+1. If
VAT is another occurs 12 field then budget +
VAT has as its i'th occurrence budget[i] +
VAT[i]. The occurs of the left operand determines the
number of occurs in the result - the formula 1 +
budget has as its result the single value
budget[1]+1.
The other binary arithmetic operators (such as *, - and /) all behave in a similar way. Usually the second operand of an arithmetic binary operator should have either the same number of occurrences as the first operand or one occurrence, but this is not enforced by the formula compiler. The actual result, R, of A op B where 'op' is a binary operator calculated as follows:
R[i] = A[i] op B[min(i, N)] where N is the number of occurrences of B.
Note that, as already noted for addition above this means that if A and B have different occurrences then A op B is not the same as B op A.
Concatenating a 0 or a 1 onto the end of the second operand may
sometimes be useful. For example, to apply VAT holiday for a
variable number of months you might use a formula like this:
BUDGET + (HEAD(VAT,i) | 0).
The relational operators =, <>, <, >, <=, >=
are all treated in the same way as the arithmetic operators: thus
budget.THIS < budget.LAST has as its result an
occurs 12 Boolean field, the i'th occurrence of which is the result
of budget.THIS[i] <
budget.LAST[i]
Again the logical operators behave in the same way. Consider the
following formula:
budget.this>0 or budget.last = 0
First the two relational expressions are evaluated giving two occurs 12 Boolean fields as the result. The OR then OR's the corresponding occurrences together to give another occurs 12 Boolean result. The ANY or EVERY functions are often useful when you have created results of this nature.
A similar process is used when assigning the final result of a formula to its field - if the target field has more occurrences than the result, then remaining occurrences will all contain the last occurrence of the result, if it has fewer the excess occurrences are discarded.
Concatenating results with 0 may sometimes be useful to stop the last occurrence being used repeatedly.