0

I have Ubuntu 12.04.5, I have installed the GnuCOBOL platform and I have programmed GnuCOBOL for a while without a problem.

I am now doing something extremely trivial: I have a program MULT03.cob that I have compiled and run as below:

    martin@martin-1001PX:~/CobolProjects$ cobc -b MULT03.cob
    martin@martin-1001PX:~/CobolProjects$ cobcrun MULT03
    Which multiplication table (01-99)? 4
    How many entries to the table (01-999)? 5
    How many lines maximally in one round of output (0-99)? 2
    The 04`s (possibly extended) table is:
    04 * 001 = 0004
    04 * 002 = 0008
    Press Enter to continue...
    04 * 003 = 0012
    04 * 004 = 0016
    Press Enter to continue...
    04 * 005 = 0020
    martin@martin-1001PX:~/CobolProjects$

Then what I do is that I introduce a truly microscopic change in the program code (I am sure the problem is on a higher level, in linking/environment variables or other, but I have changed nothing there) and get

martin@martin-1001PX:~/CobolProjects$ cobc -b MULT04.cob
martin@martin-1001PX:~/CobolProjects$ cobcrun MULT04
libcob: ./MULT04.so: undefined symbol: MULT04
martin@martin-1001PX:~/CobolProjects$ 

MULT04.cob is basically MULT03.cob with two lines changed. Both are right there in the catalog, source code, object code and all:

martin@martin-1001PX:~/CobolProjects$ ls MU*
MULT02.cob  MULT03.cob  MULT04.cob  MULTAB.cob
MULT02.so   MULT03.so   MULT04.so   MULTAB.so

I would love to know what it is that makes the run-time system find the one but not the other. I have tried naming MULT04 differently (shouldn't be necessary, but just to rule that error source out). Other earlier programs compile and run without a problem:

martin@martin-1001PX:~/CobolProjects$ cobc -b BOILERPLATE.cob
martin@martin-1001PX:~/CobolProjects$ cobcrun  BOILERPLATE
martin@martin-1001PX:~/CobolProjects$ 

These are the (slightly differing) code segments:

004100 CALCULATE-AND-DISPLAY.
004200     ADD 1 TO THE-MULTIPLIER.
004210     
004220     ADD 1 TO INTERIM-LINE-NUMBER.
004230     IF INTERIM-LINE-NUMBER IS GREATER THAN THE-LIMIT-PER-ROUND
004235      MOVE 1 TO INTERIM-LINE-NUMBER
004240      DISPLAY "Press Enter to continue..." WITH NO ADVANCING
004250      ACCEPT THE-DUMMY.
004300     COMPUTE THE-PRODUCT = THE-NUMBER * THE-MULTIPLIER.
004400     DISPLAY
004500     THE-NUMBER " * " THE-MULTIPLIER " = " THE-PRODUCT.

004100 CALCULATE-AND-DISPLAY.
004200     ADD 1 TO THE-MULTIPLIER.
004210     
004220     ADD 1 TO INTERIM-LINE-NUMBER.
004230     IF INTERIM-LINE-NUMBER IS EQUAL TO THE-LIMIT-PER-ROUND
004235      MOVE 1 TO INTERIM-LINE-NUMBER
004245      DISPLAY "Press Enter to continue..." WITH NO ADVANCING
004250      ACCEPT THE-DUMMY
004251     ELSE COMPUTE THE-PRODUCT = THE-NUMBER * THE-MULTIPLIER
004400     DISPLAY
004500     THE-NUMBER " * " THE-MULTIPLIER " = " THE-PRODUCT.

The latter segment is MULT04.cob, the former MULT03.cob.

martin@martin-1001PX:~/CobolProjects$ diff MULT03.cob MULT04.cob
59c59
< 004230     IF INTERIM-LINE-NUMBER IS GREATER THAN THE-LIMIT-PER-ROUND
---
> 004230     IF INTERIM-LINE-NUMBER IS EQUAL TO THE-LIMIT-PER-ROUND
61,63c61,63
< 004240      DISPLAY "Press Enter to continue..." WITH NO ADVANCING
< 004250      ACCEPT THE-DUMMY.
< 004300     COMPUTE THE-PRODUCT = THE-NUMBER * THE-MULTIPLIER.
---
> 004245      DISPLAY "Press Enter to continue..." WITH NO ADVANCING
> 004250      ACCEPT THE-DUMMY
> 004251     ELSE COMPUTE THE-PRODUCT = THE-NUMBER * THE-MULTIPLIER
Peter O.
  • 32,158
  • 14
  • 82
  • 96

1 Answers1

0

The problem is a full-stop on the IF block. Try to not use full-stop periods. Instead, use the corresponding scope terminators; in this case END-IF.

This should work:

004100 CALCULATE-AND-DISPLAY.
004200     ADD 1 TO THE-MULTIPLIER.
004210     
004220     ADD 1 TO INTERIM-LINE-NUMBER.
004230     IF INTERIM-LINE-NUMBER IS EQUAL TO THE-LIMIT-PER-ROUND
004235      MOVE 1 TO INTERIM-LINE-NUMBER
004245      DISPLAY "Press Enter to continue..." WITH NO ADVANCING
004250      ACCEPT THE-DUMMY
004251     ELSE COMPUTE THE-PRODUCT = THE-NUMBER * THE-MULTIPLIER
           END-IF
004400     DISPLAY
004500     THE-NUMBER " * " THE-MULTIPLIER " = " THE-PRODUCT.
Molusco
  • 59
  • 6
  • 2
    No. The problem is that the PROGRAM-ID is different from the filename (before the first fulll-stop/period in the filename) and it is a 1.1 version go GnuCOBOL where the identification of the problem is a more general message. This was previously discussed in the extensive comments on the question, which have been entirely cleared away. The PROGRAM-ID was still MULT03, when it should have been changed to MULT04. – Bill Woodger Mar 15 '16 at 16:37