Encyclopedia > Talk:COBOL programming language

  Article Content

Talk:COBOL

Redirected from Talk:COBOL programming language

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).

================ 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" ?




All Wikipedia text is available under the terms of the GNU Free Documentation License

 
  Search Encyclopedia

Search over one million articles, find something about almost anything!
 
 
  
  Featured Article
East Farmingdale, New York

... The population density is 387.5/km² (1,003.8/mi²). There are 1,723 housing units at an average density of 123.7/km² (320.3/mi²). The racial makeup ...

 
 
 
This page was created in 47.3 ms