Hacker News new | past | comments | ask | show | jobs | submit login

Ah, nothing that complicated :) It's a data structure with named fields. Each field can be a different type and they are in specific positions in the data structure so that it forms a pattern with strongly typed components.

COBOL's type definitions are also patterns really - for instance you declare a field to be of type 9(7) which means a numeric field of length 7 and so on.

The whole setup gives you very fine control over the structure of your data. For example, you can describe lines of a document to be printed out with strongly typed fields to be filled in by your program, so a form basically.

It's also used as a template for documents like VSAM files. Those are flat-file databases and the COBOL program's working storage imposes structure on them.

Here's a small example:

01 FILE-RECORD.

__03 WS-ACCOUNT_____PIC 9(10).

__03 WS-SEPARATOR1__PIC X.

__03 WS-NAME________PIC S(25).

__03 WS-SEPARATOR2__PIC X.

[Underscores are formatting only, not COBOL syntax]

That declares a structure called FILE-RECORD with four named fields, one of numeric type with length 10, one of alphabetic type with length 25 and two of alphanumeric type with length 1. So that's one record in your file structure and you can fill it in with data from VSAM files and the like, then print it out, with the separator fields for formatting.

It's a strange thing, low-level and high-level at the same time, in a very nice way. It kind of grows on you. Well, it's grown on me anyway. Of course, YMMMV.

Btw, the numbers (01, 03) make the hierarchical relation between the root of the data structure and each of its fields explicit; I won't say I'm in love with that sort of syntax :)

Also, I'm a total no0b still, so I might have made some mistake above, apologies in advance if that is the case.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: