Custom Search

What Is a Shell Program,COBOL program requirements.

What Is a Shell Program?

Because COBOL has a certain minimum amount of code that is required for all programs, it is a good practice to maintain a COBOL program that contains the minimum requirements.

New Term: A COBOL program that contains the minimum requirements usually is called a shell program, a skeleton program, or a boilerplate program.

If you copy this shell program to a new file before you start editing the new program, you can save yourself extra typing. Listing 1.6, cobshl01.cbl, is your first version of the COBOL shell program. As you progress through the days, you'll gradually add more and more pieces to the shell; eventually, you'll have a complete shell to use in all projects.

TYPE: Listing 1.6. Your first version of a COBOL shell.

000100 IDENTIFICATION DIVISION.

000200 PROGRAM-ID. COBSHL01.

000300 ENVIRONMENT DIVISION.

000400 DATA DIVISION.

000500 PROCEDURE DIVISION.

000600 PROGRAM-BEGIN.

000700

000800 PROGRAM-DONE.

000900 STOP RUN.

Type Listing 1.6 and compile it to ensure that everything in it is correct. You will use this shell, and versions of it, many times before you are through with these lessons.

As you will see in the next few days, PC-based COBOL compilers are much less stringent about following the rules described in today's lesson. However, COBOL is intended to be a portable language that allows code to be moved to other computers. Another computer probably will be using another COBOL compiler that might require compliance to all the strict rules of COBOL. When you start breaking the rules, you limit your code to a compiler that can handle the loose syntax, and this might make it extremely difficult to move your code to another machine or compiler.

Summary

Today's lesson introduced you to some computer and programming basics, including the following:

· A computer processes numbers and is made up of a central processing unit, input devices, output devices, main memory, and secondary storage.

· A computer can't do anything without a program.

· A program is a series of instructions that the central processing unit executes to process data, usually using some input data and providing some sort of output.

· A programming language is a method of writing a source code file in an English-like language that a human being can understand.

· A compiler translates the source code file into instructions that the central processing unit can understand and execute.

· A COBOL program contains four DIVISIONs: the IDENTIFICATION DIVISION, the ENVIRONMENT DIVISION, the DATA DIVISION, and the PROCEDURE DIVISION.

· A DIVISION can be broken down into paragraphs. Some divisions have required paragraphs, such as the PROGRAM-ID paragraph in the IDENTIFICATION DIVISION.

· The names of the paragraphs in the PROCEDURE DIVISION are assigned by the programmer.

· The work of a COBOL program is done in sentences that contain the commands of a program and appear within a paragraph.

· A COBOL program is written in 80-column format. The columns are divided into the following areas:

· Columns 1 through 6 are the sequence area and can be used by the programmer for line numbering. Line numbering is optional.

· Column 7 is the indicator area. An asterisk (*) in column 7 causes everything to the right of the asterisk to be treated as a comment.

· Columns 8 through 11 are Area A, and columns 12 through 72 are Area B. DIVISION names, SECTION names, and paragraph names must begin in Area A, but they can extend into Area B. Sentences begin and end in Area B.

· Columns 73 through 80 are undefined and are not processed by the COBOL compiler, but some COBOL editors use these columns to tag lines with modification codes.

Today, you also learned how to type, compile, and run several simple COBOL programs.