|
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.
|
|
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.
|
|
|
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?
|
|
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.
|