Search code examples
cobolmainframe

Explain the use of full-stop/period/point in a paragraph


I use COBOL in my business and I originally learned at a a site using perform - thru ....

Now I have changed jobs and the local programming standards are different, so I need to get used to PERFORM without THRU.

I also have a doubt about the use of the full-stop/period/point in a paragraph.

You can use the period to end sentences within a paragraph. I say this because I read in places that the paragraph ends with the first point, and elsewhere I see full-stop/period/point used differently to that.

I wrote two structures below which I understand should be equal. Is that so?

Structure A:

       PERFORM 100-WRITING.
       PERFORM 200-FINISH.



100-WRITING.
*-----------
   DISPLAY "HI MY NAME IS FELIPE".
   DISPLAY "THE WORLD IS GREAT".
   DISPLAY "I DONT SPEAK ENGLISH".
200-FINISH.
*----------
   DISPLAY "BYE BYE BABY".
   DISPLAY "ESTO ES TODO".

Structure B:

       PERFORM 100-WRITING.
       PERFORM 200-FINISH.



100-WRITING.
*-----------
   DISPLAY "HI MY NAME IS FELIPE"
   DISPLAY "THE WORLD IS GREAT"
   DISPLAY "I DONT SPEAK ENGLISH".
200-FINISH.
*----------
   DISPLAY "BYE BYE BABY"
   DISPLAY "ESTO ES TODO".

Solution

  • You are correct, the code you show is equivalent.

    A paragraph or a SECTION must end with a full-stop/period/point. This means that the last thing (other than a comment or a blank line) in a paragraph or a SECTION must be a full-stop/period/point.

    This does not mean that a full-stop/period/point actually ends a paragraph or SECTION. You are correct, a full-stop/period/point in a paragraph ends a sentence. A paragraph or SECTION must contain sentences only. Therefore a paragraph or SECTION must end with a full-stop/period/point because a sentence must end with one.

       PERFORM 100-WRITING
       PERFORM 200-FINISH
       .
    
    100-WRITING.
    *-----------
       DISPLAY "HI MY NAME IS FELIPE"
       DISPLAY "THE WORLD IS GREAT"
       DISPLAY "I DONT SPEAK ENGLISH"
       .
    200-FINISH.
    *----------
       DISPLAY "BYE BYE BABY"
       DISPLAY "ESTO ES TODO"
       . 
    

    Since the 1985 COBOL standard, sentences are no longer really important in COBOL in the PROCEDURE DIVISION, so it is only extra work if they are made important by the coder.

    I find it much more convenient to re-write like the above. Don't attach the full-stop/period/point to anything. Just have it on in a line of its own. Then it means you can move around any of the lines in a paragraph/SECTION without worrying about whether the full-stop/period/point is in the correct place, because it is not actually attached to anything, so it never gets move around until you need it for the next paragraph/SECTION.

    However, your site coding standards may not allow you to do this. You could always attempt to get them changed for the better :-)