Talk:COBOL

This is an old revision of this page, as edited by Ihope127 (talk | contribs) at 20:05, 21 July 2005. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Latest comment: 20 years ago by Ihope127 in topic COBOL makes me think of Erwin

Too little about COBOL yet

I hoped I could find some solid information on the language COBOL here. Contributors have as yet mainly concentrated on criticizing and defending COBOL, instead of first factually describing the language and its properties in detail. I find the result rather boring. Sadly, this is rather typical for many discussions on actually interesting computer subjects. --Liberatus 00:20, 7 Mar 2005 (UTC)


Current total for lines of COBOL programs

The article (based on 1981 data?) claims that little new code is being written in Cobol. A more current estimate is at 5 billion codelines a year, so perhaps it depends on the definition of "little"... (See for instance http://www.cobolwebler.com/cobolfacts.htm, citing Gartner Group as a source.) --

Question about COBOL number formats

how the heck do i decode these crazy cobol number formats? i got some data here its all '00040]' and i am thinking that means -40? or what?

>> Cobol numbers may be signed ("PIC S9999" for example). The least significant digit is "overpunched" with the sign of the number, saving a character.

    +0  {
+1 A
+2 B
+3 C
...
+9 I


    -0  } (may be used as NULL)
-1 J
-2 K
-3 L
...
-9 R


In your example, '00040}' probably indicates -400, or more likely, -4.00 (you'd have to look at the format of the number or the program logic to determine where the implied decimal is).

Claim: COBOL has no support for structured programming

As far as I understand it, Cobol does support structured programming, at least within a single program subroutines are common in all the code I've seen (and we rarely use GOTO!).

I'd also like to see a list of what Cobol does that other languages don't (or don't do as well), for example variable redefinition or subdefinition.

Cobol variable definition is closely tied to the actual memory space used by the variables (and is probably due to its heritage with punchcards).

Cobol allows the programmer to subdefine variables; this is like a C typedef.

(From memory)

10 employee-name   pic x(30)
  15 empl-fn         pic x(15)
  15 empl-mi         pic x(01)
  15 empl-ln         pic x(14)

Later in code, "move spaces to employee-name" clears all fields and subfields.

You may also redefine variables, giving a single variable more than one name.

10 business-name redefines employee-name

(another example)

 10   STD-DATE         PIC X(08)  /* YYYYMMDD, char format*/
  15  STD-DATE-CC      PIC X(02)
  15  STD-DATE-YYMMDD  PIC X(06)  /* YYMMDD, char format */
   20 STD-DATE-YY      PIC X(02)
   20 STD-DATE-MMDD    PIC X(04)

88-level values may be used to list options for flags or allowable values for variables.

10 employee-found-sw     pic x(01)
88 employee-found        value "Y"
88 employee-not-found    value "N"
10 employee-type-flag    pic x(01)
88 employee-type-standard   value "S"
88 employee-type-exempt     value "E"
88 employee-type-contractor value "C"

(later, in code:)

move employee-type-standard to employee-type-flag
if employee-type-standard ...

Dare I mention more english-like syntax (though it may perhaps be more readable to PHBs, most programmers don't seem to like it).

move 7 to days-of-the-week
if days-of-the-week=7 then next sentence.

(darn, I don't have my code here so I can't give more examples) -- Justfred


Can someone add program sample like "hello world" ?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
    DISPLAY "HELLO WORLD".
    EXIT PROGRAM.

Wikipedia naming conventions for languages

Strange use of second generation language

Where does come your use of second generation language: it is usually reserved for assembly languages. -- Hgfernan 12 May 2004

I agree. COBOL is a third generation language. other examples of third generation languages would be FORTRAN and BASIC. If someone else doesn't correct it soon I may do so. It is a clear mistake. enhandle nov 2004

Bogus lines deleted

I have been a Cobol programmer for many years in many different environments and i have NEVER seen a line like the following:

           DISPLAY " " LINE 1 POSITION 1 ERASE EOS.
           DISPLAY "Hello, world." LINE 15 POSITION 10.

If i want to display "hello word" i just write: display 'hello world'. why do people who obviously have never programmed in Cobol insist on explaining this language to others?

COBOL makes me think of Erwin

User Friendly

I want an Erwin programming language... --Ihope127 20:05, 21 July 2005 (UTC)Reply