Help needed for learning COBOL. 
Author Message
 Help needed for learning COBOL.

On Tue, 18 May 1999 12:10:07 +0100, Paul Richards

Quote:

>Hi,
>I have a friend who asked me if I could go on the Internet and ask
>around to see why his program doesn't work and how to fix it.  I myself
>no nothing about COBOL but I can program in C++.  Anyway, here's his
>source code:

[...]

A statement about how the program actually behaves might be useful.

In merely scrolling thru the program I noticed that the paragraph
label  3-PROG-TERM is not terminated with a period.

Kindrick



Sat, 03 Nov 2001 03:00:00 GMT  
 Help needed for learning COBOL.
Hi,
I have a friend who asked me if I could go on the Internet and ask
around to see why his program doesn't work and how to fix it.  I myself
no nothing about COBOL but I can program in C++.  Anyway, here's his
source code:

       IDENTIFICATION DIVISION.
       PROGRAM-ID. VIDVAL.
       AUTHOR. N TRIPNEY.
      *
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT INPUTFILE
               ASSIGN TO DISK
               ORGANIZATION IS LINE SEQUENTIAL.
           SELECT VALIDFILE
               ASSIGN TO DISK
               ORGANIZATION IS LINE SEQUENTIAL.
           SELECT ERROREPORT
               ASSIGN TO DISK
               ORGANIZATION IS SEQUENTIAL.
      *
       DATA DIVISION.
       FILE SECTION.
       FD INPUTFILE
           VALUE OF FILE-ID "C:\COBOL\PROGRAM\INPUTF".
       01 INPUT-REC.
           02 VID-NO-POS.
               03 VID-NO-POS1  PIC 9.
               03 VID-NO-POS2  PIC 9.
               03 VID-NO-POS3  PIC 9.
               03 VID-NO-POS4  PIC 9.
               03 VID-NO-POS5  PIC 9.
               03 VID-NO-POS6  PIC 9.

           02 VIDFILM-NUM REDEFINES VID-NO-POS     PIC 9(6).
               88 VIDFILM-NUM-IN-RANGE     VALUE 1 THRU 999998.

           02 CHECK-DIG        PIC X.

           02 VIDFILM-TITLE    PIC X(30).

           02 VIDFILM-CAT      PIC X(3).
               88 VIDFILM-CAT-VALID
               VALUE "COM" "HOR" "DRA" "FAM" "ADU".

           02 VIDEOISS-DAT     PIC 9(8).

           02 VIDEO-COST       PIC 99V99.
               88 VIDEO-COST-IN-RANGE  VALUE 0 THRU 5000.

       FD VALIDFILE
           VALUE OF FILE-ID "C:\COBOL\PROGRAM\VALIDF".

       01 VALID-REC.
           02 VR-VIDFILM-NO    PIC 9(6).
           02 VR-VIDFILM-TITLE PIC X(30).
           02 VR-VIDFILM-CAT   PIC X(3).
           02 VR-VIDEOISS-DAT  PIC 9(8).
           02 VR-VIDEO-COST    PIC 99V99.

       01 VALID-TOTALS.
           02 VR-TOTALVIDEO-DUM-NUM    PIC 9(6).
           02 VR-TOTALVIDEO-VAL-RECS   PIC ZZZ9.
           02 VR-TOTALVIDEO-PUR-PRICE  PIC ZZZ9V99.
           02 VR-TOTALVIDEO-FILLER     PIC X(30)   VALUE SPACES.

       FD ERROREPORT
           VALUE OF FILE-ID "C:\COBOL\PROGRAM\ERREP".

       01 PRINT-REC    PIC X(80).

      *
       WORKING-STORAGE SECTION.
       01 PRINT-LINES.
           02 PAGE-HEADER.
               03          PIC X(30)    VALUE SPACES.
               03          PIC X(19)    VALUE "VIDEO FILE VALIDATE".
               03          PIC X(23)    VALUE SPACES.
               03  P-S-DD  PIC 9(2).
               03          PIC X        VALUE "/".
               03  P-S-MM  PIC 9(2).
               03          PIC X        VALUE "/".
               03  P-S-YY  PIC 9(2).

           02 HEADING-LINE2.
               03          PIC X(30)    VALUE SPACES.
               03          PIC X(19)    VALUE "*******************".
               03          PIC X(31)    VALUE SPACES.

           02 SUB-HEADER.
               03          PIC X(8)     VALUE "VIDEO No".
               03          PIC X(3)     VALUE SPACES.
               03          PIC X(2)     VALUE "CD".
               03          PIC X(7)     VALUE SPACES.
               03          PIC X(5)     VALUE "TITLE".
               03          PIC X(28)    VALUE SPACES.
               03          PIC X(8)     VALUE "CATEGORY".
               03          PIC X(4)     VALUE SPACES.
               03          PIC X(6)     VALUE "ISSUED".
               03          PIC X(4)     VALUE SPACES.
               03          PIC X(5)     VALUE "PRICE".

           02 REC-LINE.
               03  PR-VID-NO       PIC 9(6).
               03                  PIC X(6)     VALUE SPACES.
               03  PR-CHK-DIG      PIC X.
               03                  PIC X(7)     VALUE SPACES.
               03  PR-VID-TITLE    PIC X(30).
               03                  PIC X(5)     VALUE SPACES.
               03  PR-VID-CAT      PIC X(3).
               03                  PIC X(6)     VALUE SPACES.
               03  PR-ISS-DATE     PIC 9(8).
               03                  PIC X(4)     VALUE SPACES.
               03  PR-PUR-PRICE    PIC 99V99.

           02 ASTERISK-LINE.
               03  ASTERISK-VID-NO     PIC X(6).
               03                      PIC X(6) VALUE SPACES.
               03  ASTERISK-CHK-DIG    PIC X.
               03                      PIC X(7) VALUE SPACES.
               03  ASTERISK-VID-TITLE  PIC X(30).
               03                      PIC X(5) VALUE SPACES.
               03  ASTERISK-VID-CAT    PIC X(3).
               03                      PIC X(6) VALUE SPACES.
               03  ASTERISK-ISS-DATE   PIC X(8).
               03                      PIC X(4) VALUE SPACES.
               03  ASTERISK-VIDEO-COST PIC X(4).

           02 TOTALS-LINE1.
               03                          PIC X(20)    VALUE SPACES.
               03
               PIC X(23)    VALUE "NUMBER OF INPUT RECORDS".
               03                          PIC X(4)     VALUE SPACES.
               03                          PIC X        VALUE "=".
               03                          PIC X(2)     VALUE SPACES.
               03  FIN-COUNT-INPUT-RECS    PIC Z(3)9.
               03                          PIC X(26)    VALUE SPACES.

           02 TOTALS-LINE2.
               03                          PIC X(20)    VALUE SPACES.
               03
               PIC X(25)    VALUE "NUMBER OF INVALID RECORDS".
               03                          PIC X(2)     VALUE SPACES.
               03                          PIC X        VALUE "=".
               03                          PIC X(2)     VALUE SPACES.
               03  FIN-COUNT-INVALID-RECS  PIC Z(3)9.
               03                          PIC X(24)    VALUE SPACES.

           02 TOTALS-LINE3.
               03                          PIC X(20)    VALUE SPACES.
               03
               PIC X(23)    VALUE "NUMBER OF VALID RECORDS".
               03                          PIC X(4)     VALUE SPACES.
               03                          PIC X        VALUE "=".
               03                          PIC X(2)     VALUE SPACES.
               03  FIN-COUNT-VALID-RECS    PIC Z(3)9.
               03                          PIC X(26)    VALUE SPACES.

       01 CALCULATION-VARIABLES.
           02  COUNT-INPUT-RECS            PIC 9(4)    VALUE 0.
           02  COUNT-INVALID-RECS          PIC 9(4)    VALUE 0.
           02  COUNT-VALID-RECS            PIC 9(4)    VALUE 0.
           02  COUNT-TOTAL-COST            PIC 9(4)V99 VALUE 0.
           02  CALC1                       PIC 999.
           02  CALC2                       PIC 9.
           02  PROG-CHK-DIG                PIC X.
           02  QUOTIENT                    PIC 999.
           02  REM                         PIC 9.

       01 ODDMENTS.
           02 LAST-VIDFILM-NUM             PIC 9(6)    VALUE 0.
           02 EOF-INDIC                    PIC 9       VALUE 0.
           02 LINE-COUNT                   PIC 99      VALUE 8.
               88 PAGE-FULL                            VALUE 8.
           02 SYSTEM-DATE.
               03 S-YY                     PIC 99.
               03 S-MM                     PIC 99.
               03 S-DD                     PIC 99.
           02 ERROR-INDICATOR              PIC 9.

      *

       PROCEDURE DIVISION.
       MAIN.
           PERFORM 1-PROG-INIT
           PERFORM 2-PROG-VALIDATE-RECS UNTIL EOF-INDIC = '1'
           PERFORM 3-PROG-TERM
       STOP RUN
       .

       1-PROG-INIT.
           OPEN INPUT INPUTFILE
               OUTPUT VALIDFILE
               OUTPUT ERROREPORT
           READ INPUTFILE
               AT END MOVE '1' TO EOF-INDIC
           END-READ
           ACCEPT SYSTEM-DATE FROM DATE
           MOVE S-YY TO P-S-YY
           MOVE S-MM TO P-S-MM
           MOVE S-DD TO P-S-DD
       .

       2-PROG-VALIDATE-RECS.
           MOVE SPACES TO ASTERISK-LINE
           MOVE '0' TO ERROR-INDICATOR
           ADD 1 TO COUNT-INPUT-RECS
           PERFORM 20-VIDFILM-NUM-CHECK
           PERFORM 21-CHECK-DIGIT-CORRECT
           PERFORM 22-CHECK-CORRECT-SEQUENCE
           PERFORM 23-VIDFILM-CAT-CHECK
           PERFORM 24-VIDEOISS-DAT-CHECK
           PERFORM 25-VIDEO-COST-CHECK
           IF ERROR-INDICATOR='0'
               PERFORM 26-WRITE-VALID-REC
           ELSE
               PERFORM 27-WRITE-INVALID-REC
           END-IF
           READ INPUTFILE
               AT END MOVE '1' TO EOF-INDIC
           END-READ
       .

       20-VIDFILM-NUM-CHECK.
           IF VIDFILM-NUM NOT NUMERIC OR NOT VIDFILM-NUM-IN-RANGE
               MOVE ALL '*' TO ASTERISK-VID-NO
               MOVE '1' TO ERROR-INDICATOR
           END-IF
       .

       21-CHECK-DIGIT-CORRECT.
           COMPUTE CALC1   =(VID-NO-POS1*6)
                           +(VID-NO-POS2*5)
                           +(VID-NO-POS3*4)
                           +(VID-NO-POS4*3)
                           +(VID-NO-POS5*2)
                           +(VID-NO-POS6*1)
           DIVIDE 7 INTO CALC1
               GIVING QUOTIENT REMAINDER REM
           SUBTRACT REM FROM 7 GIVING CALC2
           EVALUATE CALC2
               WHEN 1
                       MOVE 'A' TO PROG-CHK-DIG
               WHEN 2
                       MOVE 'B' TO PROG-CHK-DIG
               WHEN 3
                       MOVE 'C' TO PROG-CHK-DIG
               WHEN 4
                       MOVE 'D' TO PROG-CHK-DIG
               WHEN 5
                       MOVE 'E' TO PROG-CHK-DIG
               WHEN 6
                       MOVE 'F' TO PROG-CHK-DIG
               WHEN 7
                       MOVE 'G' TO PROG-CHK-DIG
           END-EVALUATE

           IF PROG-CHK-DIG NOT = CHECK-DIG
               MOVE '*' TO ASTERISK-CHK-DIG
               MOVE '1' TO ERROR-INDICATOR
           END-IF
       .

       22-CHECK-CORRECT-SEQUENCE.
           IF VIDFILM-NUM NOT > LAST-VIDFILM-NUM
