Code Comments
Programming Forum and web based access to our favorite programming groups.Hello: I noticed two styles of cobol syntax: main. display "hello" display "goodbye" stop run
Post Follow-up to this messageIn article <1177272149.938765.13260@o5g2000hsb.googlegroups.com>,
Mayer <mayer.goldberg@gmail.com> wrote:
>Hello:
[snip]
>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.
To work backwards... what is recommended is starting with the style of
code on your job-site (or learning what your instructor instructs you to
do), there is no 'the basis' but, quite possibly, a few different bases
and the function of the period is what, for the most part, what The Manual
says it to be.
(Even the term used to define this particular bit of punctuation varies
from one group to the next; some adherents to a primitive language which
serves as a basis for a bit of what Americans speak will insist on using
two words ('full stop') to describe it, rather than the one ('period')
which can be found in citations as early as the seventeenth century...
their reasons for doing this are still unknown but they are, at times,
*most* insistent.)
DD
Post Follow-up to this messageMayer 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
Post Follow-up to this messageJames J. Gavan wrote: > Mayer wrote: > <snip> > 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 :- > > > > 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 > . > Mayer, Pretty dumb of me - I should have checked the beginning of the program I extracted from :- ----------------------------------------------------------------------- 000340 COPY "\USR\CS\TEXT2\CSWSCOMM.CBL". 000670 PROCEDURE DIVISION 000680 000340 COPY "\USR\CS\TEXT2\CSERROR.CBL". 000710 000720 A010-MAIN-LINE SECTION. 000730 A010-BEGIN. 000740 IF WS-LABEL-CHECK NOT = "QQ" STOP RUN ELSE MOVE WS-PROGRAM-TITLE TO WS-SCREEN-TITLE PERFORM X010-OPEN-FILES. A010-NEXT. ---------------------------------------------------------------------- I think your problem with RM/COBOL will be resolved if you have :- PROCEDURE DIVISION. A010-MAIN-LINE SECTION. A010-BEGIN (or MAIN-PARAGRAPH if you like). Micro Focus compilers allow you to take 'shortcuts'. Jimmy
Post Follow-up to this messagedocdwarf@panix.com wrote:
> In article <1177272149.938765.13260@o5g2000hsb.googlegroups.com>,
> Mayer <mayer.goldberg@gmail.com> wrote:
>
>
>
> [snip]
>
>
>
>
> To work backwards... what is recommended is starting with the style of
> code on your job-site (or learning what your instructor instructs you to
> do), there is no 'the basis' but, quite possibly, a few different bases
> and the function of the period is what, for the most part, what The Manual
> says it to be.
>
> (Even the term used to define this particular bit of punctuation varies
> from one group to the next; some adherents to a primitive language which
> serves as a basis for a bit of what Americans speak will insist on using
> two words ('full stop') to describe it, rather than the one ('period')
> which can be found in citations as early as the seventeenth century...
> their reasons for doing this are still unknown but they are, at times,
> *most* insistent.)
>
> DD
>
Very insistent, us folks from the 'Mother country'. Not sure of origins,
but in days of telegrams :-
'WILL BE LEAVING BY FLIGHT AC 124. STOP. PLANE ARRIVES CALGARY 13.05
LOCAL TIME. STOP'.
Same sort of thing using teleprinters in military to send signals :-
'FROM C-IN-C MEAF TO AOC-IN-C IRAQ. STOP. FOR UK EYES ONLY. STOP. YOUR
A12345 12 SEPTEMBER 1954. STOP. GOD HELP US WHEN THE YANKS TAKE OVER. STOP.'
For your edification, something else which amuses North Americans, "If
you like I'll knock you up". NOT to be translated as, "If you like I'll
leave a bun in your oven".
Saw the latter's origins on TV. Back in yon days of the Industrial
Revolution and the 'dark Satanic Mills', when the poor sods,
disenfranchised from their farms worked in the grimy mills starting work
at 05:00 or 06:00 so the mill owner could save on lighting. It takes
me all my effort to be awake by 08:00, so they had a similar problem
with their times too.
For about a penny per w
/month each household would pay somebody to
knock them up. This man went down the rows of dingy terraced houses with
a long stick and tapped(knocked) at the window immediately above the
front door.
Another interesting one from TV. Do you know the origins of 'freelance' ?
BTW - Afterthought. You refer to hiring agencies as those 'pimps' Don't
disagree with your conclusion/description. However, if a pimp is trying
to gain you useful paid employment does that make you an whore (or in
line with Imus an 'ho') ?
Jimmy
Post Follow-up to this messageI am surprised by your statement that RM had a problem with the first exampl e - but it may depend upon the context of the entire COBOL program. (What messag e does it give you?) As far as the Procedure Division goes (different rules for other divisions). There are requirements that: A) every procedure-name (header) - paragraph or section name MUST be termina ted by a period (full-stop). B) There must be a period (full-stop) at the end of each set of procedure division statements that constitute a procedure, i.e. each paragraph or sect ion (terminated by another paragraph or section name - or by the end of source code - or End Program header). There is a SEMANTIC difference for periods. They end SENTENCES. This is wh ere a NEXT SENTENCE phrase (or statement - if your compiler has such a statement as an extension - as Micro Focus does) will "go to". For example. If Field-1 = A Next Sentence Else Display "Here"
Post Follow-up to this messageIn article <JrSWh.116487$aG1.66743@pd7urf3no>, James J. Gavan <jgavandeletethis@shaw.ca> wrote: >docdwarf@panix.com wrote: [snip] >Very insistent, us folks from the 'Mother country'. Yes, quite insistent... and the reasons, as noted above, are still unknown. Time passes, terminologies change - not much talk of women having 'the vapors', is there? - and yet this particular bit still rolls on. >Not sure of origins, >but in days of telegrams :- > >'WILL BE LEAVING BY FLIGHT AC 124. STOP. PLANE ARRIVES CALGARY 13.05 >LOCAL TIME. STOP'. See above and the OED, Mr Gavan... the use Americans make is first cited in 1609, not too many telegrams back then. (note to Mr Goldberg - this was pointed out to this newsgroup a half-dozen years ago, see <[url]http://groups.google.com/group/comp.lang.cobol/msg/f5a18356c2cad15b?dmode=source[ /url]> > >Same sort of thing using teleprinters in military to send signals :- > >'FROM C-IN-C MEAF TO AOC-IN-C IRAQ. STOP. FOR UK EYES ONLY. STOP. YOUR >A12345 12 SEPTEMBER 1954. STOP. GOD HELP US WHEN THE YANKS TAKE OVER. STOP.'[/color ] See above, Mr Gavan... teleprinters postdate telegrams (shouldn't that be 'telegrammes'?) and both postdate Davies' used in the early seventeenth century by a goodly time. [snip] >Another interesting one from TV. Do you know the origins of 'freelance' ? Off the top of my head I'd say it might be related to samurai traditions. > >BTW - Afterthought. You refer to hiring agencies as those 'pimps' Don't >disagree with your conclusion/description. However, if a pimp is trying >to gain you useful paid employment does that make you an whore (or in >line with Imus an 'ho') ? No more than one is trying to change one's hat-size by visiting a 'headshrinker' or expecting an amputation from one's annual visit to the 'sawbones', Mr Gavan. DD
Post Follow-up to this messageOn Sun, 22 Apr 2007 23:52:11 GMT, "William M. Klein" <wmklein@nospam.netcom.com> wrote: > There is a SEMANTIC difference for periods. They end SENTENCES. This is where >a NEXT SENTENCE phrase (or statement - if your compiler has such a statemen t as >an extension - as Micro Focus does) will "go to". For example. > > If Field-1 = A > Next Sentence > Else > Display "Here" > . > Display "There" > . > >Gets very different results from > > If Field-1 = A > Next Sentence > Else > Display "Here" > Display "There" > . Some compilers will allow If Field-1 = A Next Sentence Else Display "Here" End-IF Display "There". In which case "Next Sentence" still goes to the next sentence. I see no advantage in ever using NEXT SENTENCE now that CONTINUE is available. Some pre-compilers create implicit IF statements without creating END-IF statements. In these special cases, a style of including full-stop periods can be beneficial. But in other cases, the Righteous arguments for one style over another are more of a religious nature. And it is easy to see what Righteous people inflict on the world.
Post Follow-up to this messageOn 23 Apr, 10:30, docdw...@panix.com () wrote: > In article <JrSWh.116487$aG1.66743@pd7urf3no>, > James J. Gavan <jgavandeletet...@shaw.ca> wrote: > > > Off the top of my head I'd say it might be related to samurai traditions. > I'll be brief as I'm suffering another migraine. From Wikipedia: "A freelancer or freelance worker is a person who pursues a profession without a long-term commitment to any one employer. The term was first coined by Sir Walter Scott (1771-1832) in his well-known historical romance Ivanhoe to describe a "medieval mercenary warrior." " also: "However, many Asian countries appear to follow Hormung by holding low regard for freelancers, often associating the practice with personal failure (an inability to find work with a major employer) and even criminality (see: Ninja)."
Post Follow-up to this messageIn article <1177340839.047930.275980@o5g2000hsb.googlegroups.com>, Alistair <alistair@ld50macca.demon.co.uk> wrote: >On 23 Apr, 10:30, docdw...@panix.com () wrote: > >I'll be brief as I'm suffering another migraine. From Wikipedia: > >"A freelancer or freelance worker is a person who pursues a profession >without a long-term commitment to any one employer. Compare and contrast with the 'masterless samurai', or ronin... and please pardon my obscurity. L Silberstein, A'83
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.