The text read off it
[page 9]
TRANSACTION can vary from 1 to 4. These numbers correspond to the names within the parentheses; if the value is 1 the first name will be selected and so on. This is summarized in Figure 5.
| If the current value of TYPE.OF.TRANSACTION is: | Then GO TO: |
|---|---|
| 1 | WITHDRAWAL.ROUTINE |
| 2 | RECEIPT.ROUTINE |
| 3 | RETURN.PROCESS |
| 4 | RECOUNT.PROCEDURE |
Figure 5. Assigned GO TO values for Example 4 (page 9).
This assigned GO TO provides a multiple branch or switching point. For those with punched card background this may also be thought of as a "digit selection" operation.
Lines 05 and 06 illustrate another use of the SET command. It is evident from examining this sentence that the equal sign (=) in the SET command is used to mean "replace." SET A=B means replace A by the value of B, where B represents any valid expression. Thus, in the example, the difference between QUANTITY.ON.HAND and TRANSACTION.QUANTITY (to the right of the equal sign) replaces the original QUANTITY.ON.HAND.
Line 07 demonstrates another type of transfer of control:
DO REORDER.CALCULATION
The DO command may be thought of as meaning "go to the place named, do whatever it says to, and come back." In our case, it is used to transfer to a procedure named REORDER.CALCULATION and set up a return path so that, after executing that procedure, control will return to the command immediately following the DO command. After performing the REORDER.CALCULATION, control will return to, and execute, the GO TO NEXT.ITEM command on line 07.
Example 5
As another illustration of the use of Commercial Translator, we will use a savings bank procedure: updating the account record to indicate interest payment. The program might look like this:
Coding-form facsimile: Example 5 procedure statement (page 9).
SERIAL PROCEDURE NAME TEXT
01 INTEREST.CALCULATION. IF .03 * PRINCIPAL
02 IS LESS THAN 1.00 THEN GO TO
03 END. OTHERWISE SET ACCOUNT BALANCE
04 = 1.03 * PRINCIPAL. MOVE 'INTEREST'
05 TO ACTION.
Line 01 shows again the use of a procedure-name to provide a named point to which program control can be transferred. In this case it precedes a slightly different type of conditional clause. Instead of simply comparing two values as we have before, the programmer has indicated that he wishes to see if the value of an arithmetic expression (.03 * PRINCIPAL) is less than some numeric literal (1.00). It is quite valid to incorporate an arithmetic expression within a conditional expression. For clarity, it may often be desirable to use parentheses to denote the beginning and end of such an arithmetic expression.