AskDefine | Define copybook

Dictionary Definition

copybook n : a book containing models of good penmanship; used in teaching penmanship

User Contributed Dictionary

English

Noun

  1. A student’s exercise book containing samples of good handwriting to be copied
  2. A series of instructions or data definitions copied into multiple programs from a shared library; boilerplate

Extensive Definition

A copybook is the section of code in a high-level computer programming language that is copied from a master copy and inserted in several different programs (or multiple places in a single program). It is most frequently used to define the physical layout of data (either in an input or output file (file schemas), or in a temporary area (working storage)), but can also be used for sections of procedural code.
The term 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 http://e-docs.bea.com/wlintegration/v2_1/gloss/glossary.htm.
Major reasons for using COPYBOOKs are to:
  • ensure that everyone uses the identical 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 long data layouts (minor, but useful).
Since COBOL defined the COPY statement in 1959, most other languages have included a similar feature. Fortran, ALGOL, and PL/I all have this; even recent languages like C or C++, HTML, and Java have this feature.
The term "copybook" is mainly used in a COBOL or IBM mainframe context. Other languages often refer to it as an "include", because that keyword is used in their syntax: include (Fortran), %include (PL/I),
  1. include (C and C++),
(HTML SSI), (JSP), import (Java). http://e-docs.bea.com/wlintegration/v2_1/gloss/glossary.htm.
Many 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. (See the COBOL syntax below for an example of the replacing facility.

COBOL Syntax

The copybook is invoked in COBOL by the COPY statement, which has two forms:
  1. COPY text-name.
  2. COPY text-name REPLACING item-1 BY item-2.

References

Privacy Policy, About Us, Terms and Conditions, Contact Us
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2
Material from Wikipedia, Wiktionary, Dict
Valid HTML 4.01 Strict, Valid CSS Level 2.1