Volt
00000000

Guide

Mainframe files on a Mac: records, copybooks and COBOL

An extract from z/OS does not look like a text file to a Mac: the bytes are EBCDIC, the lines end with NEL or do not end at all, and the records are eighty columns wide with nothing between them. Here is how to work with one.

Why a mainframe file defeats an ordinary editor

Three assumptions that every modern editor makes, and a mainframe file breaks all three at once.

  • That the bytes are ASCII or UTF-8. They are EBCDIC, in one of sixty-two national code pages.
  • That lines end with 0x0A. They end with NEL, 0x15 — or they do not end at all.
  • That the file has lines. Plenty of mainframe data is a run of fixed-width records, or records each prefixed with their own length, with nothing between them.

The result is the familiar one: a screen of accented punctuation on a single line several megabytes long, in a file the editor took a minute to load.

Records instead of lines

FormatWhat is in the fileWhat Volt does
IBM RDW Variable-length records, each preceded by a four-byte record descriptor word giving its length. No terminator of any kind. Reads the descriptor chain, turns each record into a line on opening, and writes the descriptors back on saving.
Fixed 80-column Punch-card images: every record exactly eighty characters, padded with spaces, run together with nothing between them. Splits at the record length and restores the padding when saving, so the file goes back the shape it came in.
Fixed 132-column Line-printer output, same idea at printer width. The same.
No line breaks at all A file with no 0x0A anywhere, which may genuinely be one long line or may be records. Checks whether the record structure holds before deciding, rather than assuming either.

COBOL, and the other languages nobody writes tutorials about

Volt highlights COBOL (.cob, .cbl, .cpy) along with the rest of the languages that keep businesses running rather than trending: ABAP, PL/SQL, Visual Basic and VBA, Delphi and Object Pascal, Visual FoxPro, Fortran, Ada, SAS, VHDL and X++.

What sets these apart is not their grammar but their comments. COBOL, ABAP, FoxPro and SAS treat a marker as a comment only in the first column — anywhere else the same * is multiplication — and in Visual Basic the apostrophe that quotes a string in most languages starts a comment instead. An editor that gets this wrong colours half the file as a comment, which is exactly how you fail to notice a line of real code. The full list of languages is here.

A copybook-and-extract workflow on a Mac

  • Open the extract. If it is EBCDIC it is read as EBCDIC, and the status bar names the code page it chose and why.
  • If it has no line breaks, the records become lines — RDW by its descriptors, fixed-width by its record length.
  • Open the copybook beside it; .cpy is highlighted as COBOL.
  • Use the hex view when a field boundary is in doubt: offsets, bytes and the printable column together.
  • Edit, then save back in the same code page and record format — or convert to UTF-8 with ordinary line endings if the file is going somewhere modern.

Size is not the obstacle it usually is

Mainframe extracts are rarely small. A 4.23 GB file of 50.4 million lines opens in 2 milliseconds on a few megabytes of memory, so the record and character-set work happens on a file that is already open rather than after a minute of loading. More on large files on a Mac.

Questions

How do I read an IBM RDW file on a Mac?

Open it in an editor that understands record descriptors. Volt reads the four-byte descriptor chain, turns each record into a line when the file opens, and writes the descriptors back when it saves, so the file returns in the shape it arrived.

What about fixed-width 80-column files with no line breaks?

They are split at the record length — 80 for punch-card images, 132 for line-printer output — and the padding is restored on saving. A file with no 0x0A in it is checked for record structure rather than assumed to be one very long line.

Does Volt highlight COBOL?

Yes, for .cob, .cbl, .cpy and .cobol, with the first-column comment rule that COBOL actually uses. ABAP, PL/SQL, Visual Basic and VBA, Delphi, Visual FoxPro, Fortran, Ada, SAS, VHDL and X++ are highlighted too.

Can I convert a mainframe extract to something modern?

Yes. Open it in its EBCDIC code page and record format, then save it as UTF-8 with LF endings; the character set, the line endings and the record structure are all handled in the same pass.

Do I need anything installed alongside it?

No. Volt is one binary of about six megabytes, written in Swift with no third-party dependencies — no Java runtime, no terminal emulator, no conversion utility to chain together.

Try it on your own file

Volt is in private beta. Join the waitlist and you will be invited when the next round goes out — one email, and then one question about what to build next.

Join the waitlist