COBOL论文翻译-093303-张爽.docx

上传人:苏美尔 文档编号:11738966 上传时间:2021-09-02 格式:DOCX 页数:10 大小:44.59KB
返回 下载 相关 举报
COBOL论文翻译-093303-张爽.docx_第1页
第1页 / 共10页
COBOL论文翻译-093303-张爽.docx_第2页
第2页 / 共10页
COBOL论文翻译-093303-张爽.docx_第3页
第3页 / 共10页
COBOL论文翻译-093303-张爽.docx_第4页
第4页 / 共10页
COBOL论文翻译-093303-张爽.docx_第5页
第5页 / 共10页
点击查看更多>>
资源描述

《COBOL论文翻译-093303-张爽.docx》由会员分享,可在线阅读,更多相关《COBOL论文翻译-093303-张爽.docx(10页珍藏版)》请在三一文库上搜索。

1、长春工业大学毕业设计(论文)外文翻译一一原文COBOL论文翻译-093303-张爽Improving Program Productivity Using The COPYOBJECTIVESTo familiarize you with:The COPY statement for copying parts of a program that are stored in a library.CONTENTS Introduction Entries that Can Be Copied An Example The Full Format for the COPY Statement1.

2、INTRODUCTION:A COPY statement is used to bring Into a program a series of prewritten COBOL entries that have been stored in a library. Copying entries from a library, rather than coding them, has the following benefits: (1) it could save a programmer a considerable amount of coding and debugging tim

3、e; (2) it promotes program standardization since all programs that copy entries from a library will be using common data-names and/or procedures; (3) it reduces the time it takes to make modifications and reduces duplication of effort; if a change needs to be made to a data entry, it can be made Jus

4、t one in the library without the need to alter individual programs; and (4) library entries are extensively annotated so that they are meaningful to all users; this annotation results in better-documented programs and systems.Most often, the COPY statement is used to copy FD and 01 entries that defi

5、ne and describe files and records. In addition, standard modules to be used in the PROCEDURE DIVISION of several programs may also be stored in a library and copied as needed.Organizations that have large databases or files that are shared make frequent use of libraries from which entries are copied

6、. Students may also find that file and record description entries for test data for programmingassignments have been stored in a library, which may then be copied when needed.Each computer has its own machine-dependent operating system commands for creating and accessing a library. You will need to

7、check you computer center for the required entries.2. ENTRIES THAT CAN BE COPIED:With the COPY statement, you may include prewritten ENVIRONMENT DATA, or PROCEDURE DIVISION entries in your source programs as follows:ENVIRONMENT DIVISION:Option 1 (within the CONFIGURATION SECTION)SOURCE-COMPUTER. COP

8、Y text-name,library-name.OBJECT-COMPUTER. COPY text-name,librar)-name.SPECIAL-NAMES. COPY text-name,librarv-name.Option 2 (within the INPUT-OUTPUT SECTION)FILE-CONTROL. COPY text-name,library-name.I-O-CONTROL. COPY text-name,librarj-name.DATA DIVISION:Option 1 (within the FILE SECTION)FD file-name C

9、OPY text-namejibrar-name.Option 2 (within a File Description entry)01 data-name COPY text-name,library-name.PROCEDURE DIVISION:Paragraph-name. COPY text-namejibrary-name.The librar)-namc is an external-name- It should be 1 to 8 characters and include letters and digits only.3. AN EXAMPLE:Suppose we

10、have created a library entry called CUSTOMER that contains the following:01 CUSTOMER-REC-3长春工业大学毕业设计(论文)外文翻译一一原文PIC X(5).PIC X(20).PIC X(30).PIC 9(4)V99.05 CUST-NO05 CUST-NAME05 CUST-ADDRESS05 CUST-BAL-DUETo copy the entries in CUSTOMER into our source program, code the following at the point in the

11、 program where you want the entries to appear:COPY CUSTOMERThe source listing would appear as follows (we use lowercase letters for the copied library entries to distinguish them from the source program coding):1 IDENTIFICATION DIVISION.2 PROGRAM-ID. CUST01. The numbers are source statement line num

