Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

wrong cobol source on the internet

Status
Not open for further replies.
Hi,

here is an example of wrong cobol source on the internet:


Identical source can be found at ZDnet.

If I try to compile it, there are errors. I am wondering which compiler will compiles that source without errors.

Besides a-margin errors, the compute should be like:
Code:
           COMPUTE CENT = (FAHR - 32) * 5 / 9.
So FAHR should be followed by a space.

One of my compilers said this:

12 IGYPS0009-E "DISPLAY" should not begin in area "A". It was processed as if found in area "B".

Same message on line: 15

13 IGYPS0009-E "ACCEPT" should not begin in area "A". It was processed as if found in area "B".

14 IGYPS0009-E "COMPUTE" should not begin in area "A". It was processed as if found in area "B".

14 IGYPS0013-E "FAHR" was a name that ended with one or more hyphens. The hyphens were discarded.

14 IGYPS2070-E Expected a right parenthesis, but found "32" in the "COMPUTE" statement. A right parenthesis was assumed
before "32".

14 IGYPS2072-S "32" was invalid. Skipped to the next verb, period or procedure-name definition.

16 IGYPS0009-E "GOBACK" should not begin in area "A". It was processed as if found in area "B".

Regards,

Crox
 
even worse: you find that in an IBM magazine....
Maybe they should try a "hello world" first, see if that is not too difficult for them.
 
These errors are likely caused by the code's having passed through a word processor sometine in the posing process. When I first began coding COBOL on a PC (for compiling on an IBM mainframe), I used WordStar. It liked to mess up my code in ways simular to the above.

Before using code obtained from any published source, on should ensure that it is formatted properly for COBOL. Many languages don't care, they ignore white space.
 
When I run the subject code through my compiler (Micro Focus v 3.5), only two errors show up 1) FAHR- ends with a hyphen, accepted as written, 2) FAHR- not defined.
 
@webrabbit:

I know about Micro Focus. It is very friendly. By default MF doesn't care about a- or b- margins, but the mainframe is not that friendly.

Also "FAHR-" not defined? So it wants to interpret "FAHR-" as a variable? But then it should also complain about the expression, which can not be valid anymore.

Fun those differences between compilers.
 
Yes, the expression is no longer valid, but, probably to avoid cascading errors, the compiler simply abandons the compilation process for that statement when it finds a fatal error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top