Upload
earl-peter-g
View
356
Download
0
Embed Size (px)
Citation preview
COBOL Programming LanguagePresentation by: Earl Peter G.Email: [email protected]: http://go.earlpeter.com/COBOLPresentation
What is it all about?• It is pronounced as /ˈkoʊbɒl/ kow-bahl.• COBOL is an acronym for common business-oriented
language.• It is a compiled English-like computer programming language
designed for business use.• COBOL was widely used in legacy applications deployed on
mainframe computers, such as large-scale batch and transaction processing jobs.
• But due to its declining popularity and the retirement of experienced COBOL programmers, programs are being migrated to new platforms, rewritten in modern languages or replaced with software packages.
Quick History• COBOL was designed in 1959 by Grace Hopper.• It was created as part of a US Department of Defense effort to
create a portable programming language for data processing.• It was standardized in 1968 and has since been revised four
times. Expansions include support for structured and object-oriented programming.
• The current standard is ISO/IEC 1989:2014.
Example Compilers• COBOL12 16-bit COBOL Compiler (DOS/Windows 16bit)
http://homepages.paradise.net.nz/jsoeberg/• GNU Cobol (formerly OpenCOBOL) (Linux/Windows/OpenSolaris/MacOS 32bit)
http://sourceforge.net/projects/open-cobol/• COBOL for GCC (DOS/Windows 16bit/32bit)
http://cobolforgcc.sourceforge.net/• Tiny COBOL Compiler (Linux 16bit/32bit)
http://tiny-cobol.sourceforge.net/• Wildcat Cobol Compiler for .NET (Windows 32bit .NET Framework 2000)
http://sourceforge.net/projects/cobol/files/cobol/• Online Compiler
http://www.tutorialspoint.com/compile_cobol_online.php
Syntax• COBOL has an English-like syntax, which was designed to be
self-documenting and highly readable.It is verbose (using more words than needed) and uses over 300 reserved words.
• Example: y = x; is rather represented with: MOVE x TO y
• COBOL code is split into four divisions (identification, environment, data and procedure) containing a rigid hierarchy of sections, paragraphs and sentences.
• Lacking a large standard library, the standard specifies 43 statements, 87 functions and just one class.
• COBOL is not case sensitive
Syntax – Code FormatA condition in COBOL can be expressed as:
IS x GREATER THAN yMore complex conditions can be "abbreviated" by removing repeated conditions and variables. For example:
IS a GREATER THAN b AND a GREATER THAN c OR a EQUALS TO d
Syntax Comments• What is a programming language without comments?• Since COBOL 2002, *> was used to introduce inline comments,
similar to C’s // functionality.
Field-X Pic XX *> Used in calculating the current THINGY
MOVE ABC to XYZ *> Current-XYZ
LMN *> Saved XYZ
Example 1 – Hello World!IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY 'Hello, world'.
STOP RUN.
Example 2 – FactorialIDENTIFICATION DIVISION.PROGRAM-ID. FACTORIAL.PROCEDURE DIVISION.
factorial-value PIC 9(8) COMP. factorial-number PIC 99.
MOVE 1 TO factorial-value. *> Temporary value to hold answerPERFORM UNTIL factorial-number not greater than 1 MULTIPLY factorial-number BY factorial-value ON SIZE ERROR DISPLAY "value too big" END-MULTIPLY SUBTRACT 1 FROM factorial-number END-PERFORM
STOP RUN.
Presentation by: Earl Peter GEmail: [email protected]: http://go.earlpeter.com/COBOLPresentation
Thank you!