FORMULA STATEMENT  
Previous  Top  Next

Description  
 
This statement, referred to as "reverse Polish", uses a stacking method and is formatted  
 
F;element;element;element.....  
 
where the element can be an attribute, an arithmetic operation, a relational operator, a special operand, another Correlative or a Conversion.  
 
Due to the complexity of this instruction it is advised that you consult the Multi-Value manual section referring to CONVERSIONS and CORRELATIVES.  
 
This help message and the OSMOSi manual section entitled CORRELATIVES show some examples of its use.  
 
The principal of the stack is that the program will examine the statement from the first element immediately after the F. The value will be placed in stack 1. The next element will be examined, if it is another value, stack 1 will be moved to stack 2 and the new value into stack 1. When an operation is found then stack 1 and/or stack 2 will be used for that operation e.g. addition uses stack 1 and 2, a Correlative/Conversion will only use stack 1.  
 
As each stack is used it is deleted from the stack (i.e. stack 2 will be moved to stack 1 etc. until the last occupied stack, which will be cleared of data). Results are always put into stack 1 moving stack 'down' first.  
 
document Examples  
 
F;1;"100";*;15;/;"1500";12;+;- - is the equivalent of a normal arithmetic statement A12-"1500"+(1*"100"/15)  
 
F;1;"2";"3";[ ];"100";>;"1500";*;(TVATFILE;X1;;1) - results in either 0 or 1500 as the key to access the VATFILE and extract the 1st multi-value element of attribute 1 of the record indicated. The item-id to use depends on the 2nd to 4th characters (inclusive) of attribute 1, being greater than 100 or not. If the value extracted is greater than 100 the item-id will be (1500) "1"*"1500" otherwise it will be (0) "0"*"1500".     
 
Permissible Operators:  
 
Operand
Description
" * "
multiply STACK 1 with STACK 2.
" *nn "
multiplication with the decimal place of the result shifting left by nn places.
" / "
divide STACK 2 by STACK 1.
" R "
as divide but returns REMAINDER not quotient.
" + "
add STACK 1 to STACK 2.
" - "
subtract STACK 1 from STACK 2.
" : "
concatenate (or join) STACK 1 to the start of STACK 2.
" [ ] "
extract from the contents in STACK 3 starting at position in STACK 2 for the number of characters in STACK 1
" S "
sum the attribute in STACK 1.
" _ "
(underline) exchanges STACK 1 and STACK 2.
" P "
inserts STACK 1 at the top of the stack i.e. as STACK 1
" (...) "
conversion/correlative statement using STACK 1 to perform the statement.
" = "
returns 1 if STACK 1 and STACK 2 are equal.
" # "
returns 1 if STACK 1 and STACK 2 are not equal.
" < "
returns 1 if STACK 2 is less than STACK 1.
" > "
returns 1 if STACK 2 is greater than STACK 1.
" [ "
returns 1 if STACK 2 is 'greater than or equal to' STACK 1.
" ] "
returns 1 if STACK 2 is 'less than or equal to' STACK 1.
" D "
push the system date in internal format, into the STACK 1.
" T "
push the system time in internal format, into STACK 1.
" NI "
push the current item counter (number of items selected or listed) into STACK 1.
" ND "
push the number of detail lines since the last BREAK on a break line into STACK 1. Value is 1 on a detail line or the number of lines that make up the total break.
" NV "
push the current multi-value counter for columnar listings only into STACK 1.
" NS "
push the current sub-value counter for columnar listings only into STACK 1.
" NB "
push the Break level number, 1 = lowest level, 255 = grand total into STACK 1.
 
 
document Examples  
 
"F;12;NV;/ -" averages the multi-values of attribute 12.  
"F;13;ND;/ -" shows an average of attribute 13 over the number of lines within a break.