...

read more »



Sat, 03 Nov 2001 03:00:00 GMT  
 Help needed for learning COBOL.
Kindrick Ownby writes,
Quote:
>On Tue, 18 May 1999 12:10:07 +0100, Paul Richards

>>Hi,
>>I have a friend who asked me if I could go on the Internet and ask
>>around to see why his program doesn't work and how to fix it.  I myself
>>no nothing about COBOL but I can program in C++.  Anyway, here's his
>>source code:
>[...]

>A statement about how the program actually behaves might be useful.

Yeah sorry, I thought he might have put in comments.

Quote:
>In merely scrolling thru the program I noticed that the paragraph
>label  3-PROG-TERM is not terminated with a period.

K, I'll tell him.  Is that the name of a function of something "3-PROG-
TERM"?  If it is it's a bit meaningful ain't it?
--
Paul Richards (AKA Pauldoo)

FAX     +44 (0)870 0522086
HTTP    www.dunvegan1.demon.co.uk/paul/
ICQ     14106503


Sun, 04 Nov 2001 03:00:00 GMT  
 Help needed for learning COBOL.
Paul Richards writes,
Quote:
>       3-PROG-TERM
>           MOVE 999999 TO VR-TOTALVIDEO-DUM-NUM
>           MOVE COUNT-VALID-RECS TO VR-TOTALVIDEO-VAL-RECS
>           MOVE COUNT-TOTAL-COST TO VR-TOTALVIDEO-PUR-PRICE
>           MOVE SPACES TO VR-TOTALVIDEO-FILLER
>           WRITE VALID-TOTALS
>           MOVE COUNT-INPUT-RECS TO FIN-COUNT-INPUT-RECS
>           MOVE COUNT-INVALID-RECS TO FIN-COUNT-INVALID-RECS
>           MOVE COUNT-VALID-RECS TO FIN-COUNT-VALID-RECS
>           WRITE PRINT-REC FROM TOTALS-LINE1 AFTER 5
>           WRITE PRINT-REC FROM TOTALS-LINE2 AFTER 1
>           WRITE PRINT-REC FROM TOTALS-LINE3 AFTER 1
>           CLOSE INPUTFILE VALIDFILE ERROREPORT
>       .

