0

我有 Ubuntu 12.04.5,我已经安装了 GnuCOBOL 平台,并且我已经编写了 GnuCOBOL 一段时间没有问题。

我现在正在做一些非常微不足道的事情:我有一个程序 MULT03.cob,我已经编译并运行如下:

    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$

然后我所做的是我在程序代码中引入了一个真正的微观变化(我确信问题在更高的层次上,在链接/环境变量或其他方面,但我没有改变任何东西)并得到

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 基本上是 MULT03.cob 更改了两行。两者都在目录、源代码、目标代码和所有内容中:

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

我很想知道是什么让运行时系统找到了一个而不是另一个。我尝试过以不同的方式命名 MULT04(不是必须的,只是为了排除错误源)。其他早期程序编译和运行没有问题:

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

这些是(略有不同的)代码段:

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.

后段是MULT04.cob,前段是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
4

1 回答 1

0

问题是块上的句号IF。尽量不要使用句号。相反,使用相应的范围终止符;在这种情况下END-IF

这应该有效:

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.
于 2016-03-15T15:22:27.100 回答