|
|
|
|
![]() ![]() |
Jul 8 2006, 03:39 AM
Post
#1
|
|
|
Member [ Level 2 ] Group: Members Posts: 54 Joined: 28-May 06 Member No.: 13,691 |
Dear Friends
A few days back I was looking for a COBOL compiler. Therefore I made a post here assuming that some might come to my rescue. A few help did come but wasn’t very satisfying. Eventually I found the compiler I was looking for. My compiler is Micro Focus COBOL COMPILER 2.4.12. It runs smoothly under Windows 98, Windows XP and Windows 2003 (I have personally tested it on these operating systems). When I turned to this forum for help regarding COBOL I was surprised to see that there was not even one topic written about COBOL. So I decided to write something about COBOL (though I have been learning COBOL for merely two three days). COBOL is a programming language designed for solving business problems. COBOL though solves a lot more than just business problems and can be used as a solution to many data processing problems. COBOL excels in accounting systems and related activities such as inventory control, retail sales tracking, contact management, commissions, payroll etc etc. It is like English and easy to read. This is why people with little programming knowledge tend to favor it. COBOL professionals got a real boost when Y2K problem surfaced. In old COBOL dealing with date math is even more complicated. Dates in COBOL are typically stored in three different locations (a month, a day, and a year). The year is often stored as 2 digits to save space and simplify output problems with pre-printed forms. In some cases, COBOL programs were written with 4 digit dates and 1900 is subtracted from the date to generate the form (1981 - 1900 = 81) so that the form can look like 1981 when it is generated. This will cause a problem since 2001 - 1900 = 101 instead of 01. In other cases where a 6 digit date was used, the problem is even worse since there is no clear indication of which date we are talking with. Imagine COBOL program that deals with county records to record births and deaths. If all the dates are stored as 6 digits soon you will have records which say something like 08/04/54. Let us suppose, a man live to be a hundred years old, his date of birth is recorded as 08/04/54 and if he dies on his birthday 100 years later his death would also be 08/04/54. A casual observer might interpret this as him dying at birth or who knows what. The situation is not limited to COBOL programs, but because COBOL has been the language of fondness for business applications for so long, there are vastly more COBOL programs in existence. The importance of the year 2000 catastrophe has caused knowledgeable software experts to forecast horrible consequences. It is estimated that the cost of fixing the crisis will run into the billions of dollars. The demand for COBOL programmers increases more or less weekly, as more and more companies understand the scope of the year 2000 problem and begin to apportion resources for its solution. COBOL stands for Common Business Oriented Language. COBOL was developed by the Conference on Data Systems Languages (CODASYL), convened in 1959 by the Department of Defense. COBOL compilers were available in 1960. The American National Standards Institute (ANSI) standardized a version of COBOL in 1968. The language was revised and updated by ANSI in 1974 and again in 1985. These standards sometimes are called COBOL or COBOL-68, COBOL-74, or COBOL-85. Most compilers are now COBOL-85 standard. Some of the advantages of COBOL are that it caters well for business needs and is easily portable to different operating systems or platforms. However, the language is considered to be rather wordy with an overly rigid format. A further disadvantage is that COBOL lacks many of the programming instructions required by the scientific community. Let’s write our first COBOL program. As you might have started learning many languages by printing “HELLO WORLD” in the screen, this is no exception. We shall write a program which would print “HELLO WORLD”. Type the following codes in any text editor, say for example NOTEPAD. 000100 IDENTIFICATION DIVISION. 000200 PROGRAM-ID. HELLO. 000300 ENVIRONMENT DIVISION. 000400 DATA DIVISION. 000500 PROCEDURE DIVISION. 000600 000700 PROGRAM-BEGIN. 000800 DISPLAY "HELLO WORLD". 000900 001000 PROGRAM-DONE. 001100 STOP RUN. Save the file. Name the file HELLO.COB. Select “ALLFILES” in Save as type Field. I am assuming that you have Micro Focus Compiler, though the process is similar in all compilers. Create the Directory Called cob1 in C Drive (As I have done) and place the hello.cob file in that directory. Now run the COBOL compiler. It is usually done by changing directory. C:\>cd cobol C:\Cobol> Now give COBOL command and as the following. C:\Cobol>cobol Microsoft COBOL Compiler Version 2.20 ©Copyright Microsoft Corp. 1982-87 Source filename [.COB]: c:\cob1\hello.cob Object filename [HELLO.INT]: c:\cob1\hello.int Listing filename [NUL.LST]: c:\cob1\hello.lst ** Scanning Environment Division... ** Scanning Data Division... ** Compiling Procedure Division... ** Generating Object Code... No errors or warnings Data area size = 232 Code area size = 38 ------------------------------------------------------------------------------------------------------- Now Run the program using “runcob” command C:\Cobol>runcob c:\cob1\hello It will produce the following output HELLO WORLD. I hope you would like this article. If anybody is interested to learn COBOL please write to me and if some one is an expert please do help me in learning COBOL. Thank you all for your time. Bye.. |
|
|
|
Jul 8 2006, 11:54 AM
Post
#2
|
|
|
Hedonist at large Group: Members Posts: 610 Joined: 30-July 05 From: another realm Member No.: 7,524 |
I learnt COBOL in an institute about 8 years ago when I was in the 9th standard
But, is there any application for COBOL now? I mean this generation of programming languages are obsolete now. You can code more easily and efficiently in C or C++. Besides, the formatting for COBOL is so rigid that it takes quite a while to debug big programs. |
|
|
|
Jul 8 2006, 01:21 PM
Post
#3
|
|
|
Way Out Of Control - You need a life :) Group: [MODERATOR] Posts: 1,919 Joined: 16-August 05 Member No.: 7,896 |
QUOTE My compiler is Micro Focus COBOL COMPILER 2.4.12. Your first question seemed to be about a free Cobol compiler. Micro-Focus is the king of Cobol compilers (until being bought by Merant) but I don't think that their compiler is free. Is it ? |
|
|
|
Jul 8 2006, 01:38 PM
Post
#4
|
|
|
Member [ Level 2 ] Group: Members Posts: 54 Joined: 28-May 06 Member No.: 13,691 |
Yes, you are absolutely right. It’s not at all free. A friend of mine gave me this compiler and I can tell you it a very good one. I would like everybody with knowledge of COBOL to contribute here and I would like to request the moderators to open a new forum for COBOL like there are for other programming language. COBOL might not have any role in today’s world but it was a very effective tool and it will help young ones to know about a very good programming language. Bye.
|
|
|
|
Jul 8 2006, 10:33 PM
Post
#5
|
|
|
Way Out Of Control - You need a life :) Group: [MODERATOR] Posts: 1,919 Joined: 16-August 05 Member No.: 7,896 |
QUOTE But, is there any application for COBOL now? Of course, most of the real life current applications (payrolls, banking applications) are still Cobol applications written some tens of years ago. So, most of companies have to continue using them, it would cost too much if they wanted to convert them to C++. QUOTE I would like to request the moderators to open a new forum for COBOL like there are for other programming language. Great idea ! However, before requesting this, I would like to suggest you to simply start another post with a poll : what programming language are you currently using, or are you planning to use ? - cobol - C, C++ - Fortran - Basic - Java ? There are already some such polls, but without Cobol. I am sure if you startup such a poll, you will see that almost nobody is currently writing in Cobol. I'm pretty sure more than 99% people will talk about other languages. And that's why there will probably be no Cobol special forum. Because cobol will probably stay as one of these old goodies, still useful, but not so wanted for future applicatons. |
|
|
|
Jul 28 2006, 05:01 AM
Post
#6
|
|
|
Member [ Level 2 ] Group: Members Posts: 54 Joined: 28-May 06 Member No.: 13,691 |
Dear Friends
Last time around I wrote a program named Hello World using COBOL. Today I will try to analyze the program. So I will rewrite the program for your convenience. 000100 IDENTIFICATION DIVISION. 000200 PROGRAM-ID. HELLO. 000300 ENVIRONMENT DIVISION. 000400 DATA DIVISION. 000500 PROCEDURE DIVISION. 000600 000700 PROGRAM-BEGIN. 000800 DISPLAY "Hello world". 000900 001000 PROGRAM-DONE. 001100 STOP RUN. A COBOL program always has four divisions and these four divisions are always having the same names: i) IDENTIFICATION DIVISION ii) ENVIRONMENT DIVISION iii) DATA DIVISION iv) PROCEDURE DIVISION In Hello World program, lines 000100 and 000200 are the IDENTIFICATION DIVISION. This division is used to mark the basic information about the program. In this program, the IDENTIFICATION DIVISION contains only the PROGRAM-ID, HELLO. Line 000300 is the ENVIRONMENT DIVISION, which is used to identify the environment in which the program is running. Keep in mind that COBOL is intended to run on many unlike types of machines, and this section is used to handle the differences between various computers. In this case, the program has no specialized machine necessities, so the ENVIRONMENT DIVISION is empty. Line 000400 is the DATA DIVISION, which will contain any data that the program operates on. This program has no data, so the DATA DIVISION is empty. Lines 000500 through 001100 are the PROCEDURE DIVISION. This is the meat of the program--the part that does the work planned by the programmer. The PROCEDURE DIVISION contains two paragraphs at line 000700 (PROGRAM-BEGIN) and line 001000 (PROGRAM-DONE). The term paragraph has a special definition in COBOL that will be covered a bit later in today's lesson. All the actual work in this program is done by line 000800. |
|
|
|
Jul 28 2006, 12:15 PM
Post
#7
|
|
|
Way Out Of Control - You need a life :) Group: [MODERATOR] Posts: 1,919 Joined: 16-August 05 Member No.: 7,896 |
QUOTE Line 000400 is the DATA DIVISION, Are the line numbers mandatory ? Or are these numbers here only for convenience ? I remember old Fortran programs had a line number field, which was often left to blank. |
|
|
|
Apr 11 2008, 04:51 PM
Post
#8
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 0 Joined: 1-November 07 Member No.: 25,869 |
Programmer
An Introduction To COBOL I am a one time COBOL programmer using MF COBOL version 2.5.60. For a long time I had batch files created to create int, gnt, or exe files. I had to reconstruct my machine a couple of months back and ever since I copied the COBOL compiler back over, after the OS reload, I have been unable to create an int file. It always creates a gnt file no matter what command line info I provide. I really need to be able to create the int files so I can utilize the Animator. I beleive my problem involves the pathing or environment variable(s) that I had to replace from memory. Any help would be greatly appreciated. -question by TonyM |
|
|
|
Jun 3 2008, 06:49 AM
Post
#9
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 0 Joined: 1-November 07 Member No.: 25,869 |
how to link the data file in program
An Introduction To COBOL ============================================================= FILE-CONTROL. SELECT PHONE-FILE ASSIGN TO "phone.Dat" ORGANIZATION IS SEQUENTIAL. ============================================================= Dear friends as shown in above syntax as I am using this syntax in my program to select the dat file. The compiler is giving error in these line I think compiler is unable to link the data file Please help me on this? -reply by vishal choudhary |
|
|
|
Jul 8 2008, 06:19 AM
Post
#10
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 0 Joined: 1-November 07 Member No.: 25,869 |
Differences b/w cobol and microfocus cobol?
An Introduction To COBOL Can someone tell me the major differences between cobol and microfocus cobol? |
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 24th July 2008 - 12:02 PM |