Kindrick, that looks like a full-stop to me.
--
Paul Richards (AKA Pauldoo)

FAX     +44 (0)870 0522086
HTTP    www.dunvegan1.demon.co.uk/paul/
ICQ     14106503


Sun, 04 Nov 2001 03:00:00 GMT  
 Help needed for learning COBOL.

Quote:

>Paul Richards writes,
>>       3-PROG-TERM

As Kindrick stated, the full-stop is missing from the label.

Quote:
>>           MOVE 999999 TO VR-TOTALVIDEO-DUM-NUM
[...]
>>           CLOSE INPUTFILE VALIDFILE ERROREPORT
>>       .
>Kindrick, that looks like a full-stop to me.

------------------
Rick Smith


Sun, 04 Nov 2001 03:00:00 GMT  
 Help needed for learning COBOL.

Quote:

>Kindrick Ownby writes,
>>On Tue, 18 May 1999 12:10:07 +0100, Paul Richards

>>>[...]  I myself
>>>no nothing about COBOL but I can program in C++.  [...]
[...]
>>In merely scrolling thru the program I noticed that the paragraph
>>label  3-PROG-TERM is not terminated with a period.
>K, I'll tell him.  Is that the name of a function of something "3-PROG-
>TERM"?  If it is it's a bit meaningful ain't it?

