Picture clause
Encyclopedia
A picture clause is an element in programming languages that is used to describe a datum
, by using sample characters that indicate the item characteristics and size.
(Commercial Translator) language developed by Bob Bemer
of IBM
in 1957. In 1959, it was incorporated into the original definition of COBOL
. Since then, many other programming languages have copied this feature.
Datum
A geodetic datum is a reference from which measurements are made. In surveying and geodesy, a datum is a set of reference points on the Earth's surface against which position measurements are made, and an associated model of the shape of the earth to define a geographic coordinate system...
, by using sample characters that indicate the item characteristics and size.
History
The picture clause was first used in the COMTRANCOMTRAN
COMTRAN is an early programming language developed at IBM. It was intended as the business programming equivalent of the scientific programming language FORTRAN . It served as one of the forerunners to the COBOL language...
(Commercial Translator) language developed by Bob Bemer
Bob Bemer
Robert William Bemer was a computer scientist best known for his work at IBM during the late 1950s and early 1960s.-Biography:...
of IBM
IBM
International Business Machines Corporation or IBM is an American multinational technology and consulting corporation headquartered in Armonk, New York, United States. IBM manufactures and sells computer hardware and software, and it offers infrastructure, hosting and consulting services in areas...
in 1957. In 1959, it was incorporated into the original definition of COBOL
COBOL
COBOL is one of the oldest programming languages. Its name is an acronym for COmmon Business-Oriented Language, defining its primary domain in business, finance, and administrative systems for companies and governments....
. Since then, many other programming languages have copied this feature.
Formatting
A picture clause is made up of various format characters, each of which represents a certain portion of the data item. Each format character can be repeated or followed by a repeat number, which specifies the number of times the format item occurs in the data item. Some examples (from COBOL) are:Character | Description |
---|---|
A | Alphabetic character (A-Z, a-z, or blank) |
B | Blank (space) character |
CR | Sign indicator ('CR' if negative, blanks if positive) |
DB | Sign indicator ('DB' if negative, blanks if positive) |
E | Floating-point exponent |
G | Double-byte (DBCS DBCS A double-byte character set is a character set that represents each character with 2 bytes. The DBCS supports national languages that contain a large number of unique characters or symbols... ) graphic/alphanumeric character |
N | Double-byte (DBCS) character |
P | Implied scaling digit (not displayed) |
S | Implied sign (not displayed) |
V | Implied decimal point (not displayed) |
X | Any character, alphabetic, numeric, or other symbols |
Z | Numeric digit, but leading-zero-suppressed (replaced by a blank when equal to zero) |
0 | Inserted '0' digit |
9 | Numeric digit (0-9) |
/ | Inserted '/' character |
, | Inserted digit group separator |
. | Inserted decimal point |
+ | Sign ('-' if negative, '+' if positive) |
- | Sign ('-' if negative, blank if positive) |
$ | Floating currency sign (blank for leading zeroes, '$' to the left of the most significant digit, otherwise digit 0-9) |
* | Floating digit fill ('*' for leading zeroes, otherwise digit 0-9) |
Examples
picture clause | data type | sample contents |
---|---|---|
PIC 999 | 3-digit number | 123, 005, 087, any number from 000 through 999 |
PIC S999 | 3-digit internally signed number | +123, -005, +087, any number from -999 through +999 |
PIC +999 | 3-digit output signed number | +123, -005, +087, any number from -999 through +999, with sign displayed. |
PIC ZZ9 | 3-digit number, leading zeros suppressed | 123, 5, 87, any number from 000 through 999 |
PIC A(8) | 8-character alphabetic string | "Fredrick", "Fred ", "Fred Jr ", any string of 8 alphabetic letters (may include spaces) |
PIC X(8) | 8-character string | "Smithson", "O'Riley ", "Bon-Jovi", "23Skidoo", any string of 8 characters (may include any valid character) |