Statement Categories
All COBOL statements are divided into four categories based on their actions, and they are -
- Imperative Statements
- Conditional Statements
- Delimited scope statements
- Compiler-directing statements
Imperative Statements -
An Imperative Statement is a procedural instruction specifying an action to be taken during the program's execution. It provides the step-by-step process that the program should follow.
For Example - ACCEPT, MOVE, INSPECT, STRING, UNSTRING, and all statements without ERROR and EXCEPTION phases.
Conditional Statements -
A Conditional statement tests a condition and then executes one or more statements based on the result of that condition. It allows a program to choose the execution flow between different paths based on the truth value (TRUE or FALSE) of a condition or set of conditions.
For example - IF, EVALUATE, SEARCH, and all statements with ERROR and EXCEPTION phases.
Delimited scope statements -
Delimited Scope Statement marks the statement ending by specific keywords. This type of statement improves the readability and structure of programs by providing a clear scope of where a particular logic ends.
Explicit Scope terminators -
Explicit scope terminators mark the end of a statement or block of code. They are not common and are specific only to the statement. For example - END-IF, END-CALL, END-COMPUTE, etc.
Implicit Scope terminators -
Implicit scope terminator (.) is used to end the statement implicitly and is used to terminate all statements. For example - Period (.).
Compiler-directive statements -
Compiler-directive statements provide instructions to the compiler about how to compile the source program. They don't impact the program exexution but instead it affect the compilation process.
For example - COPY, EJECT, SKIP, etc.