搜索表 (COBOL)

发布于 2024-10-16 16:53:00 字数 828 浏览 4 评论 0原文

我第一次尝试使用桌子,但遇到了一个小障碍。我已经弄清楚如何制作表格,但我不知道如何搜索表格或将存储的信息移动到另一个字段。这是表格:

   01  SALESMAN-TABLE.
       05  TABLE-ENTRIES OCCURS 99 TIMES.
           10 SALESMAN-NUMBER              PIC 99    VALUE ZEROS.
           10 SALESMAN-NAME                PIC X(20) VALUE SPACES.
   01  SALESMAN-COUNT                      PIC 9(3)  VALUE ZEROS.

这是我到目前为止尝试搜索数据的内容:

   510-TABLE-SEARCH.
       SEARCH TABLE-ENTRIES
           WHEN SALESMAN-NUMBER (ROUTINE-CHECK) = ROUTINE-CHECK
               PERFORM 520-WRITE-FILE
           WHEN SALESMAN-NUMBER (ROUTINE-CHECK) = 0
               CONTINUE
       END-SEARCH.

这就是我用来移动数据的内容:

       SET DL-NAME-COLUMN TO SALESMAN-NAME

但它说 DL-NAME-COLUMN 应该是数字,即使 SALESMAN-NAME 是字母数字。我应该怎么办?任何帮助将不胜感激。

I have been trying to use a table for the first time and I have hit a small snag. I have figured out how to make a table, but I cannot figure out how to search the table or move the stored information to another field. Here is the table:

   01  SALESMAN-TABLE.
       05  TABLE-ENTRIES OCCURS 99 TIMES.
           10 SALESMAN-NUMBER              PIC 99    VALUE ZEROS.
           10 SALESMAN-NAME                PIC X(20) VALUE SPACES.
   01  SALESMAN-COUNT                      PIC 9(3)  VALUE ZEROS.

This is what I got so far to try and search for data:

   510-TABLE-SEARCH.
       SEARCH TABLE-ENTRIES
           WHEN SALESMAN-NUMBER (ROUTINE-CHECK) = ROUTINE-CHECK
               PERFORM 520-WRITE-FILE
           WHEN SALESMAN-NUMBER (ROUTINE-CHECK) = 0
               CONTINUE
       END-SEARCH.

And this is what I am using to move the data:

       SET DL-NAME-COLUMN TO SALESMAN-NAME

but it says that DL-NAME-COLUMN should be numeric even though SALESMAN-NAME is alphanumeric. What should I do? Any help will be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

若水般的淡然安静女子 2024-10-23 16:53:00

您应该使用以下内容对表进行索引:

05  TABLE-ENTRIES OCCURS 99 TIMES INDEXED BY IND-TABLE-ENTRIES.

然后您可以使用 SEARCH 动词:

510-TABLE-SEARCH.
   SEARCH TABLE-ENTRIES
       UNTIL SALESMAN-NUMBER (IND) = 0
       WHEN SALESMAN-NUMBER (IND) = ROUTINE-CHECK
           PERFORM 520-WRITE-FILE
   END-SEARCH.

表索引始终是数字,因为它们用作指针(它们包含内存地址)。 SET 动词通常用于修改表索引。

You should index your table using something like:

05  TABLE-ENTRIES OCCURS 99 TIMES INDEXED BY IND-TABLE-ENTRIES.

Then you can use the SEARCH verb:

510-TABLE-SEARCH.
   SEARCH TABLE-ENTRIES
       UNTIL SALESMAN-NUMBER (IND) = 0
       WHEN SALESMAN-NUMBER (IND) = ROUTINE-CHECK
           PERFORM 520-WRITE-FILE
   END-SEARCH.

Table indices are always numeric since they are used as pointers (they contain a memory address). The SET verb is normally used to modify table indices.

笑看君怀她人 2024-10-23 16:53:00

使用

MOVE SALESMAN-NAME (IND)   TO DL-NAME-COLUMN

而不是

SET DL-NAME-COLUMN TO SALESMAN-NAME

Use

MOVE SALESMAN-NAME (IND)   TO DL-NAME-COLUMN

instead of

SET DL-NAME-COLUMN TO SALESMAN-NAME
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文