Computing: DOS, OS/2 & Windows Programming

Developing COBOL 74 programs on DOS.

"We believe this is the fastest COBOL compiler on any micro; for example we have compiled 4500 statements per minute on an IBM-AT. Utah COBOL is based on ANSI-74 standards with powerful level 2 features, including compound conditionals & full CALL CANCEL. Speed and simplicity are certain to make it a favorite in the classroom as well as with professional programmers."

The paragraph above is how Utah COBOL, by Ellis Computing, was introduced in the computer magazine "BYTE" from October 1985. Version 5.0.1 (1988) is available for free at Vetusware.

The download archive contains the folder structure, in fact one directory with all files. I unpacked it on my Windows 10 and, because the files don't fit on a floppy diskette, I burned them onto a CDROM (aka created a CD ISO). On my FreeDOS, I created the directory C:\UTCOBOL and copied all files from the CD to there. Supposing that the current directory is C:\ and F: being my CD drive letter:
    MKDIR UTCOBOL
    CD UTCOBOL
    F:
    COPY *.* C:

The screenshot shows the content of my C:\UTCOBOL directory.

COBOL on FreeDOS: Files of Utah COBOL 5.0.1

Unfortunately, the installation files don't include any documentation (the original software was distributed together with a printed manual), and so I didn't figure out all features. The package includes an editor (EDIT.EXE). However, it has no menu bar, and F1 doesn't display help content, as is usually the case. So, no idea how to use it. Simple work-around: Delete the file (or rename it to UTEDIT.EXE). This will result in using the default FreeDOS editor instead. The package also includes an executable called VIDPOP.EXE. No idea, what's its purpose. Maybe, that it should be run, or has to be run in certain cases (with the "/S" option) before running (certain) Utah COBOL programs (?).

Utah COBOL includes a compiler (called CC.EXE) and a COBOL runtime (called RUN.EXE). COBOL source files have the extension .CBL, the compiler produces object files with the extension .OBJ. These may then be run using RUN.EXE. Is it possible to create DOS executables? The Utah COBOL installation files do not include a linker. As there isn't any library file either, I suppose that there is no way to include the COBOL runtime in a .EXE using the linker included with some other software package (?).

Important: To use the Utah COBOL development system, please, note the following:

  1. The source files must have the extension .CBL.
  2. The filename specified with CC.EXE is not .CBL, but of the form .SOW, where S is the drive containing the source file, O is the drive where the object file should be placed, and W is the drive where temporary work files should be placed. Example: To compile the program HELLO.CBL, with all files on the C: drive, the correct command is CC HELLO.CCC. This will compile the source file C:\<current-directory>\HELLO.CBL creating the object file C:\<current-directory>\HELLO.OBJ.
  3. This special extension naming convention is also true for the Utah editor. If you use the FreeDOS editor instead, the real file extension (.CBL) has to be specified, of course.
  4. To execute the program you can either use RUN HELLO, RUN HELLO.OBJ, or RUN HELLO.CCC.

Beside running the compiler from the command line, you can start all development tools from one place, running the batch file COBOL.BAT. In fact, this batch file runs the COBOL program T271 ("The Utah COBOL System")), that creates a menu, including items to edit, compile, and run a file, as well as to view the compilation errors.

COBOL on FreeDOS: Menu of 'The Utah COBOL System'

Use the Up and Down arrow keys to navigate within the menu. With EDIT, COMPILE, or RUN selected, hit ENTER. This places the cursor in the filename selection field; enter the filename (using the extensions, as mentioned above). As the Utah COBOL System uses filenames without a path, and the FreeDOS editor being in the actual PATH, the usage of this editor instead of the original Utah editor works all correctly from the menu.

Must I mention that the Utah COBOL System being a COBOL program with the source provided, you have the possibility to change it for adapting it to your needs, if you want?

Some notes concerning the COBOL language:

Here is the code of a simple "Hello World" program:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. HELLO.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       PROCEDURE DIVISION.
       BEGIN.
           DISPLAY UNIT "X2".
           DISPLAY "Hello world!".
           STOP RUN.
       END PROGRAM HELLO.

No idea, what's the meaning of the statement DISPLAY UNIT "X2". All that I can say is that if you omit it, several empty lines will be displayed before displaying the "Hello World!" text.

The screenshot on the left shows the file HELLO.CBL opened in the FreeDOS editor (started from the Utah COBOL System menu, and returning control to this system after exiting). The screenshot on the right shows the successful compilation.

COBOL on FreeDOS: Utah COBOL source file opened in FreeDOS editor
COBOL on FreeDOS: Successful compilation of a Utah COBOL program

As a further example, here is the code of my INTEREST.CBL, that calculates the annual interest of a loan with given interest rate. To note, that I did not succeed to figure out the correct syntax of the COMPUTE statement, that's why I used the MULTIPLY and DIVIDE statements instead.
       IDENTIFICATION DIVISION.
       PROGRAM-ID. INTEREST.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
           77 IAMOUNT PIC 9(6).
           77 TAMOUNT PIC 9(6)V99.
           77 RATE    PIC 99V9.
           77 YEAR    PIC 99.
           77 ZYEAR   PIC Z9.
           77 INT     PIC 9(6)V99.
           77 ZINT    PIC Z(5)9.99.
           77 ZAMOUNT PIC Z(5)9.99.
       PROCEDURE DIVISION.
       BEGIN.
           DISPLAY UNIT "X2".
           DISPLAY "Enter initial amount? ".
           ACCEPT IAMOUNT.
           DISPLAY "Enter Interest rate ? ".
           ACCEPT RATE.
           MOVE 1 TO YEAR.
           PERFORM CALCULATE-INTEREST 20 TIMES.
           STOP RUN.
       CALCULATE-INTEREST.
           MULTIPLY IAMOUNT BY YEAR GIVING INT.
           MULTIPLY RATE BY INT.
           DIVIDE INT BY 100.
           ADD INT TO IAMOUNT GIVING TAMOUNT.
           MOVE YEAR TO ZYEAR.
           MOVE INT TO ZINT.
           MOVE TAMOUNT TO ZAMOUNT.
           DISPLAY "At the end of year " ZYEAR ","
             "interest is " ZINT ", total amount is " ZAMOUNT ".".
           ADD 1 TO YEAR.
       END PROGRAM INTEREST.

The screenshot shows the program output.

COBOL on FreeDOS: Utah COBOL - Output of a simple interest calculation program

The Utah COBOL installation files include several COBOL examples, not really useful programs, but demonstrations how to implement given features. And I would say that the features available should make it possible to create serious COBOL programs: creation of menus, programming of the function keys, usage of colors (via the ANSI.SYS driver), variable length record files, ISAM files. That's not bad, is it?

To terminate the tutorial, here is a screenshot of the output of the program ANSICOLR.CBL. It requires that (N)ANSI.SYS is installed, what (normally) is the case by default on FreeDOS.

COBOL on FreeDOS: Utah COBOL - Colored output demo using (N)ANSI.SYS

If you find this text helpful, please, support me and this website by signing my guestbook.