# COBOL for Golf - how to count characters

Yes. COBOL. I assume that the full power of a compiler implementation may be used... but, COBOL has some historical disadvantages if used for code-golf, at least for compilers which do not support various relaxations (but which in turn don't have some other stuff, gain on the swings, lose on the roundabouts).

Specifically, I want to use IBM's Enterprise COBOL compiler V4.2.

A COBOL line occupies 72 bytes in a fixed layout. http://pic.dhe.ibm.com/infocenter/pdthelp/v1r1/index.jsp?topic=%2Fcom.ibm.entcobol.doc_4.1%2FPGandLR%2Fref%2Frlfmt.htm

The first six bytes, the sequence-number area, cannot contain code. The compiler ignores these bytes (although a compiler may, optionally, check for ascending numerical sequence and issue a warning diagnostic message).

The seventh byte cannot contain code. It is called the indicator column. It can contain a comment indicator. It can contain a debug-line indicator. It can contain a "print a heading on the compiler listing now" indicator. It can contain a character used for the continuation of literals that do not fit between columns 12 and 72 (and which must be bounded by single- or double-quotes).

Area A is bytes 8-11. Area B is bytes 12-72. Some statements should only start in Area B, but the diagnostic messages can be ignored, so this is not a problem.

There is trailing physical space on a line up to and including byte 72.

Question 1.

Would it be clear that it would be OK not to count positions 1-6 and 73-80 of a COBOL source line?

Question 2.

Can the indicator column (byte seven) be ignored? I cannot contain code.

Question 3.

Can the trailing space be ignored.

Of course, if anyone is scared of being beaten at code-golf by a COBOL program, they will vote this discussion down.

I would expect to be able to beat JAVA where a reasonable golf-COBOL solution exists. Of course, I don't mind what languages I manage to beat (if any).

Here are a couple of example COBOL programs for those unfamiliar with the language. An ID DIVISION, PROGRAM-ID and PROCEDURE DIVISION are required, as are full-stops/periods after those, and at various other points.

Some may feel this is a sufficient disadvantage, without having to count 72 characters for each and every line.

COBOL has some handicaps for code-golf, anyway. I'd just like the seven leading bytes and trailing space not to be counted, if possible.

There are some COBOL examples already:

From Cereal, Generate a pronouncable word

This uses a Micro Focus compiler which does not require "the DIVISIONs" but does seem to require the seven leading characters for each line (the example can be drastically reduced in size).

From gnibbler on SO, https://stackoverflow.com/questions/2406780/code-golf-triforce/2414416#2414416

And now mine, one golfed, Happy Birthday to Me!, and two for popularity, Execute prints backwards, Bloatware contest: producing 100+ MiB executable

• Divide a into b giving c remainder r? :) – Dr. belisarius Feb 18 '14 at 21:16
• @belisarius And IDENTIFICATION DIVISION and that sort of stuff. Yes. See, for code-golf Identification can be reduced to Id :-) – Bill Woodger Feb 18 '14 at 21:23
• I think whenever someone actually does the code in COBOL, that should be an instant win! – SztupY Feb 19 '14 at 23:58
• @SztupY Well, I think there are a total of six COBOL answers already, four linked-to in the question. Can you arrange that then please? Can I take that as a vote for "yes" to all three questions? – Bill Woodger Feb 20 '14 at 0:06
• @belisarius Exactly why I hate COBOL, the only language I say that about! – CJ Dennis May 16 '15 at 9:56
• @CJDennis If you can't stand the heat, get out of the ktichen. It's not obligatory to tell people you're a bad cook, but no-one's going to stop you. – Bill Woodger May 16 '15 at 10:48

For triforce I passed -free -x to cobc.