-----------------------------------------------------------------------------------------------------------
Program --     is a set of instructions that tell a computer how to process data.

                    A program requires a description of data and what is to be done to the data.

-----------------------------------------------------------------------------------------------------------
Machine language programs (also called load modules)
    are a series of 1's and 0's with meaning to the computer
    can be executed by a computer
    are very difficult for most people to ready or write.

-----------------------------------------------------------------------------------------------------------
Symbolic programs
    look related to English and math
    are more intelligible for people to write and read
    are very difficult for machines to read and execute
    are the source code for executable machine programs (load modules)

-----------------------------------------------------------------------------------------------------------
Two steps and two different programs are needed to translate symbolic programs into executable machine
programs -- a Compiler and Linker.

-----------------------------------------------------------------------------------------------------------
Compiler

Translates a symbolic program to machine language -- object program.
The object program is incomplete and needs other programs to make it complete -- such as system routines.

-----------------------------------------------------------------------------------------------------------
Linker

A program that unites other programs (object and/or load modules) into one executable program -- load module.

-----------------------------------------------------------------------------------------------------------
PROGRAM DEVELOPMENT PROCESS

1)  Specify -- determine the problem and what program is to do
2)  Plan   -- solve the problem logically before coding
3)  Code  -- translate the logical solution into symbolic code
4)  Test   -- verify that the program executes correctly
5)  Document -- write procedure manuals for users and operators
-----------------------------------------------------------------------------------------------------------

Four Divisions of a COBOL program

IDENTIFICATION DIVISION

        Contains some program documentation.

        PROGRAM-ID.   --   Identifies the program to the computer system.
        AUTHOR               --   person who wrote the program
 

ENVIRONMENT DIVISION

        Assigns a filename for each file used in the program and specifies the device that the file will use.

        DATA DIVISION

        Contains the format of all input, output and work areas used by the program.

        FILE SECTION. -- a description of each file.

        Files contain records and each record contains one or more fields of information.

        WORKING-STORAGE SECTION.  -- work areas needed for processing
 

PROCEDURE DIVISION

        Contains Instructions required to process input and produce produce output.

        All instructions are executed in sequence

 -----------------------------------------------------------------------------------------------------------
COBOL Coding  format

Columns                  Usage

1-6                           line number sequence - optional

                                (Automatically updated by the computer when using ISPF)

7                               *          for comment line
                                  /          Page-eject
                                 -          Continue non-numeric literal from previous line
                                 Blank

8-11.                         Area A

                                  Some program statements start within this region
                                  (typically label names for DIVISIONS, SECTIONS and paragraphs)
                                  Statements which began in Area A may extend into Area B

12-72                        Area B

                                 All other program statements.

73-80                        Optional program identification or comment area.

-------------------------------------------------------------------------------------------
RULES FOR FORMING USER-DEFINED WORDS

1)     1 to 30 characters
2)     Letters, digits and hyphens (-) only.
3)     No embedded blanks
4)     At least one alphabetic character
5)     Do not began or end with a hyphen

-----------------------------------------------------------------------------------------------------------

COBOL Procedure statement verbs introduced in program #1.

        DISPLAY, PERFORM, STOP RUN.

 -----------------------------------------------------------------------------------------------------------
DISPLAY Statement

Used for small amounts of output such as error messages, warnings, the contents of program variables for debugging purposes, short comments, etc.

Not used for creating reports or output of large amounts of data.
-----------------------------------------------------------------------------------------------------------
Format of the DISPLAY statement

DISPLAY {identifier } ...  [UPON mnemonic-name] [WITH NO ADVANCING]
                 {literal      }

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Braces              {   }  one of the enclosed items is required.
Brackets           [   ]  the clause or paragraph is optional.
Ellipsis              (...)  additional entries of the same type may be included.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Identifier is the name of a field in the data division.
Literal could be numeric or nonnumeric or alphanumeric

Numeric literals are       Nonnumeric literals are
   1 to 18 digits                  1 to 160 characters
   Decimal point optional    Any characters may be used
   Sign optional                  Delimited by single quotes ( '  )

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DISPLAY Clause  [UPON mnemonic-name]

This optional clause specifies where the output will print.
On a mainframe the clause "UPON CONSOLE" will direct output to the master terminal.

If not specified, DISPLAY output goes to the JCL statement //SYSOUT.

Do not use this clause for programming assignments on the DePaul mainframe.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DISPLAY Clause   [WITH NO ADVANCING]

This optional clause will force the output of the next DISPLAY to print on the same line as the previous DISPLAY.
-----------------------------------------------------------------------------------------------------------
PERFORM Statement (out-of-line)

Out-of-line PERFORM statements transfer control to the first executable statement in a procedure referenced.

When the last statement of the PERFORM'ed procedure is complete,
control returns to the statement immediately following the PERFORM.

-----------------------------------------------------------------------------------------------------------
Format for the PERFORM statements used in program #1.

PERFORM proc-name-1 [ THRU proc-name-2 ]  [  {identifier          }   TIMES ]
                                                                                  {numeric literal }

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
proc-name-1 is the label of the procedure that will receive control.

PERFORM Clause   [ THRU proc-name-2 ]

This optional clause specifies that proc-name-1 and all the procedures that are between proc-name-1 and proc-name-2 will receive control.  proc-name-1 should physically precede proc-name-2 in the source listing.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

PERFORM Clause   [  {identifier }  TIMES ]
                                   [  {numeric  }                 ]
 
This optional clause controls how often the referenced procedure is repeated.
A change in the value of the identifier during execution of the referenced procedures will not affect the number of iterations.

-----------------------------------------------------------------------------------------------------------

STOP RUN

 The STOP RUN statement terminates program execution.

-----------------------------------------------------------------------------------------------------------