12、bers 10 DATA DIVISION.11 FD CUSTFILE.The lines that include a C,12 *after the line number are13 COPY CUSTOMER.the copied statements14C 01 customer-rec.15C05 cust-nopic x(5).16C05 cust-namepic x(20).17C05 cust-addresspic x(30).18C05 cust-bal-duepic 9(4)v99.The C following the source program line numb

13、ers indicates that these entries have been copied from a library. Some systems use an L (for library) or another letter to distinguish copied entries from programmer-supplied ones.As noted, other prewritten program entries besides file and record descriptions can also be copied.2. THE FULL FORMAT FO

14、R THE COPY STATEMENT:A COPY statement can be used not only to copy prewritten entries but to make certain changes to them in the source program. The full format for theCOPY is:Format:COPY test-name-1,library-name-1=pseudo-text-1 = identifier-1literal-1word-1=pseudo-text-2= identifier-2literal-2word-

15、2If the REPLACING clause is omitted from the COPY statement, the library 7Vtext is copied unchanged.The REPLACING option allows virtually any library entry to be changed when it is being copied into the user,s source program. This includes COBOL entries as well as comments or other elements that wou

16、ld appear as pseudo-text. Literals and identifiers can also be changed as well as “words” that refer to COBOL reserved words.Example: Using the library entry called CUSTOMER in the preceding example, suppose we code:COPY CUSTOMER REPLACING CUST-NO BYCUST-NUMBER, =X(5)= BY=X(6)=.This results in the f

17、ollowing changes to the library entry when it is called into the source program:14C 01 customer-rec.15C05 cust-number plc x(6). BY文字-2单词-1单词-2COPY文本名1,库名1如果REPLACING子句被从COPY语句中省略,那么库文本将被没有改变 的复制。REPLACING选项实质上允许任何库条目在被复制到用户的源程序中时被改变。这包括COBOL条目和注释或者其它可能会被显示为“伪文本”的元素。 文字和标识符也能如那些引用到COBOL保留字的“单词”一样被改变。

18、9长春工业大学毕业设计(论文)外文翻译一一原文例子:在前面的例子中用到了被称为“CUSTOMER”的库条目,设想我们编 了一下代码:COPY CUSTOMER REPLACING CUST-NO BYCUST-NUMBER, =X(5)= BY=X(6)=.这导致了库中的条目发生一下的变化,当其在源程序内部被访问时:14C 01 customer-rec.15C05 cust-numberpic x(6).一数据名和PIC子句被改变了16C05 cust-name pic x(20).17C05 cust-addresspic x(30).18C05 cust-bal-duepic 9(4)v

19、99.REPLACING子句不会改变库中预先写好的条目。即:只可能对用户的源 程序做出修改。通常情况下,是那些有着长且复杂的记录描述的FD被复制到程序中,就像 条屏甚至模块或段中常见的多个程序一样。表也能被复制。在第12章中,我们看到一些表被用VALUE子句直接编码 到工作储存节中。设想一下,学生文件中的一个记录包含一个代码(0140)以 此来区分每个学生的专业。如果学校只有10个专业,并且这些专业都不大可能 发生改变,我们可以在COBOL程序中对其进行如下编码:02 MAJOR-TABLE VALUE 4ART HIS ECO MAT CSC PHI BIO ENG SOC PSY.05 EACH-MAJOR OCCURS 10 TIMES PIC X(4).这个表由10个四位长的专业组成,当专业编码为1时表示此专业为艺术专 业,当专业编码为2时表示此专业为历史专业,等等。很有可能不止一个文件在处理学生信息时要使用这张表。比如:一个校友 文件,一个部门文件,或者是一个个人文件,都有可能需要这些表条目。因此, 最好把数据存放在库中并允许它被复制到需要它程序中去。此外,因为存在专 业编码在极少数情况下发生改变的可能,你需要把表中的数据存放在单一位置 以便让任何的改变只发生一次。10

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 科普知识


经营许可证编号:宁ICP备18001539号-1