Copybook (programming)

Copybook (programming)

A copybook is a section of code written in a high-level programming language or assembly language that can be copied (from a master) and inserted into several different programs (or multiple places in a single program). It is often used to define the physical layout of program data, pieces of procedural code and prototypes.

The term "copybook" may have originated from use of COBOL on IBM mainframe operating systems: COPY is the COBOL keyword for this, and the master item was stored as a “book” within a larger library of source code.[1]

Major reasons for using COPYBOOKs in assembly language or COBOL are to:

  • ensure that everyone uses the same version of a data layout definition or procedural code.
  • make it easier to cross reference where components are used in a system.
  • make it easier to change programs when needed (only one master copy to change).
  • save programmer time by not needing to code extensive data layouts (minor, but useful).

RPG IV supports the COPYBOOK concept exactly as in COBOL; here COPYBOOKs are most commonly used to define PROTOTYPEs of RPG IV procedures.

Influence

Since COBOL defined the COPY statement in 1959, many other languages have included a similar feature, often using “include” as a keyword (e.g. Fortran, ALGOL, PL/I, C, C++ and HTML). The term “copybook” is mainly used in an IBM mainframe context; other languages have different names and syntaxes:

  • COPY text-name. (COBOL),
  • /COPY QCPYLESRC,QBC (RPG IV – first argument is the filename, second argument is the copybook),
  • include ... (Fortran),
  • %include ... (PL/I),
  • #include ... (C and C++),
  • include ... (MASM),
  • <!--#include ... --> (HTML SSI),
  • <%@ include ... %> (JSP). [2].

Several languages have a replacement feature in their copybook syntax. This allows a programmer to replace certain text in the copybook with other text when copying it into the program. This makes the copybook more versatile, since it can be re-used in the same program. For example, the same copybook can be used to describe the input and output files within the same program.

Replacements in COBOL are invoked using the second form of the COPY statement:

  • COPY text-name REPLACING item-1 BY item-2.

Modern languages (e.g. Haskell and Java) tend to avoid copybooks or includes, preferring modules and import/export systems for namespace control.

References

  • "BEA WebLogic Integration Glossary", Version 2.1. unsigned. BEA Systems, Inc., October 2001. [3], accessed: 2006/07/06.
  • RPGLE Copybooks

Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • Copybook — may refer to: Copybook (education), a book containing examples and space for writing down copies of the examples. Copybook (programming), source code that can be copied or included into other programs. This disambiguation page lists articles… …   Wikipedia

  • COBOL — For other uses, see COBOL (disambiguation). COBOL LANGUAGE Paradigm(s) procedural, object oriented Appeared in 1959 (1959) Designed by Grace Hopper, William Selden, Gertrude Tierney, Howard Bromberg, Howard Discount, Vernon Reeves, Jean E.… …   Wikipedia

  • IBM Information Management System — (IMS) is a joint hierarchical database and information management system with extensive transaction processing capabilities. History IBM designed IMS with Rockwell and Caterpillar starting in 1966 for the Apollo program. IMS s challenge was to… …   Wikipedia

  • Brave New World — This article is about the novel. For other uses, see Brave New World (disambiguation). Brave New World   …   Wikipedia

  • Dclgen — A declarations generator or DCLGEN (pronounced dekel jin) is a table schema used by COBOL programs that work against a database, often IBM DB2 on a mainframe. Contents 1 Composition 2 Example 3 Usage 4 …   Wikipedia

  • Include — Das Substantiv Include (von englisch to include = einschließen ) (in Cobol: Copy Element oder kurz Copy genannt) [1]) ist eine unter Programmierern übliche Bezeichnung für eine Routine oder eine Dateibeschreibung, die von mehreren Programmen …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”