关于COBOL的问题

sndcbu 2005-11-10 04:05:20
请问大家用COBOL语言开发程序时,用到过宏没有?就是类似COPY语句的一种东西吧,如果有谁有这方面的资料,能否给小弟介绍一下!拜托!!!
...全文
568 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
tiger5 2006-04-02
  • 打赏
  • 举报
回复




Text Words
The matching procedure in the REPLACING phrase operates on text words.


A text word is defined as ;


Any COBOL text enclosed in double equal signs (e.g. ==ADD 1==). This text is known as PseudoText and it allows us to replace a series of words or characters as opposed to an individual identifier, literal or word.


Any literal including opening and closing quotes


Any separator other than;
A space
A Pseudo-Text delimiter
A Comma
Any COBOL reserved word


Any Identifier.

Any other sequence of contiguous characters bounded by separators.


Text Word examples

MOVE
1 Text Word

MOVE Total TO Print-Total
4 Text Words - MOVE Total TO Print-Total

MOVE Total TO Print-Total.
5 Text Words - MOVE Total TO Print-Total .

PIC S9(4)V9(6)
9 Text words - PIC S9 ( 4 ) V9 ( 6 )

“PIC S9(4)V9(6)”
1 Text word - “PIC S9(4)V9(6)”
tiger5 2006-04-02
  • 打赏
  • 举报
回复
The COPY verb is generally used when creating large software systems. These systems are subject to a number of problems that the COPY verb helps to alleviate.

For instance, when data files are used by a number of programs in a large software system, it is easy for programmers describing those files to make errors in defining the key fields (Indexed files) or the file organization or the type of access allowed or the number, type and size of the fields in a record. Any errors in these descriptions may result in difficult-to-find bugs. For instance, if one program writes a file using an incorrect record description and the others read it using the correct description, a program crash may occur in in one of the correct subprograms rather than the one which actually has the problem.

Using copy libraries or files helps to reduce programmer transcription errors and also makes implementation simpler by reducing the amount of coding required. For instance, when a number of programs need to access the same file, the relevant file and record descriptions can be copied from a copy library instead of each programmer having to type their own (and possibly get them wrong).

Another advantage of using copy libraries is that they permit item descriptions such as file, record and table descriptions, to be kept and updated centrally in a copy library, often under the control of a copy librarian. This makes it more difficult for programmers to make ad hoc changes to file and record formats. Such changes generally have to be approved by the COPY librarian.



In a large software system using the COPY verb makes some maintenance tasks easier and safer. Certain changes may only require an update to the text in the copy library and a recompilation of any affected programs. If a copy library were not used each affected program would have to be changed
tiger5 2006-04-02
  • 打赏
  • 举报
回复
COPY statements in a COBOL program are very different from other COBOL statements. While other statements are executed at run time, COPY statements are executed at compile time.


A COPY statement is similar to the "Include" used in languages like C and C++. It allows programs to include frequently used source code text.

When a COPY statement is used in a COBOL program the source code text is copied into the program from from a copy file or from a copy library before the program is compiled.

A copy file, is a file containing a segment of COBOL code.

A copy library, is a collection code segment each of which can be referenced using a name. Each program that wants to use items described in the copy library uses the COPY verb to include the descriptions it requires.

When COPY statements include source code in a program, the code can be included without change or the text can be changed as it is copied into the program. The ability to change the code as it being included greatly adds to the versatility of the COPY verb.
aj092 2006-03-25
  • 打赏
  • 举报
回复
- -!
COBOL中类copy的宏...
copy句类似.h文件,就是把程序用到的一些变量 常量写在一个copy句中,其实是一个文件,然后在程序中使用:copy filename就可以了.
copy语句是将指定的文件格式(更准确应该叫数据结构)在你的程序中定义,不过放在"WORKING_STORAGE SECTION"与"LINKAGE SECTION"中的"copy"语句作用还是有区别的.
再有COBOL程序中的DATA DIVISION部分往往是很长的,因为其中包含许多的数据项的描述.可以利用COPY语句使某些记录描述和数据描述为不同的程序共用.为此要建立一个"源程序库",将上述这些共同使用的程序中的某一部分事先存入库中.
复制语句的一般形式
标识符1 标识符2
COPY 库名 REPLACE 常量1 BY 常量2 …
字1 字2
"子"的含义是不超过30个字符组成的字符序列.它包括数据名 条件名 过程名 表意常量 助忆名或保留字等.复写语句可以用在除标识部以外的其他三个部中,但在环境部中使用复写语句的意义不大.使用复写语句的目的是有利于在不同文件中用标准化的记录书写程序,减少写程序的工作量,便与程序的保存和修改.
虽然说的楼上的都说过了,但是在COBOL中类copy的宏的用法和目的都在这里了.
TonyH2002 2006-03-23
  • 打赏
  • 举报
回复
COBOL 问题可与我联系!
zhenzhen1 2006-03-15
  • 打赏
  • 举报
回复
COBOL程序中的DATA DIVISION部分往往是很长的,因为其中包含许多的数据项的描述。可以利用COPY语句使某些记录描述和数据描述为不同的程序共用。为此要建立一个“源程序库”,将上述这些共同使用的程序中的某一部分事先存入库中。
复制语句的一般形式
标识符1 标识符2
COPY 库名 REPLACE 常量1 BY 常量2 …
字1 字2
“子”的含义是不超过30个字符组成的字符序列。它包括数据名、条件名、过程名、表意常量、助忆名或保留字等。复写语句可以用在除标识部以外的其他三个部中,但在环境部中使用复写语句的意义不大。使用复写语句的目的是有利于在不同文件中用标准化的记录书写程序,减少写程序的工作量,便与程序的保存和修改。
jinguliang 2005-12-12
  • 打赏
  • 举报
回复
copy语句是将指定的文件格式(更准确应该叫数据结构)在你的程序中定义,不过放在“WORKING-STORAGE SECTION”与“LINKAGE SECTION”中的‘copy’语句作用还是有区别的。
changhuixp 2005-11-23
  • 打赏
  • 举报
回复
copy句类似.h文件,就是把程序用到的一些变量、常量写在一个copy句中,其实是一个文件,然后在程序中使用:copy filename就可以了。
飞飞狐 2005-11-16
  • 打赏
  • 举报
回复
又是对日外包吧
huaya0304 2005-11-15
  • 打赏
  • 举报
回复
不是回答问题:)

如果有COBOL专家,希望可以取得联系,多谢多谢!

3,423

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 其他开发语言
社区管理员
  • 其他开发语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