

F CORRELATIVESF codes provide many facilities for arithmetic, relational, logical, and concatenation operations. All operations are expressed in Reverse Polish notation and involve the use of a "stack" to manipulate the data.
SYNTAX SUMMARYThere are three forms of the F code: F Uses only the integer parts of stored numbers unless a scaling factor is included. If the JBCEMULATE environment variable is set to "ROS", the operands for "", "/" and concatenate are used in the reverse order. FS Uses only the integer parts of stored numbers. FE Uses both the integer and fraction parts of stored numbers.
SYNTAXF{n};elem{;elem}...
SYNTAX ELEMENTSn is a number from 1 to 9 used to convert a stored value to a scaled integer. The stored value"s explicit or implied decimal point is moved n digits to the right with zeros added if necessary. Only the integer portion of this operation is returned. elem is any valid operator. See later.
NOTESF codes use the Reverse Polish notation system. Reverse Polish is a postfix notation system where the operator follows the operands. The expression for adding two elements is "a b + ". (The usual algebraic system is an infix notation where the operator is placed between the operands, for example, "a + b"). The F code has operators to push operands on the stack. Other operators perform arithmetic, relational, and logical operations on stack elements. There are also concatenation and string operators. Operands that are pushed on the stack may be constants, field values, system parameters (such as data and time), or counters (such as record counters).
THE STACKF codes work with a pushdown stack. Note: All possible F correlative operators push values onto the stack, perform arithmetic and other operations on the stack entries, and pop values off the stack. The term "push" is used to indicate the placing of an entry (a value) onto the top of the stack so that existing entries are pushed down one level. "Pop" means to remove an entry from the top of the stack so that existing entries pop up by one level. Arithmetic functions typically begin by pushing two or more entries onto the stack. Each operation then pops the top two entries, and pushes the result back onto the top of the stack. After any operation is complete, the result will always be contained in entry 1.
ORDER OF OPERATIONF code operations are typically expressed as "F;stack2;stack1;operation".
Under most emulations, this will be Note that the FE and FS codes are evaluated in the same way for all emulations.
INPUT CONVERSIONInput conversion is not allowed.
EXAMPLE 1
Push a value of 3 onto the stack. Push a value of 5 onto the stack. Take entry 1 from entry 2 (3  5) and push the result (2) back onto the stack as entry 1. ROS emulations will subtract 3 from 5 and return a result of 2.
EXAMPLE 2
Push a value of 3 onto the stack. Push a value of 5 onto the stack. Take entry 2 from entry 1 (3  5) and push the result (2) back onto the stack. This works in the same way for all emulations.
EXAMPLE 3
Push a value of 2 onto the stack. Push a value of 11 onto the stack. Push a value of 3 onto the stack. Subtract entry 1 from entry 2 (11  3) and push the result (8) back onto the stack. Now divide entry 2 by entry 1 (2 divided by 8) and push the result (0) back onto the stack. Under ROS emulation, this would evaluate as 3  11 = 8, followed by 8 / 2 = 4.
PUSH OPERATORSA push operator always pushes a single entry onto the stack. Existing entries are pushed down one position. Push operators are: "literal"Literal. Any text string enclosed in double or single quotes. fieldnumber{R{R}}{(formatcode)} fieldnumber is the value of the field from the current record. R specifies that the last nonnull value obtained from this field is to be applied repeatedly for each multivalue that does not exist in a corresponding part of the calculation. RR specifies that the last nonnull value obtained from this field is to be applied repeatedly for each subvalue that does not exist in a corresponding part of the calculation. (formatcode) is one or more format codes (separated by value marks) enclosed in parentheses. Applied to the value before it is pushed onto the stack.
ARITHMETIC OPERATORSThe arithmetic F code operators work on just the top stack entry or the top two stack entries. They are:
MISCELLANEOUS OPERATORSMiscellaneous operators control formatting, exchanging stack entries, popping the top entry, concatenation, and string extraction. They are:
RELATIONAL OPERATORSRelational operators compare stack entries. The result is pushed onto stack entry 1 and is either 1 (true) or 0 (false). Relational operators are:
LOGICAL OPERATORSLogical operators include a logical AND test and a logical inclusiveOR test. Logical operators are: & AND stack entries 1 and 2. If both entries contain non zero, a 1 is pushed onto stack entry 1, otherwise, a 0 is pushed. ! OR stack entries 1 and 2. If either of the entries contains non zero, a 1 is pushed onto stack entry 1; otherwise, a 0 is pushed.
MULTIVALUESA powerful feature of F and FS code operations is their ability to manipulate multivalues. Individual multivalues can be processed, one by one, or you can use the R (or RR) modifier after a field number, to repeat a value and thus combine it with each of a series of multivalues. Field operands may be valued and subvalued. When mathematical operations are performed on two multivalued lists (vectors), the result is also multivalued. The result has an many values as the longer of the two lists. Zeros are substituted for the null values in the shorter list if the R option is not specified.
REPEAT OPERATORSTo repeat a value for combination with multivalues, follow the field number with the R operator. To repeat a value for combination with multiple subvalues, follow the FMC with the RR operator.
FORMAT CODESFormat codes can be used in three ways. One transforms the final result of the F code, another transforms the content of a field before it is pushed on the stack, and the third transforms the top entry on the stack.
SYNTAXfcode{]formatcode...}
SYNTAX ELEMENTSfcode is a complete F Code expression. fieldnumber is the field number in the record from which the data is to be retrieved. formatcode is any valid format codes. ] represents a value mark (ctrl ]) that must be used to separate each formatcode.
NOTESTo process a field before it is pushed on the stack, follow the FMC with the format codes enclosed in parentheses. To process the top entry on the stack, specify the format codes within parentheses as an operation by itself. To specify more than one format code in one operation, separate the codes with the value mark, (ctrl ]). All format codes will convert values from an internal format to an output format.
EXAMPLE
Obtain the value of field 2. Apply an MD2 format code. Then apply a group extract to acquire the integer portion of the formatted value, and push the result onto the stack. Subtract 100 from the field 2 formatted, groupextracted value. Return this value. Note that under ROS emulation, the value returned would be the result of subtracting the integer value from the group extract, from 100. In other words: 100  OCONV(OCONV(Field2, "MD2"), "G0.1" ). 