clarification with Hyphen & Period usage .



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

clarification with Hyphen & Period usage .

Postby gowthamgyaa » Mon Oct 22, 2012 9:54 pm

Hi everyone,
1. Using hyphens between pre-defined Section or paragraphs, what it indicates? why should i use it? If i dont use hyphen its showing me an error .
2. If i use period to File control sentences its showing me an Error , why I should not use Period over there?

For example.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
           SELECT INFILE ASSIGN TO SYSUT1.
           ORGANIZATION IS SEQUENTIAL.
           ACCESS IS SEQUENTIAL.
           FILE STATUS IS FS.


In the above mentioned example in Predefined Sections and para hyphens are used, if i dint use hyphen its showing me an error. Similarly if i use hyphen for FILE STATUS its showing me an error.
To my knowledge I think hyphen used in section and para are for better readability.

Kind regards
gyaa
gowthamgyaa
 
Posts: 101
Joined: Wed Sep 05, 2012 11:18 pm
Has thanked: 67 times
Been thanked: 0 time

Re: clarification with Hyphen usage .

Postby BillyBoyo » Mon Oct 22, 2012 9:59 pm

What are all those fullstops/periods in your SELECT?

No, it is not for readability. If you look, all the "predefined" sections are "one something" followed by the word SECTION. If you happen to have two words for "one something", then you'll find they have a hyphen.

It is the way they are defined in the language standard.

These users thanked the author BillyBoyo for the post:
gowthamgyaa (Mon Oct 22, 2012 10:09 pm)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: clarification with Hyphen usage .

Postby Akatsukami » Mon Oct 22, 2012 10:02 pm

gowthamgyaa wrote:Hi everyone,
1. Using hyphens between pre-defined Section or paragraphs, what it indicates? why should i use it? If i dont use hyphen its showing me an error .

For example.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
           SELECT INFILE ASSIGN TO SYSUT1.
           ORGANIZATION IS SEQUENTIAL.
           ACCESS IS SEQUENTIAL.
           FILE STATUS IS FS.


In the above mentioned example in Predefined Sections and para hyphens are used, if i dint use hyphen its showing me an error. Similarly if i use hyphen for FILE STATUS its showing me an error.
To my knowledge I think hyphen used in section and para are for better readability.

Wrong. The section and paragraph names are spelled with hyphens; spelling them without is just as much an error as if you spelled the paragraph name FYLE-KONTROL. Likewise the FILE STATUS clause does not have a hyphen. When the manual states "XXX-XXX is a required section (paragraph, etc.)" it implies "...and the name must be spelled 'XXX-XXX'", not "...and the name can be spelled any way your little heart desires".
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day

These users thanked the author Akatsukami for the post:
gowthamgyaa (Mon Oct 22, 2012 10:08 pm)
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: clarification with Hyphen & Period usage .

Postby gowthamgyaa » Mon Oct 22, 2012 10:07 pm

BillyBoyo wrote:
What are all those fullstops/periods in your SELECT?

I should not have Periods in select , but i need to know why i should not use periods there?


Kind regards
gyaa
gowthamgyaa
 
Posts: 101
Joined: Wed Sep 05, 2012 11:18 pm
Has thanked: 67 times
Been thanked: 0 time

Re: clarification with Hyphen & Period usage .

Postby Robert Sample » Mon Oct 22, 2012 10:12 pm

There is a link to IBM Manuals on the top right of this page. You need to click on it, find the Enterprise COBOL Language Reference manual, and start reading -- cover to cover. All computer languages, including COBOL, have a specified syntax and the syntax for COBOL is provided in the Language Reference manual. You may create your own variable names -- with or without hyphens -- but COBOL names (such as INPUT-OUPUT SECTION) must be provided EXACTLY as given in the manual; you have no choice on their format.

Periods are required in certain cases such as the end of a paragraph in the PROCEDURE DIVISION, or after many statements in other divisions. Note that this statement you posted
           SELECT INFILE ASSIGN TO SYSUT1
           ORGANIZATION IS SEQUENTIAL
           ACCESS IS SEQUENTIAL
           FILE STATUS IS FS.
is NOT 4 statements -- it is 1 SINGLE statement, called the SELECT statement, with multiple clauses. As such, the only place you should put a period is after the last clause (FILE STATUS IS FS in your case). There are other times (when coding multiple statements associated with an IF, for example) where you must NOT put a period -- if you do, you get syntax errors at best and at worst a badly malfunctioning program.

These users thanked the author Robert Sample for the post:
gowthamgyaa (Tue Oct 23, 2012 7:06 pm)
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: clarification with Hyphen & Period usage .

Postby dick scherrer » Tue Oct 23, 2012 12:59 am

Hello,

I should not have Periods in select , but i need to know why i should not use periods there?
Simply because this violates the syntax rules. . .

You do not have to agree with the rules (or even understand all of them), but you must follow them. if you "make up your own" syntax, it will fail.

Until you are more familiar with the various "constructs", suggest you verify in the documentation if what you want to code is valid. You can also put bits and pieces of New code in a little test module to make sure what you are doing will be accepted by the compiler and at run time.
Hope this helps,
d.sch.

These users thanked the author dick scherrer for the post:
gowthamgyaa (Tue Oct 23, 2012 7:06 pm)
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post