Re: newbie question on cobol syntax



Mayer wrote:
Hello:

I noticed two styles of cobol syntax:

main.
display "hello"
display "goodbye"
stop run
.

vs.

main.
display "hello".
display "goodbye".
stop run.

Some books use the first, others the second. I have no idea what's the
difference between them, but I note the following:

- MF Cobol/DOS allows both

- RM Cobol/DOS allows only the second, i.e., requires a period at the
end of each statement.

Can someone please explain to me the function of the period in cobol,
what is the basis for the difference in syntax, and what is
recommended.

Thanks,

Mayer

Well first off - if you can, avoid using both compilers - you will get
yourself in one hell of a mess :-)

Are you sure about RM/COBOL being adamant about periods/full-stops, or
is it perhaps what you interpreted ? The following extract from a very
old RM compiler, Version 2 and no longer supported :-

--------------------------------------------------------------------------

B040-ENTER-ID.

ACCEPT WS-SCREEN-PROGRAM, POSITION 40, LINE 15,
PROMPT "-", ECHO, CONVERT, REVERSE, NO BEEP
ACCEPT WS-SCREEN-PAGE, POSITION 43, LINE 15,
PROMPT "-", ECHO, CONVERT, REVERSE, NO BEEP

IF WS-SCREEN-PROGRAM = ZEROES
MOVE "Are you sure - Program Zero ? y/n"
TO WS-INSTRUCTION-TEXT
MOVE SPACES TO WS-INSTRUCTION-EXIT
PERFORM Z040-INSTRUCTION-LINE
PERFORM Z025-ANSWER

IF WS-ANSWER = "N"
GO TO B040-ENTER-ID.

IF WS-SCREEN-PAGE = ZEROES
MOVE "Screen ID can't be zeroes"
TO WS-ERROR-MESSAGE-TEXT
PERFORM Z050-ERROR-MESSAGE
GO TO B040-ENTER-ID.

IF WS-SELECTION NOT = 2
MOVE ZEROES TO WS-LINE-ID

ELSE PERFORM B050-LINE-ID.

B050-LINE-ID.

ACCEPT WS-LINE-ID, POSITION 45, LINE 15,
PROMPT "-", ECHO, CONVERT, REVERSE, NO BEEP

IF WS-LINE-ID = ZEROES
MOVE "Line ID can't be zeroes"
TO WS-ERROR-MESSAGE-TEXT
PERFORM Z050-ERROR-MESSAGE
GO TO B050-LINE-ID.

C010-RECORD.

IF WS-SELECTION = 1
MOVE 3 TO WS-NUMBER-OF-QUESTION
PERFORM C020-DISPLAY-SCREEN
PERFORM C030-READ-RECORD

ELSE MOVE 4 TO WS-NUMBER-OF-QUESTION
PERFORM D020-DISPLAY-SCREEN
PERFORM C030-READ-RECORD.

IF WS-RECORD-EXISTS = "Y"

IF WS-SELECTION = 1
PERFORM C040-DISPLAY-VALUES

ELSE PERFORM D040-DISPLAY-VALUES.

IF WS-RECORD-EXISTS = "N"
MOVE
"No record - do you want to input ? y/n"
TO WS-INSTRUCTION-TEXT
MOVE SPACES TO WS-INSTRUCTION-EXIT
PERFORM Z040-INSTRUCTION-LINE
PERFORM Z025-ANSWER

IF WS-ANSWER = "Y"
PERFORM C060-ENTER-NEW-DATA

ELSE GO TO C010-EXIT.

PERFORM C070-LINE-NUMBER THROUGH C070-EXIT.

000000 C010-EXIT.
EXIT.
---------------------------------------------------------------------------------------

If you look at the above code your compiler should certainly hiccup if
you leave out the very last period/full-stop before the next paragraph
name. If you have perform PARAGRAPH-NAME-A and the para-name isn't
preceded by a period, you should get an error like "Invalid Paragraph Name".

I tried searching the latest version of Net Express for "period", "full
stop" - no luck. Familiarize yourself with END SCOPE Terminators - which
weren't around when I wrote the above code.

In written English we finalize our thoughts by putting a period at the
end of a sentence. We group a series of like sentences into a paragraph
and terminate that with a CR/LF(Carriage-Return, Line Feed), have a
blank line and start a new paragraph on the next line.

Translate that to COBOL - using Scope Terminators, mainly you only need
a period preceding the next 'heading' Section, Paragraph-Name etc.

Let's take the very last sequence above and show how it could be edited
to operate with scope terminators "-

IF (#1) WS-RECORD-EXISTS = "N"
MOVE
"No record - do you want to input ? y/n"
TO WS-INSTRUCTION-TEXT
MOVE SPACES TO WS-INSTRUCTION-EXIT
PERFORM Z040-INSTRUCTION-LINE
PERFORM Z025-ANSWER

IF (#2) WS-ANSWER = "Y"
PERFORM C060-ENTER-NEW-DATA

ELSE (#2) GO TO C010-EXIT
----> don't need the period here replaced by following end-if

----> END-IF (#2)

----> END-IF (#1)

PERFORM C070-LINE-NUMBER THROUGH C070-EXIT.

----> If I didn't have the line 'PERFORM C070-LINE...." nor the
two lines for C010-EXIT, then a period would be required after the final
'END-IF', denoting the end of the current paragraph.


000000 C010-EXIT.
EXIT.

Note the two 'IF' s are paired off with an END-IF and we don't need any
intervening periods. (Scope Terminators are the equivalent of something
being finished with a period).

Not a very expansive explanation but if you are saying that RM/COBOL is
rejecting the following, then it might be useful to post the full source
that you are getting errors for, plus the error messasges in the following :-

main.
display "hello"
display "goodbye"
stop run
.

Just a thought, it's so long ago. Doesn't 'old' RM require something like :-

MAIN-SECTION.
FIRST-PARAGRAPH. ?????????

display "hello"
display "goodbye"
stop run
..

And 'Yes' you DEFINITELY need that period after STOP RUN :-)

Jimmy
.



Relevant Pages

  • 26 Suggestions for both Word and Excel
    ... Transpose should have an extra facility to transpose the selected cells ... display begins in the second line and therefore we cannot see row name A, B, ... And more in a single selection at a time, then there will be no problem. ... Identity to any selected Paragraph, line, or any character or criteria. ...
    (microsoft.public.word.docmanagement)
  • Re: stuck trying to create a page with multiple blank lines
    ... In the latter case (putting paragraph lines into boxes) ... The display math switch $$ in TeX is, *by definition*, an interuption ... there are occasions in hboxes where empty math displays ...
    (comp.text.tex)
  • Re: Section headings in header
    ... "Jezebel" wrote: ... Causes the field to display the entire paragraph number for a referenced ... Literature review (header) ...
    (microsoft.public.word.vba.general)
  • Help with manipulating a string.
    ... I was interested in formatted display on screen. ... My question was how to adjust MANY such independent ... Or Text::wrap can handle only one paragraph. ... To unsubscribe, e-mail: beginners-unsubscribe@perl.org ...
    (perl.beginners)
  • RE: Help needed on perl wrappers
    ... > I was interested in formatted display on screen. ... Or Text::wrap can handle only one paragraph. ... Help needed on perl wrappers ...
    (perl.beginners)