When a user is generating a routine, there are occasions when a series of values are entered or displayed. At times it would be useful to display the sum of these values. This can be achieved by defining the prompt variable 'SUM ABOVE$' as a V type. In many respects, it is the same as the other prompts in the window. It requires a variable type code "V" although no XREF file definition is allowed, there is an entry for ATTRIBUTE/EXPRESSION which is 'SUM ABOVE$'. It has a cursor position which is where the total is printed out on the screen. A CONVERSION can be defined for it and a JUSTIFICATION can be applied to the output. However, much of the processing to handle it is totally different.

In its simplest form it will take the multi-valued list defined by the prompt IMMEDIATELY preceding it and sum it, displaying the total at the position defined. This total is maintained irrespective of any changes made to the contents of the multi-valued list. This list may also refer indirectly to a data value that the preceding variable definition can be for a D type.

Valid variable types for which this facility may be maintained are D, N and S.

Take the following example :-

In this case the multi-valued attribute STOCK.ITEM.COST on the MAIN UPDATE record would be displayed and input from cursor position 10 and its related positions. Once the multi-values in the attribute STOCK.ITEM.COST have been input, changed or deleted, a total is displayed at cursor position 25. IN ADDITION, the actual sum is stored in a variable. The name of the variable begins with 'TOTAL.'. This is then followed by the field name of the variable totalled and finished of with a '$'. In this case that variable would be 'TOTAL.STOCK.ITEM.COST$'

In this case a value is input for STOCK.CODE. This is zero filled and checked against the SF1 file. If it is a valid code then the value ITEM.COST is displayed and a total of all ITEM.COSTs is displayed at cursor position 25. Again a total is produced and maintained in a variable. The name of this variable now has the file variable following the 'TOTAL.'. In this case the variable name would be 'TOTAL.SF1.ITEM.COST$'.