17

In COBOL there are three picture clauses, A for alpha, X for alphanumeric, and 9 for numeric. But why is it called PIC or PICTURE. I am wondering where the name comes from?

2
  • 2
    Too bad Grace Hopper is no longer with us to answer the question. Commented May 16 at 17:44
  • Jean Sammet might have been a better choice! Commented May 25 at 17:37

2 Answers 2

26

Remember that COBOL was - in theory - designed for business people to be able to read and write. The PICTURE clause was the way that the data was intended to be displayed - that is, it was a PICTURE of the displayed value.

Modern languages use commands or functions with names like format for the same capability, but the strings that define the format may well ultimately trace their origins back to the same ideas that led to the codes like A, X, and 9 in the COBOL PICTURE clause.

Edited to add:

By default, COBOL variables were declared for display purposes (USAGE IS DISPLAY, but as this was the default, it didn't need to be specified); for numeric values, you could compute with them, but it wasn't efficient, as it would have to convert an EBCDIC (or ASCII) string into the internal binary representation to perform the computation. To get around this, one could specify USAGE IS COMPUTATIONAL (abbreviable to USAGE COMP) or USAGE IS COMPUTATIONAL-3 (abbreviable to USAGE COMP-3). USAGE COMP told the compiler to store the data in binary form, which made it more efficient for computational purposes. USAGE COMP-3 was essentially the same, except that the internal storage was in BCD (Binary-Coded Decimal) format. This was a format where each four bits represented one digit in the PICTURE. It's less efficient for computing than USAGE COMP, but more efficient than USAGE DISPLAY. The biggest advantage to USAGE COMP-3 was that it could represent decimals exactly, whereas not all decimal values could be accurately represented with USAGE COMP.

15
  • 1
    although FORTRAN's FORMAT codes very slightly predate Cobol. I wonder if the PICTURE clauses have any history in unit-record processing? Commented May 15 at 18:32
  • @scruss I remember there were format cides for key punches, maybe they're related. Commented May 15 at 18:44
  • @scruss - if you look at the structure and sections of a COBOL program, there's a lot of evidence that the language was really designed around the idea of processing files of records. As I recall, ISAM (Indexed Sequential Access Method) was actually built in to the language. Commented May 15 at 19:01
  • It seems self-evident to me - it's a picture of what a datum would look like. 999V99 is a picture of a 5-digit number with 2 decimal place. OK, 'v' is not entirely obvious as denoting the decimal point, but '.' was taken. Commented May 15 at 19:08
  • 1
    @dave - well, yeah, but if one is not of a Certain Age, one will not think of it being a PICTURE; the "in" thing is to call them FORMATs. If, G-dhelpus, COBOL were to be invented today, the declaration would probably be FOO FORMAT S9(4)V9(2) USAGE COMP. Commented May 15 at 19:13
19

To answer the question precisely, COBOL uses the word PICTURE because IBM Commercial Translator (COMTRAN) originated the concept, which it describes as a 'pictorial', using the same data syntax.

I'm unclear as to whether the word PICTURE appears in the actual language, but 'pictorial' to 'picture' is not a great leap.

The CODASYL committee that designed COBOL took ideas from several language, including FLOW-MATIC and COMTRAN.

COMTRAN general information manual

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.