Sunteți pe pagina 1din 14

Control Sequence Verbs

COBOL Training Class-8

Control Sequence Verbs


STOP RUN GOTO GOBACK EXIT EXIT-PROGRAM PERFORM

CONTROL VERBS

STOP RUN is used to stop programs and return the control back to OS (MVS). Do not use STOP RU in sub programs. EXIT is used to e!it paragraph or program i" #$%T %S US#D the its must be the onl& entr& in that paragraph. the e!it statement does nothing. %" EXIT-PRO R!" is used to e!it a subprogram OB!C# is used to e!it programs. 'hen used in called program it has the same e""ect o" #$%T(PRO)R*M statement and +hen used in main program +orks as STOP RU . OTO is used to trans"er control to another part o" the program, -ontrol +ill not return back.

PERFORM IN !ETAI

PERFORM: Passes the control to specified paragraph, But control will return back. Perform is of two types: 1. INLIN P !"#!$ %.#&'LIN P !"#!$ IN INE PERFORM: 'he statements lie In between the scope of perform ( P !"#!$ ) N*+P !"#!$ , OUT INE PERFROM: 'he statements lie with+in a paragraph, control returns back to the ne-t statement of it.

T$%es O& Per&or's(

1. %. /.

.imple perform is used to e-ecute the referenced code one time Perform N times is used to e-ecute the code multiple times. the actual number of times is indicated by identifier or integer. Perform &ntil condition is used to e-ecute the code multiple times but dependent upon the &N'IL condition. 'he condition will be tested before the code is actually testes unless the 0I'1 ' .' 2"' ! is included. Perform 'hru is used to e-ecute code from one particular paragraph to another in se4uence. Perform 6arying is used to e-ecute multiple times by using 72!8IN9 phase used to count in a 6ariable.

3. 5.

IN INE PERFORM .ynta- : P !"#!$ P !"#!$ N 'I$ . P !"#!$ &N'IL :#N*I'I#N .'2' $ N'1 .'2' $ N'1 .'2' $ N'1 .'2' $ N'% .'2' $ N'% .'2' $ N'% " " " . . . N*+P !"#!$. N*+P !"#!$. N*+P !"#!$. Note# No I$%l&c&t ter$&n'tor &n bet(een t)e sco%e"

Nee) to #no*

'he P !"#!$ and N*+P !"#!$ statements bracket all :#B#L II statements between them. In line P !"#!$s work as long as there are no internal 9# '#s, not e6en to an ;I'. 'he inline P !"#!$ for readability should not e-ceed a page length it would be better to put the code in a separate Para and use P !"#!$ Para+name rather than in+line perform.

OUTLINE PER+OR"

#&'LIN perform statement causes the program to transfer control to another paragraph, e-ecute all the statement within the paragraph, and return to the statement following the P !"#!$ statement. S*nt'+

PERFORM PARANAME" PERFORM PARANAME N TIMES" PERFORM PARANAME UNTI CON!ITION" PERFORM PARANAME, T-RU PARANAME." STATEMENT," STATEMENT."

PARANAME"

.....

TEST BE+ORE , !+TER

If ' If '

.' B "#! is specified, the condition is tested at the beginning of each repeated e-ecution of the specified P !"#!$ range. .' 2"' ! is specified, the condition is tested at the end of the each repeated e-ecution of the P !"#!$ range. 0ith ' .' 2"' !, the range is e-ecuted at least once.

EXAMP E-,
I! !IVISION" PROGRAM-I!" EMP!ETPG" ENVIROMENT !IVISION" !ATA !IVISION" /ORKING-STORAGE SECTION" 0, /S-EMP!ET" 01 EMPI! PIC X213 VA UE 01 ENAME PIC X2,03 VA UE 01 E OC PIC X2,03 VA UE 01 ESA PIC 4213V42.3 VA UE PROCE!URE !IVISION" MAIN-PARA" PERFORM ACCEPT EMPI! ACCEPT ENAME ACCEPT E OC ACCEPT ESA !ISP A5 /S-EMP!ET EN!-PERFORM" STOP RUN"

SPACES" SPACES" SPACES" SPACES"

EXAMP E-. P!#: *&! *I7I.I#N. $2IN+P2!2. P !"#!$ 2:: P'+P2!2. P !"#!$ *I.PL28+P2!2. .'#P !&N. 2:: P'+P2!2. 2:: P' $PI*. 2:: P' N2$ . 2:: P' L#:. 2:: P' .2L. *I.PL28+P2!2. *I.PL28 0.+ $P* '.

+e* Ti%s to Re'e'ber


1. %. /. 3.
&se the P !"#!$ statement to access code which needs to be e-ecuted from more than one location. &se the P !"#!$ statement to structure your code. $ake a main routine that P !"#!$ #'1 ! !#&'IN .. &se the 0I'1 ' .' 2"' ! option to force the code to P !"#!$ * at least once. If the number of lines in the routine is relati6ely small. &se an in+line P !"#!$ instead of outline P !"#!$.

Tr$ Out
0, /S-N PIC 42.3 VA UE 6ERO" A-PARA" MOVE 1 TO /S-N" PERFORM B-PARA /S-N TIMES" B-PARA" MOVE ,0 TO /S-N" -O/ MAN5 TIMES /I B-PARA BE EXECUTE! 7

T-an. /ou

S-ar putea să vă placă și