A paragraph in COBOL has an equivalence to a static function
in C++ with the restriction that the function has no return value, no
parameters, and no local variables. For any paragraph (in a
structured COBOL program), the equivalent C++ function
declaration would look like:

static void paragraph_name (void) {
    // code for paragraph body

Quote:
}

Then
    PERFORM PARAGRAPH-NAME
is equivalent to
    paragraph_name ();

With the name "3-PROG-TERM", I would expect the paragraph
to contain program termination code. It does; therefore, the name
is sufficiently meaningful, for me.

HTH
------------------
Rick Smith



Sun, 04 Nov 2001 03:00:00 GMT  
 Help needed for learning COBOL.
Rick Smith writes,

Quote:


>>Paul Richards writes,
>>>       3-PROG-TERM
>As Kindrick stated, the full-stop is missing from the label.

See, told you that I know zip COBOL...
--
Paul Richards (AKA Pauldoo)

FAX     +44 (0)870 0522086
HTTP    www.dunvegan1.demon.co.uk/paul/
ICQ     14106503


Sun, 04 Nov 2001 03:00:00 GMT  
 Help needed for learning COBOL.
On Wed, 19 May 1999 08:57:21, Paul Richards

Quote:

> Paul Richards writes,
> >       3-PROG-TERM

The full stop is needed ABOVE.

Quote:
> >           MOVE 999999 TO VR-TOTALVIDEO-DUM-NUM
> >           MOVE COUNT-VALID-RECS TO VR-TOTALVIDEO-VAL-RECS
> >           MOVE COUNT-TOTAL-COST TO VR-TOTALVIDEO-PUR-PRICE
> >           MOVE SPACES TO VR-TOTALVIDEO-FILLER
> >           WRITE VALID-TOTALS
> >           MOVE COUNT-INPUT-RECS TO FIN-COUNT-INPUT-RECS
> >           MOVE COUNT-INVALID-RECS TO FIN-COUNT-INVALID-RECS
> >           MOVE COUNT-VALID-RECS TO FIN-COUNT-VALID-RECS
> >           WRITE PRINT-REC FROM TOTALS-LINE1 AFTER 5
> >           WRITE PRINT-REC FROM TOTALS-LINE2 AFTER 1
> >           WRITE PRINT-REC FROM TOTALS-LINE3 AFTER 1
> >           CLOSE INPUTFILE VALIDFILE ERROREPORT
> >       .
> Kindrick, that looks like a full-stop to me.

There isn't one after the paragraph name.

Quote:
> --
> Paul Richards (AKA Pauldoo)

> FAX     +44 (0)870 0522086
> HTTP    www.dunvegan1.demon.co.uk/paul/
> ICQ     14106503

