When to use dots in COBOL?

Philip picture Philip · Nov 6, 2012 · Viewed 8.8k times · Source

I'm completely new to COBOL, and I'm wondering:

There seems to be no difference between

DISPLAY "foo"

and

DISPLAY "foo".

What does the dot at the end of a line actually do?

When should I use/avoid it?

Answer

cschneid picture cschneid · Nov 6, 2012

The period ends the "sentence." It can have an effect on your logic. Consider...

IF A = B
    PERFORM 100-DO
    SET I-AM-DONE TO TRUE.

...and...

IF A = B
    PERFORM 100-DO.
    SET I-AM-DONE TO TRUE

The period ends the IF in both examples. In the first, the I-AM-DONE 88-level is set conditionally, in the second it is set unconditionally.

Many people prefer to use explicit scope terminators and use only a single period, often on a physical line by itself to make it stand out, to end a paragraph.