COBOL - en ANGLAIS

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 62

ISPF = éditeur de texte

*********************************
Transcription

Start of Tutorial.

here's a quick overview of what will be

covered in this lesson

first we will go over what cobalt is

then we will go over cobalt's format

followed by cobalt structure

next we will install the vs code cobalt

extension

followed by the gnu cobalt compilers

installation

finally we will end this lesson with a

hello world program

What is COBOL?

cobalt stands for common business

oriented language

and the first release of cobalt was back

in 1959

so cobalt has been around for over 60

years

even though cobalt is one of the first

computer languages it is still in use

today

cobalt's primary use is for business

applications

so some examples of cobalt applications

include things like hr payroll and

banking applications

also it's a relatively simple

programming language and is inherently

self-documenting
however this comes at the cost of making

the language more verbose

COBOL Format.

cobalt programs must adhere to a

specific format

this format requires that particular

information be located in specific

columns of the code

this figure shows the five areas that

make up cobalt code

columns one through six make up the

sequence number area

this area is used to give each line of

code a sequence of numbers

in the past this was used primarily when

programmers used to feed stacks of punch

cards

into a computer when loading their

programs

numbering the lines of code would allow

the programmer to figure out the correct

card order if the cards were ever

dropped

the seventh column is referred to as the

indicator area

and this is primarily used to declare

comments and a debugging line

it can also be used for a continuation

of lines but this is rarely used

columns 8 through 11 are referred to as

area a
there are several items that must begin

in area a they include things such as

the division

section and paragraph headers columns 12

through 72 are referred to as area b

area b contains entries sentences

statements and clauses

finally columns 73 through 80 are known

as the identification

or comment area and this area was used

to identify a program in case more than

one stack of cards were mixed together

COBOL Structure

this is the hierarchical structure of a

cobalt program

at the lowest level there are statements

statements start with verbs and verbs

show an action

a few examples of verbs would be

initialize move

set search and add you can use these

verbs with an

operand which is the data that is to be

operated on by the verb

and make a statement sentences are at

the next level and they contain one or

more statements

and end with a period paragraphs are

made up of one or more sentences

paragraphs can be used as modules that

are called by other modules


if you need a block of code that can be

used several times during the execution

of your program then use a paragraph

sections contain paragraphs and sections

give the program structure

and may actually be necessary to include

so the information that the program

needs is stored within the section

finally at the top there are divisions

there are a total of four divisions

first there's the identification

division the name of the author the name

of the program what the program does all

goes here

then there's the environment division

this division describes the system that

the program will run on along with an

input output section that is used to

link the names used in the program to

the external file names on a disk

next there's the data division this is a

place that is used to describe the data

that will be used in the program

in addition to storage and memory that

will be used

finally there's the procedure division

the program's processing occurs here by

writing instructions on how to take

data in and manipulate that data

now let's install the visual studio code

Visual Studio Code: COBOL Extension Installation.


cobol extension

open vs code and click on the extensions

icon type in cobol

click on the first link and click

install

you now have installed the vs code

cobalt extension

GnuCOBOL Installation for MacOS Catalina.

let's install gnu cobol for mac os

catalina

you will first need to install homebrew

by going to brew.sh

copy this line

and then paste it into a terminal

press enter type in your password

press return

now type brew install gnu

hyphen cobalt

you can check the installation by typing

cob

space hyphen x and you should get the

error that there are no input files

GnuCOBOL Installation for Windows.

let's install gnu cobalt for windows 10.

we'll first install 7zip which will

allow us to extract the gnu cobalt file

go to the download link and download the

file that's appropriate to your windows

version

after the files finish downloading

double-click the file to begin the


installation process

then click the install button

next we're going to search google for

gnu cobol

go ahead and click on the first link

then click the download button

after the file's finished downloading go

ahead and extract the file

now go ahead and copy and paste the

folder into the directory of your choice

in this case i chose the root directory

now we can open the gnu cobalt folder

and scroll down to the readme file

which will give us the installation

instructions

now we want to use google to search for

sigwin

go to the install cygwin link

download the installation file

after the files finished downloading go

ahead and start the installation

when it gets to the screen during the

installation process change the view to

full

we want to first search for lib gmp

click in the new column so that these

packages will be installed

next search for libdb

click in the new column to install these

packages

next search for n curses


now click in the new column so that

these packages will be installed

now search for gcc

now click inside the new column in order

to install the following packages

now search for make now click inside the

new column

to install the following automake cmake

and make

packages

then click next click next to continue

to install

cygwin and install the packages

click next and then finish

now open sigwin

now go to the directory where the gnu

cobalt folder is located

go inside the folder

type dot forward slash configure and

press

enter to begin the configuration process

now type make and press enter

to make sure that the make process

worked correctly we can run a series of

tests by typing make

check and then press enter

please note that running these tests do

take a while

you can run a series of cobalt 85

optional tests by typing make test

however this test may fail because the


test file is missing

you can see more detail if you go to the

tests cobalt 85

folder and the readme file

you can copy and paste this link into

your address bar in your browser

and go to this website

and then download the test file

after the files downloaded you can go

ahead and extract it

and then copy and then paste the file

in the cobol 85 test directory

now go back to sigwin and type make test

and press enter and the tests will begin

to run

note that these tests do take a while

you can check the results of the test by

going to the cobalt 85 test directory

and going to the summary file

opening that file and you can see the

results

now that we ran all the tests we can go

ahead and install gnu cobol

by typing make install and pressing

enter

you can check the installation by typing

cobc

space hyphen x and pressing enter

you should see the no input files error

next we want to check the gnu cobalt

directory
in order for gnu cobalt to work

correctly with windows powershell we

will have to add some directories to our

path

type path into the search go into the

environmental variables

edit the path

go to cygwin forward slash bin and copy

the location

click new and paste that location into

the path

press ok

now go to cygwin user local

bin and copy that location

press new and paste that location into

the path

press ok press ok

and press ok again

now we can see if everything's set up

correctly by going into vs code and

opening up a terminal

and typing c o b c space

hyphen x pressing enter and you should

see an error that says no input files

let's install gnu cobalt for umbuntu

GnuCOBOL Installation for Ubuntu.

20.04

lts

up a terminal and type sudo apt-get

install

gnu cobalt and press enter


type y and press enter

you can check the installation by going

to vs code opening up a terminal

and typing cobc space hyphen

x pressing enter and you should see the

error that says

no input files

now let's code our first program hello

COBOL Program: Hello World Program

world

first make a file named hello dot

cbl

let's start the program with a comment

by placing an asterisk

in column 7 and typing hello world as

the comment

next we will go to column 8 in area a

and add the identification division

which is required for any cobalt program

and must have a period after the word

division

next we will add the program id

paragraph starting in column 8 and area

this is the only required line of code

in the identification division

there must be a period following the

program id

and it must be followed by the name of

the program in this case hello

underscore world
with a period at the end of the program

name

now we will add the procedure division

again starting in column 8

in area a there must be a period after

the word division

next we will add a statement with the

action display to column 12

and area b and then type the words and

characters that we want displayed on the

screen

in this case we will type hello comma

world exclamation point to the end of

the statement and at a period

finally to stop the execution of the

program we will add the stop run

statement ending with a period

now we need to compile the program so go

to the terminal and type

cobc space hyphen x

followed by the name of the program in

this case hello.clb

and press enter

this creates a file named hello.exe to

run this file type

dot forward slash hello and press enter

you should now see the results hello

world printed on the display

thank you for watching if you consider

this lesson to be helpful

please consider subscribing to the


channel i look forward to our next

lesson

and i hope you all have a wonderful day

You might also like