The text read off it
[page 47]
The ADD Command
The ADD command provides a way to add a given quantity to each of one or more variable quantities. The general form is:
ADD data.name TO variable.1, variable.2, ... variable.n
The effect of the ADD command is to increment the one or more named variables by the quantity represented by "data.name." In this context, "data.name" may be a literal or the name of a variable, constant or function.
The optional phrases TRUNCATED and ON OVERFLOW described above in conjunction with the SET command are equally applicable to the ADD command. As in the case of SET, the ON OVERFLOW option is permitted only if the command specifies a single result field.
Some examples of the use of ADD are:
ADD GROSS.PAY TO YR.TO.DATE.GROSS.
ADD 1 TO COUNTER, ON OVERFLOW GO TO BEGIN.
ADD ADJUST.FACTOR TO RATE TRUNCATED.
The ADD CORRESPONDING Command
This command permits the programmer to specify a series of additions. Its general form is:
ADD CORRESPONDING data.name.1 TO data.name.2, data.name.3,
... data.name.n
Each "data.name" in an ADD CORRESPONDING command must represent an area of storage which is composed of smaller units or fields. The effect of the command is to cause each field in "data.name.1" to be added to its corresponding field (i.e., a field with the same name) in the "to" area(s). Non-corresponding fields in "data.name.1" and in the "to" areas are not affected by the command.
To illustrate, suppose that the programmer wishes to accumulate department totals and grand totals from certain fields in each detail record of a payroll. The detail-record fields involved might be GROSS.PAY, FICA, FED.TAX, STATE.TAX and DEDUCTIONS. Having defined DEPT.TOTALS and GRAND.TOTALS as records containing corresponding fields, the programmer could write:
ADD CORRESPONDING DETAIL.RECORD TO DEPT.TOTALS,
GRAND.TOTALS.
This one command would cause all of the desired totals to be accumulated; it would have the same effect as writing:
ADD DETAIL.RECORD GROSS.PAY TO DEPT.TOTALS
GROSS.PAY, GRAND.TOTALS GROSS.PAY.
ADD DETAIL.RECORD FICA TO DEPT.TOTALS FICA,
GRAND.TOTALS FICA.
ADD DETAIL.RECORD FED.TAX TO DEPT.TOTALS FED.TAX,
GRAND.TOTALS FED.TAX.
ADD DETAIL.RECORD STATE.TAX TO DEPT.TOTALS
STATE.TAX, GRAND.TOTALS STATE.TAX.
ADD DETAIL.RECORD DEDUCTIONS TO DEPT.TOTALS
DEDUCTIONS, GRAND.TOTALS DEDUCTIONS.
