pc.function Processing Code/Restore Processor

pc.function

Command pc.function Processing Code/Restore Processor
Applicable release versions:
Category Restore Processor (84)
Description used in the conversion, correlative, and input-conversion attributes of attribute-defining items, to create and modify the associated attribute value using various mathematical and logical operations.

Elements in an f-correlative are operands and operators in "Reverse Polish Notation" separated by semicolons. As each operand is encountered scanning from left to right, its value is "pushed" onto a stack. As an example a "push-down" stack is usually compared with the spring loaded mechanism that loads, stores and dispenses saucers in a restaurant.

Operators operate on the top entries in the stack. For example the addition operator "+", "pops" and adds the top two entries in the stack together and then pushes the result back onto the stack.
Operands and operators may appear in any order and after all the operand pushes and operator operations have been processed and the right end of the f-correlative has been reached, what's left on the stack is the result.

Operands:

ac{r} Attribute value of the attribute whose attribute count is "ac". "r" specifies that the first value or subvalue of an attribute is to be used repeatedly when using it against a multi-valued value or subvalue.
"string" Operand is the immediate literal string.
cn Numeric constant "n".
d System date in external format (dd mmm yyyy)
lpv Last processing code
nb Break level number. On detail lines, 0 is returned. The break level number has a value of 255 on the grand-total line and a value of 0 (zero) on detail lines. The lowest level control-break in the sentence has a value of 1.
nd Pushes the number of detail lines since the last "break-on" on the stack. On a detail line, "nd" has a value of 1. On a grand-total line, "nd" equals the item counter; ("nd" can be used to generate averages in conjunction with control breaks).
ni Pushes the current item counter (number of items listed or selected) on the stack.
ns Pushes the current sub-multi-value counter on the stack (for columnar listing only).
nv Pushes the current multi-value counter on the stack (for columnar listing only).
t Pushes the current time (in "00:00:00" format) on the stack.


Operators:
The term, stack#, is used in the following descriptions to indicate the stack level where the data resides (level 1 being the top, 2 being the next level, etc.).


*{n} Multiplies stack1 by stack2. If the optional "n" is used, the result is divided by 10 to the power of (n-1). (This is not available as an a-correlative operator. Use the division operator with the appropriate literal value, i.e. /"100".)
/ Divides stack2 by stack1, and returns quotient to stack1. Results of division operations are rounded down.
r This is the same as "/", except the remainder of the division is returned to stack1.
+ Adds the top two entries in the stack and returns the sum to stack1.
- Subtracts stack1 from stack2 and returns the result to stack1.
: Concatenates the string value in stack1 to the end of the string value in stack2 and returns the result to stack1
[ ] Extract a substring from string value in stack3, using stack2 as the starting character position, and stack1 as the number of characters to extract. The result is placed in stack1.
s Adds multi-values in stack1 (if any) and returns the sum to stack1.
_ (Underscore) Exchanges the top two positions in stack.
p Pushes the top stack value back on the stack, resulting in the same value in stack1 and stack2.
(processing.code) A standard processing code such as "d" (date), "g" (group), etc., may be specified. It operates on the top stack value and the result replaces the original top stack value.



Relational Operators:

Relational operators compare stack1 to stack2 entries. A "1" (one) is returned to stack1 if the condition evaluates to true. A "0" (zero) is returned to stack1 if the condition is false. The following relational operators are available:


= true, if stack1 equals stack2
< true, if stack1 is less than stack2
> true, if stack1 is greater than stack2
# true, if stack1 does not equal stack2
=> true, if stack1 is equal to or greater than stack2
=< true, if stack1 is equal to or less than stack2


Branching:


j ~label branches to label
jf ~label If the top stack entry is zero, it branches to the specified label.
jt ~label If the top stack entry is non-zero, it branches to the specified label.
~label The label is a "~" (tilde) followed by any ASCII characters other than a ";" (semi-colon), blank, Attribute Mark, or Value Mark, which ends the label.


Conditionals:

Conditionals are constructed using a syntax very similar to the Pick/BASIC "if...then...else" construct and have the general form:
if condition then f.code {else f.code} {end}
if condition else f.code { end }
if condition then f.code { end }

If the condition evaluates to zero, it is considered false and, if present, the "else" clause is taken. If the evaluation is false, and the "else" clause is missing, a null is returned.

If the condition evaluates to non-zero, it is considered true, and, if present, the "then" clause is taken. If the evaluation is true, and there is no "then" clause, a null is returned.

If "end" is not specified, the "else" is paired with the nearest previous "if". The "end" is used to close off the current "if" and associates the "else" with the prior "if".
Syntax f;element{;element...}
Options
Example
Purpose
Related correlative
conversion
up.correlative.adi
pc.a
reverse.polish
pc.f
up.correlative.fdi