The Cleveland Area COBOL Meetup Group Message Board The Old Forum › The Structure of Cobol Programs

The Structure of Cobol Programs

Aoirthoir An Broc
Posted Oct 6, 2009 2:12 AM
aoirthoir
Group Organizer
Cleveland, OH
Post #: 279
Send an Email Post a Greeting
Tonight's class we went over a number a topics. So this will cover some of it.

Our lesson was The Structure of Cobol Programs, an introduction. Some points of interest:

  • COBOL means COmmon Business Oriented Language.
  • It's 50 years old (as of a couple of weeks ago).
  • It was created by CODASYL Committee (Conference on Data Systems Languages)
  • There were to be two committess, the Short Range Committee and the Long Range Committee. The short range was so successful that the long range never materialized.
  • Cobol is English, maintainable for decades, costly to replace, verbose, and used mainly in Vertical Market Applications (those for a specific business or industry), thus the most used language in the world.
  • We created two sample Cobol programs.
  • We set up a user on dreamhost (available to any taking the course) to test Cobol apps and encourage one another.


multiplytest.cob:

IDENTIFICATION DIVISION.
PROGRAM-ID. multiplytest.
*>AUTHOR. Aoirthoir An Broc.
*>DATE WRITTEN. 2009-10-05.
*>DATE COMPILED. 2009-10-05.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 num1 PIC 9999.
01 num2 PIC 9999.
01 result PIC 9(8).
01 disp-res PIC Z(8).
PROCEDURE DIVISION.
00-PROCESS.
DISPLAY "ENTER NUM1:" WITH NO ADVANCING
ACCEPT num1
DISPLAY "ENTER NUM2:" WITH NO ADVANCING
ACCEPT num2
MULTIPLY num1 BY num2 GIVING result
MOVE result TO disp-res
DISPLAY "RESULT IS " disp-res
GOBACK.






selection.cob:

IDENTIFICATION DIVISION.
PROGRAM-ID. multiplytest.
*>AUTHOR. Aoirthoir An Broc.
*>DATE WRITTEN. 2009-10-05.
*>DATE COMPILED. 2009-10-05.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 NumberValues.
05 num1 PIC 9999.
05 num2 PIC 9999.
05 result PIC 9(8).
05 disp-res PIC Z(8).
01 OperationType PIC X.
PROCEDURE DIVISION.
00-PROCESS.
PERFORM UNTIL OperationType IS EQUAL TO "Q"
DISPLAY "(A)dd"
DISPLAY "(S)ubtract"
DISPLAY "(M)ultiply"
DISPLAY "(D)ivide"
DISPLAY "(Q)uit"
ACCEPT OperationType
IF OperationType IS EQUAL TO "A"
OR "S"
OR "M"
OR "D" THEN
DISPLAY "ENTER NUM1:" WITH NO ADVANCING
ACCEPT num1
DISPLAY "ENTER NUM2:" WITH NO ADVANCING
ACCEPT num2
EVALUATE OperationType
WHEN "A"
ADD num1 TO num2 GIVING result
WHEN "S"
SUBTRACT num2 FROM num1 GIVING result
WHEN "M"
MULTIPLY num1 BY num2 GIVING result
WHEN "D"
DIVIDE num1 BY num2 GIVING result
END-EVALUATE
MOVE result TO disp-res
DISPLAY "RESULT IS " disp-res
END-IF
END-PERFORM
GOBACK.


So before we go on, let's get some commentary going on these two programs. Any questions feel free to ask and I will answer.
Bill Maupin
Posted Oct 6, 2009 4:41 PM
user 10485194
Cleveland, OH
Post #: 1
Send an Email Post a Greeting
Very thorough and I appreciate your patience. I have 0 programining, what I found strange was when I was a Collection manager, I remember running reports and I would have to create statements such as what we were doing in order to get the data I needed ie. Collector calls, Daily money posted, returned checks, accounts that had more than 10 days without a call. I know how frustrating also it can be when training people and just the small things like colon and they seemed confused can leave you befungled. Again thanks for the patience and you make great teacher.
Slava Voronzoff
Posted Oct 8, 2009 9:17 AM
user 10539345
Cleveland, OH
Post #: 1
Send an Email Post a Greeting
Hell! about "calculator" with menu =))) i made this some days ago =))) btw, isn't it will be more "beaty" if you add - (minus) sign to your display variable?
Aoirthoir An Broc
Posted Oct 8, 2009 12:06 PM
aoirthoir
Group Organizer
Cleveland, OH
Post #: 281
Send an Email Post a Greeting
Slava,

Yes the selection program should really be calculator. And yes it can be improved. Did you do a cobol version? Would you mind posting it here for us to see? Also I think we could create a version that takes a text line such as :

"3 * 4 + 8" and calculates it.

You are also correct that the vars should allow for a negative. As well as the result. This was just the first intro so the students will be given more of these concepts as we go along.
Powered by mvnForum

Our Sponsors

We want Sponsors!

Support us and get exposure.

This Meetup is about…

Other nearby
Meetups
Why these groups?
x

The Meetup Groups shown here are topically similar to The Cleveland Area COBOL Meetup Group.

Groups are more likely to be displayed here if they:

  • have a Meetup scheduled
  • have a high rating
  • have a group photo
  • are "public" and not "private"
  • have shown they are likely to stick around (older than 30 days)

Log in

  • Not registered with us yet?
or

Log in to Meetup with your Facebook account.

Sign up

or

Join this Meetup Group even quicker with your Facebook account.

By clicking the "Sign up using Facebook" or "Sign up" buttons above, you agree to Meetup's Terms of Service