Page 1 of 1

clarification with Hyphen & Period usage .

PostPosted: Mon Oct 22, 2012 9:54 pm
by gowthamgyaa
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

Re: clarification with Hyphen usage .

PostPosted: Mon Oct 22, 2012 9:59 pm
by BillyBoyo
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.

Re: clarification with Hyphen usage .

PostPosted: Mon Oct 22, 2012 10:02 pm
by Akatsukami
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".

Re: clarification with Hyphen & Period usage .

PostPosted: Mon Oct 22, 2012 10:07 pm
by gowthamgyaa
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

Re: clarification with Hyphen & Period usage .

PostPosted: Mon Oct 22, 2012 10:12 pm
by Robert Sample
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.

Re: clarification with Hyphen & Period usage .

PostPosted: Tue Oct 23, 2012 12:59 am
by dick scherrer
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.