“复制"带有"REPLACING"的声明在COBOL中 [英] "COPY" statement with "REPLACING" in COBOL

查看:501
本文介绍了“复制"带有"REPLACING"的声明在COBOL中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到编译错误,

在嵌套的"COPY"中找到带有"REPLACING"短语的"COPY"语句.

A "COPY" statement with "REPLACING" phrase was found within a nested "COPY".

这是我们的编译设置,不能在嵌套副本中使用REPLACING动词. 我们有一本习字簿,其中包含多个替换动词的复制语句. 谁能帮助我解决此错误?

This is our compilation setting that we can not use REPLACING verb in nested copy. We have one copybook which is having multiple copy statements with replacing verb. Can anyone help me to resolve this error?

推荐答案

在COBOL中嵌套COPYBOOKS有点技巧.一般来说 您只能嵌套抄写本,除非它们不嵌套 包含REPLACING短语,并且不会引起递归.

Nesting COPYBOOKS in COBOL is a bit of a trick. In general you may nest copybooks only if they do not contain the REPLACING phrase and do not cause recursion.

假设您有以下两本抄写本:

Suppose you had the following two copybooks:

COPYBOOK ABC

  01 :A:-VAR-A1     PIC X.
  01 :A:-VAR-A2     PIC X.
  COPY XYZ REPLACING ==:A:== BY ==B==.

COBPYOOK XYZ

  01 :A:-VAR-X1     PIC X.
  01 :A:-VAR-X2     PIC X.

不允许在COPYBOOK ABC中嵌套,因为它包含一个REPLACING短语.

The nesting in COPYBOOK ABC is not allowed because it contains a REPLACING phrase.

但是,您可以执行以下操作.从COPYBOOK ABC中删除RELACING,因此 它变成:

However, you can do the following. Drop RELACING from COPYBOOK ABC so it becomes:

COPYBOOK ABC

  01 :A:-VAR-A1     PIC X.
  01 :A:-VAR-A2     PIC X.
  COPY XYZ.

现在将COPYBOOK ABC包含在您的源程序中,如下所示:

Now include COPYBOOK ABC into your source program as follows:

  REPLACE ==:A:== BY ==B==.
  COPY ABC.
  REPLACE OFF.

REPLACE指令导致所有:A:出现 被B替换,直到遇到REPLACE OFF指令为止,并且这些 所有COPY指令均已执行后,将进行替换.互联网 以上语句的结果将是:

The REPLACE directive causes all occurances of :A: to be replaced by B until a REPLACE OFF directive is encountered, and these replacements occur after all COPY directives have been actioned. The net result of the above statements would be:

  01 B-VAR-A1     PIC X.    <== from ABC
  01 B-VAR-A2     PIC X.    <== from ABC
  01 B-VAR-X1     PIC X.    <== Nested copy of XYZ from ABC
  01 B-VAR-X2     PIC X.    <== Nested copy of XYZ from ABC

这是对嵌套抄写本进行替换的唯一合法"方式 在我所知道的COBOL中.

This is the only 'legal' way of performing replacements to nested copybooks in COBOL that I am aware of.

这篇关于“复制"带有"REPLACING"的声明在COBOL中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