skip to main content

Procedure Division Statements : PERFORM

PERFORM
General Format
Format 1
PERFORM  [IN THREAD] procedure-name-1 [ {THROUGH} procedure-name-2 ]
[HANDLE IN Handle-1] [times-phrase  ]
Format 2
PERFORM [times-phrase  ] imperative-statement-1 END-PERFORM
where times-phrase is:
where until-phrase is:
[ WITH TEST {BEFORE} ] UNTIL {condition-1}
where varying-phrase is:
[ WITH TEST {BEFORE}
VARYING {identifier-2} FROM {identifier-3} [BY {identifier-4}] UNTIL condition-1
AFTER {identifier-5} FROM {identifier-6} [BY {identifier-7}] UNTIL condition-2] ...
Format 3
PERFORM  imperative-statement-1 UNTIL EXIT END-PERFORM
Syntax rules
1.
2.
3.
4.
5.
A.
B.
6.
A.
B.
C.
7.
8.
9.
10.
General rules
1.
2.
3.
A.
B.
4.
 
NOTE - Statements such as the GO TO statement, the PERFORM statement, and the procedure format of the EXIT statement may occur in the flow of execution of the specified set of statements, however the flow of execution should eventually pass to the end of procedure-name-2.
5.
6.
7.
 
NOTE - During execution of the PERFORM statement, a change to the contents of identifier-1 does not alter the number of times the specified set of statements is performed.
8.
9.
 
NOTE - If an augment value is less than 0, the induction variable is actually decremented by the absolute value of the augment value.
 
The sequence of operation of the PERFORM statement is as follows:
A.
B.
C.
i.
ii.
iii.
iv.
D.
E.
i.
 
If condition-1 is true, control is transferred to the end of the PERFORM statement; otherwise, the condition-2 immediately to the right becomes the current condition.
ii.
 
If the current condition is true:
a.
b.
c.
d.
 
otherwise:
a.
 
—the condition associated with that AFTER phrase becomes the current condition
 
—execution proceeds to the beginning of step b;
b.
 
—the specified set of statements is executed
 
—the induction variable associated with the current condition is incremented by the augment value
 
—execution proceeds to the beginning of step b.
 
During the execution of the specified set of statements associated with the PERFORM statement, all changes to the induction variable, the variables associated with the augment value, and the variables associated with the initialization value have immediate effect and all subsequent references to the associated data items use the updated contents.
10.
11.
12.
Format 3
13.
Examples
Format 1 - Perform paragraphs in separate thread
working-storage section.
77 t-handle-1 usage handle of thread.
procedure division.
  perform thread par-1 handle t-handle-1
  display message "This message displays even before par-1 is done"
Format 2 - Perform paragraphs or statements n times
perform par-1 thru par-5 10 times
perform par-2 5 times
perform 10 times 
  add 1 to var-1 
Format 2 - Perform paragraphs or statements until condition evaluates true
perform multiply-var-1 until var-1 > 900
perform compute-interest thru compute-exit until var-interest > 0
perform until var-1 > 900
  multiply 2 by var-1 
Format 2 - Perform paragraphs or statements varying variable
perform count-items varying ws-count from 1 by 1 until ws-item-count > 9850
perform until varying ws-count from 1 by 1 until var-1 > 900
  multiply ws-count by var-1 
Perform paragraphs or statements testing the condition after the first iteration
perform multiply-var-1 test after until var-1 > 900
perform compute-interest thru compute-exit test after until var-interest > 0
perform test after until var-1 > 900
  multiply 2 by var-1 

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left