1 / 23

COBOL

COBOL. CO mmon B usiness O riented L anguage Work began in 1959 and has never stopped. CODASYL. Conference on Data Systems Languages Primarily Business Wanted a language designed for their needs. The resulting language reflected business needs and the computing environment.

phuc
Télécharger la présentation

COBOL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COBOL COmmon Business Oriented Language • Work began in 1959 and has never stopped

  2. CODASYL • Conference on Data Systems Languages • Primarily Business • Wanted a language designed for their needs. • The resulting language reflected business needs and the computing environment.

  3. File Formatting • You can read to or from records specifying precision by digit. • While it is different than what we are used to, it is as powerful as newer languages for records.

  4. Records • COBOL understands the idea of a record • Has incorporated support for composite and atomic attributes from the beginning • This understanding avoids some of the more tedious aspects of programming with records by minimizing parsing.

  5. Computing Environment • Words and Bytes: Many assumptions we make every day the COBOL programmer could not rely on. • Environment Division: Specifies to the compiler and programmer the target environments. • More or less just comments now, useful for maintenance.

  6. PunchCard

  7. Changes with Time • Certainly the most difficult part of COBOL is that all new versions must be backwards compatible. • It is possible to get nearly 817 keywords (ca.1985)

  8. Artifacts • Program line numbers for program cards • Spacing (Areas A & B) • While not as familiar or as “clean” as {} block structures, it does add a visual structure to a program

  9. Divisions and Sections • Sections subdivide four primary divisions • Provides a top level organization for programs. More later.

  10. Procedural Paradigm • Supported but not enforced • Centers mostly on GOTO (and in newer versions, IF/THEN) All procedures names are labels. • Newer versions support some OO features.

  11. IDENTIFICATION DIVISION ENVIRONMENT DIVISION DATA DIVISION PROCEDURE DIVISION FOUR PROGRAM DIVISIONS

  12. IDENTIFICATION DIVISION • Provides the name of the program, who wrote it, when and where it was written, when it was compiled, and what security precautions(if any) should be taken to restrict access to the program or to the file it processes. Division should end with a set of English sentences giving a brief overview of what the program does.

  13. ENVIRONMENT DIVISION • Contains information about the computer(s) on which the COBOL program will be compiled and on which the resulting machine-language program will be run. It also gives a COBOL name to each file to be processed and assigns each file to a specified I/O device. This information defines the hardware environment in which programs runs.

  14. DATA DIVISION • Gives a brief description of each file to be processed, and then gives a detailed layout for the records in the file. Each field in a record is described in terms of its length and its type of data. The DATA DIVISION also describes in a memory area called WORKING-STORAGE. All data fields(in file records or in working-storage) must be described in the DATA DIVISION.

  15. PROCEDURE DIVISION • The computer is actually instructed as to what processing is to be carried out. The directions closely resemble English sentences.

  16. SIMPLE SAMPLE PROGRAM 000100 IDENTIFICATION DIVISION. 000200 PROGRAM-ID. HELLOWORLD. 000300 000400 ENVIRONMENT DIVISION. 000500 CONFIGURATION SECTION. 000600 SOURCE-COMPUTER. RM-COBOL. 000700 OBJECT-COMPUTER. RM-COBOL. 000800 000900 DATA DIVISION. 001000 FILE SECTION. 001100 101200 PROCEDURE DIVISION. 101300 101400 MAIN-LOGIC SECTION. 101500 DISPLAY “HELLO WORLD!” 101600 STOP RUN.

  17. SAMPLE PROGRAM “ACCEPT_NUM” 000100 ID DIVISION. 000200 PROGRAM-ID. ACCEPT1. 000300 DATA DIVISION. 000400 WORKING-STORAGE SECTION. 000500 01 WS-FIRST-NUMBER PIC 9(3). 000600 01 WS-SECOND-NUMBER PIC 9(3). 000700 01 WS-TOTAL PIC ZZZ9.

  18. SAMPLE PROGRAM “ACCEPT_NUM” 000100 ID DIVISION. 000200 PROGRAM-ID. ACCEPT1. 000300 DATA DIVISION. 000400 WORKING-STORAGE SECTION. 000500 01 WS-FIRST-NUMBER PIC 9(3). 000600 01 WS-SECOND-NUMBER PIC 9(3). 000700 01 WS-TOTAL PIC ZZZ9.

  19. SAMPLE PROGRAM “ACCEPT_NUM” 000900 PROCEDURE DIVISION. 001000 0000-MAINLINE. 001100 DISPLAY 'ENTER A NUMBER: '. 001200 ACCEPT WS-FIRST-NUMBER. 001300* 001400 DISPLAY 'ANOTHER NUMBER: '. 001500 ACCEPT WS-SECOND-NUMBER. 001600* 001700 COMPUTE WS-TOTAL = WS-FIRST-NUMBER + WS-SECOND-NUMBER. 001800 DISPLAY 'THE TOTAL IS: ', WS-TOTAL. 001900 STOP RUN.

  20. SAMPLE PROGRAM “ACCEPT_NUM SAMPLE RUN” ENTER A NUMBER: 7 ANOTHER NUMBER: 7 THE TOTAL IS: 14

  21. COMPARED TO OTHER LANGUAGES “ THE GOOD SIDE” • Self-Documenting • Reserved Words Based on English • Readability • Easy to learn • Business Oriented • Non-proprietary(portable)

  22. COMPARED TO OTHER LANGUAGES “ THE BAD SIDE" • No encapsulation and little information hiding • No block structure • All variables are global • Numbers closer to human arithmetic • No recursion • Not designed for graphical user environment • Only best for business applications

  23. SOURCES • http://www.engin.umd.umich.edu/CIS/course.des/cis400/cobol/seccob.html • Newcomer, Lawrence R.. Theory and Problems of Programming with Structured COBOL.McGraw-Hill, Inc. 1984. • http://www.fourmilab.ch/documents/univac/cards.html

More Related