-------------------------
Trust the computer industry to shorten "Year 2000" to Y2K.  It was
this
kind of thinking that caused the problem in the first place.

Visit my updated website at
http://www.geocities.com/Eureka/2006/



Sun, 04 Nov 2001 03:00:00 GMT  
 Help needed for learning COBOL.

Quote:
> COBOL isn't really a programming language, is it?  :)

???????????????????????????????????????????????????????

Was I the only one who saw this remark?



Mon, 05 Nov 2001 03:00:00 GMT  
 Help needed for learning COBOL.
'Twas Thu, 20 May 1999 14:41:27 -0600, when "ChrisOsborne"

Quote:
> > COBOL isn't really a programming language, is it?  :)

> ???????????????????????????????????????????????????????

> Was I the only one who saw this remark?

If I had, I wouldn't want to admit to reading all 349 lines of that dull
post.
--
R B |\  Randall Bart

n r |\  1-614-538-8764 x230    Please reply without spam    I Love You
d t ||\ Where have you gone Joe Dimaggio?  99?  7?       MS^7=6/28/107
a    |/ What can we do about the Year 2000 Bugs?  Let's sing:
l    |\             http://users.aol.com/PanicYr00/SongMiscellany.html
l    |/ Have you solved http://users.aol.com/PanicYr00/Sequence.html ?


Mon, 05 Nov 2001 03:00:00 GMT  
 Help needed for learning COBOL.

Quote:

>> COBOL isn't really a programming language, is it?  :)

>???????????????????????????????????????????????????????

>Was I the only one who saw this remark?

No! In context, it was "tongue in cheek" humor by someone who
claimed no knowledge of COBOL. Since the comment was most
likely (the "smilely" is a clue) not intended as a disparagement of
the COBOL programming language or its users, no refutation of
the comment was required.

At least, that is how I treated it! ;-)
------------------
Rick Smith



Mon, 05 Nov 2001 03:00:00 GMT  
 Help needed for learning COBOL.
Randall Bart writes,

Quote:
>'Twas Thu, 20 May 1999 14:41:27 -0600, when "ChrisOsborne"

>> > COBOL isn't really a programming language, is it?  :)

>> ???????????????????????????????????????????????????????

>> Was I the only one who saw this remark?

>If I had, I wouldn't want to admit to reading all 349 lines of that dull
>post.

See, told you COBOL is a dull language... :)
--
Paul Richards (AKA Pauldoo)

FAX     +44 (0)870 0522086
HTTP    www.dunvegan1.demon.co.uk/paul/
ICQ     14106503


Tue, 06 Nov 2001 03:00:00 GMT  
 Help needed for learning COBOL.
I scrolled down to the bottom to see if there were any comments about
what was going wrong.


Quote:
> 'Twas Thu, 20 May 1999 14:41:27 -0600, when "ChrisOsborne"

> > > COBOL isn't really a programming language, is it?  :)

> > ???????????????????????????????????????????????????????

> > Was I the only one who saw this remark?

> If I had, I wouldn't want to admit to reading all 349 lines of that
dull
> post.
> --
> R B |\  Randall Bart



Quote:
> n r |\  1-614-538-8764 x230    Please reply without spam    I Love
You
> d t ||\ Where have you gone Joe Dimaggio?  99?  7?
MS^7=6/28/107
> a    |/ What can we do about the Year 2000 Bugs?  Let's sing:
> l    |\

http://users.aol.com/PanicYr00/SongMiscellany.html
Quote:
> l    |/ Have you solved http://users.aol.com/PanicYr00/Sequence.html

?


Tue, 06 Nov 2001 03:00:00 GMT  
 Help needed for learning COBOL.
Lemme guess, you probably think Visual Basic is a programming language?

Quote:

> > COBOL isn't really a programming language, is it?  :)

> ???????????????????????????????????????????????????????

> Was I the only one who saw this remark?

--


########################################
 "When all of your wishes are granted,
 many of your dreams will be destroyed.
########################################



Fri, 09 Nov 2001 03:00:00 GMT  
 
 [ 14 post ] 

 Relevant Pages 

1. help, i need to learn cobol

2. Need help learning Cobol...

3. VS COBOL to COBOL II - Need Help

4. WWW: Help learning COBOL

5. Help requested re learning cobol on MVS, using ISPF, JCL, TSO, etc

6. Please Help--having trouble learning COBOL

7. i need help to modify my cobol program can someone help soon please

8. Help...college student needs help w/cobol prgm.

9. COBOL HELP NEEDED, PLEASE HELP ME!

10. need help learning ABC template use

11. VO 2 - Just learning - need help!

12. Need help learning functional programming

 

 
Powered by phpBB® Forum Software