In this topic, we described about the below sections -
THROUGH/THRU PERFORM is used to execute the statements-block that are coded with procedure. THROUGH/THRU PERFORM is out-of-line PERFORM only.
procedure-name-1, procedure-name-2 -
Must name a section or paragraph in the procedure division. If one of the procedures is in a declarative procedure and both procedures are specified, the other procedure also must be procedure-names in the same declarative procedure.
If procedure-name-1 is specified, imperative-statement-1 and the END-PERFORM phrase must not be specified. If procedure-name-1 is omitted, imperative-statement-1 and the END-PERFORM phrase must be specified.
The statements-block to be executed for an in-line PERFORM. The only relationship between procedure-name-1 and procedure-name-2 is that a consecutive sequence of operations is executed, beginning at the procedure named by procedure-name-1 and ending with the execution of the procedure named by procedure-name-2. The returning of transferred control is determined as follows -
- If procedure-name-1 is a paragraph name and procedure-name-2 is not specified, the control returns after the execution of the last statement of the procedure-name-1 paragraph.
- If procedure-name-1 is a section name and procedure-name-2 is not specified, the control returns after the execution of the last statement of the last paragraph in the procedure-name-1 section.
- If procedure-name-2 is specified and it is a paragraph name, the control returns after the execution of the last statement of the procedure-name-2 paragraph.
- If procedure-name-2 is specified and it is a section name, the control returns after the execution of the last statement of the last paragraph in the procedure-name-2 section.
PERFORM statements can be specified within the performed procedure procedure-name-1. If there are two or more logical paths to the return point, then procedure-name-2 can name a paragraph that consists only of an EXIT statement and all the paths must lead to this paragraph.
Practical Example - PERFORM THROUGH