Please enable JavaScript to view this site.
Program to total values with a varying number of input decimals and output a value with a specific number of decimals. The result may be rounded and include comma delimiters if required.
To INITIALISE the parameters and zero the total, use the following parameters:
Parameter |
In |
Len |
Comments |
PARM1 |
Number of output decimals (0 – 5) |
1 |
If left blank defaults to 0 |
PARM2 |
Round up result |
4 |
*YES to round or blank if not |
PARM3 |
Thousand delimiter etc. |
1 |
Enter delimiter if required e.g. “,” |
PARM4 |
Negative sign? |
4 |
*NO to stop minus sign on Total or Sub Total |
PARM5 |
Decimal point e.g. “.” or ”,” |
1 |
If left blank defaults to “.” This is required for Europe where decimal point is a comma. |
PARM6 |
*FIRST |
6 |
This should be called when you wish to zero the total and start again, possibly inside a Page = *FIRST condition |
To ADD or SUBTRACT values, use the following parameters:
Parameter |
In |
Len |
Out |
Len |
Comment |
PARM1 |
Value to sum |
30 |
Sub Total #2 |
20 #3 |
Subtotal |
PARM2 |
|
*NEG |
4 |
If result is negative |
|
PARM3 |
|
|
|||
PARM4 |
|
|
|||
PARM5 |
|
|
|||
PARM6 |
*ADD or *SUB #1 |
6 |
|
Notes:
#1 | If using *ADD you may pass in a number with a minus sign and it will subtract the value. If you do not have minus signs on your spooled file then you may use *SUB to subtract a number from your total. It does not matter if the value that you pass in PARM1 has more or less decimals than the decimals required for the total value. |
#2 | If there is an error in the value being passed in *ERROR will be returned in PARM1 otherwise a subtotal of all the values passed for this type of call since initialisation will be returned. |
#3 | This is the maximum length; the actual length will depend upon the number of decimals you wish returned, a minus sign and whether or not you have specified a thousands delimiter. |
To return the TOTAL value, use the following parameters:
Parameter |
In |
Len |
Out |
Len |
Comment |
PARM1 |
Total Value |
20 #3 |
Total of values |
||
PARM2 |
*NEG |
4 |
If result is negative |
||
PARM3 |
|||||
PARM4 |
|||||
PARM5 |
|||||
PARM6 |
*LAST |
Called when you wish to produce a total, possibly inside a Page = *LAST condition. |