SEQUENCE CONTROL STATEMENTS

STOP Statement

This performs to stop or to halt the execution of the program.

Format:

STOP RUN/Lit.

NOTE:

Examples:

STOP 5.
STOP "hellow".
STOP RUN.


Input Outout Statements

PROCEDURE DIVISION Page


GO TO Statement

It is used to branch, depart or transfer the sequence of the execution of statement unconditionaly.

Format:

GO TO ( procedure name).
PROCEDURE DIVISION Page

GO TO ... DEPENDING ON Statement

Format:

GO TO (List of procedure names) DEPENDING ON (data item).

Note:

  • When the transfer of control is required to some procedure conditionally the data item that contains the whole number value.
  • The control is transfered to the procedure (whose name is present in the format) at the position number by taking the value of data item.
  • Data item must be defined unsign integer.

Examples:

GO TO islamabad karachi lahore quata peshawar DEPENDING ON CITY-CODE. GO TO AJK. islamabad. move 'capital' to city-type GO TO ajk. karachi. move 'sind' to city-type GO TO ajk. lahore. move 'punjab' to city-type GO TO ajk. quata. move 'baluchistan' to city-type GO TO ajk. peshawar. move 'nwfp' to city-type GO TO ajk.
PROCEDURE DIVISION Page

PERFORM Statement

  • This verb is used to perform a specified procedure (contains one or more than one statements) and back to next instruction after it.
  • The difference of GO TO statement and PERFORM statement is skipping but not back and skipping but back respectively.

Format:

PERFORM ( procedure name).

Examples:

PERFORM calc-proc.

TIMES option in PERFORM statement

This option of PERFORM verb means to execute the specified procedure or procedures a number of time.

Format:

PERFORM (procedure name) Integer/data neme TIMES.

Examples:

PERFORM add-rtn 50 TIMES.

UNTIL option in PERFORM statement:

This option in PERFORM is valid if the execution of some routine/s is/are required conditionaly.

Format:

PERFORM (procedure name) UNTIL (condition).

Note:

* By use of UNTIL the condition is checked before the procedure/s is/are to be executed. * If the condition is true the procedure will not be executed.

THROUGH/THRU option in PERFORM statement

Whenever a series of procedures are to be performed this option may be used. This gives the range of procedures and starts to perform from top to bottom.

Format:

PERFORM (Procedure name S) THROUGH/THRU (Procedure name E).

Note:

Procedure name S is the Starting procedure and Procedure name E is ending procedure.

Example:

PERFORM abc THROUGH xyz. STOP RUN. abc. MOVE'abc' TO A-B-C. imn. MOVE 'imn' TO L-M-N. pqr. MOVE 'pqr' TO P-Q-R. xyz. MOVE 'xyz' TO X-Y-Z.
PROCEDURE DIVISION Page

Nested Perform Statement:

It is possible to have one or more PERFORM statements in the range of procedure S to procedure E with the use of THRU option.

EXIT Statement:

  • It happens when certain conditions exist and it is required to reach the end of the PERFORM usage or to bypass the statements in between.
  • This verb does not mean to terminate the executation rather it has no-op (no Operation). It is also called as non executable statement.
  • It is followed by a procedure name.
  • It is better to use in last procedure defined in PERFORM....THRU option.

CONDITION

The logical decisions like equality, greatness, smallness, checking of type of data i.e. alphabetic, numeric, or possitive, negetive, etc. can be done by using these statements. In this regard one conditon is to be established.

Conditon:

A condition is, in general, an expression which resposes either true or false in a particular circumstance.

Format:

data name (Relational Operator) data-name constant constant

Relational Operators:

Reserved WordsSymbols
IS LESS THAN<
IS GREATER THAN>
IS EQUAL TO=
IS GREATER THAN OR EQUAL TO>=
IS LESS THAN OR EQUAL TO<=
IS NOT EQUAL TO NOT=

Note:

The IF statement is used for examining/deciding/checking.

PROCEDURE DIVISION Page