MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Shortest COBOL program (Again!)

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Mainframe Challenge
View previous topic :: View next topic  
Author Message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Tue Nov 02, 2004 10:42 am    Post subject: Shortest COBOL program (Again!) Reply with quote

Hi all,
Can anyone tell me what is so special about this COBOL program without actually compiling it? Yes. Only compilation.

Code:

IDENTIFICATION DIVISION.
PROGRAM-ID. ERRMSG.     
    STOP RUN .         


Will it compile successfully?
If not, what will be compilation messages?

8)
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Nov 02, 2004 10:51 am    Post subject: Reply with quote

Cogito,

If I remember correctly ERRMSG is used to generate the compiler listing with explanations. is that Right?

It will compile successfully.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Tue Nov 02, 2004 12:01 pm    Post subject: Reply with quote

100% !

It compiles successfully. And, yes, it generates a list of various compiler messages.

Kolusu, you are great!
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
mok
Beginner


Joined: 16 May 2003
Posts: 12
Topics: 0
Location: paris

PostPosted: Tue Nov 09, 2004 1:19 pm    Post subject: Reply with quote

Hi,
ERRMSG exists since Cobol II ! Furthermore, you can do it shorter : the STOP RUN statement is not mandatory.
Cheers
Back to top
View user's profile Send private message
Kathi
Beginner


Joined: 14 May 2003
Posts: 25
Topics: 0
Location: Mission Viejo, California

PostPosted: Tue Dec 28, 2004 1:52 am    Post subject: Reply with quote

I think some people have too much time on their hands! Laughing
Back to top
View user's profile Send private message
ranga_subham
Intermediate


Joined: 31 Jan 2006
Posts: 255
Topics: 72

PostPosted: Sun Feb 25, 2007 3:12 am    Post subject: Reply with quote

Hi, mok.

Quote:

ERRMSG exists since Cobol II ! Furthermore, you can do it shorter : the STOP RUN statement is not mandatory.


Would you please explain in detail?

TIA.
_________________
Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Sun Feb 25, 2007 10:42 am    Post subject: Reply with quote

ranga_subham,

If control reaches the end of the Procedure Division of a method, and there is no next executable statement, an implicit EXIT METHOD statement is executed. ie the control is returned to the system. So if you don't have an explicit STOP RUN statement and the control reaches the end, then the program automatically execuetes the implicit exit method and return the control which is what mok is saying.


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
peaglet
Beginner


Joined: 08 Jun 2007
Posts: 2
Topics: 0
Location: Chicago

PostPosted: Mon Jun 11, 2007 4:58 pm    Post subject: Reply with quote

If you're still using STOP RUN you need to move up to the newest compiler. GOBACK is now the standard
Back to top
View user's profile Send private message
balaji.p.raman
Beginner


Joined: 27 Feb 2007
Posts: 10
Topics: 5
Location: India

PostPosted: Thu Sep 02, 2010 7:17 am    Post subject: Reply with quote

Well, I hope you guys would be shooting me for posting this! Very Happy

The shortest COBOL program I have managed to write was this

"PROGRAM-ID. SHORT." bonk

Compiler used: Fujitsu NetCOBOL for Windows!

No kidding!

Reason:
A file input is treated to be a COBOL input file ONLY when it is identified with an IDENTIFICATION DIVISION. However, if one forgets just that small bit and a COBOL verb PROGRAM-ID follows, this compiler works around and recognizes the file as a valid COBOL file.

Can someone confirm if IBM compilers exhibit this behavior?
_________________
Rgds,
Balaji
Back to top
View user's profile Send private message Yahoo Messenger
Anuj Dhawan
Intermediate


Joined: 19 Jul 2007
Posts: 298
Topics: 7
Location: Mumbai,India

PostPosted: Thu Sep 02, 2010 8:08 am    Post subject: Reply with quote

No that will not work on zOS. For IBM Enterprise COBOL for z/OS 3.4.1 you get this error
Code:
IGYDS1000-E   A "IDENTIFICATION DIVISION" header was not found in this program.  It was assumed present.
and program does not compile successfully.
_________________
Regards,
Anuj
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Mainframe Challenge All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group