Computing: DOS, OS/2 & Windows Programming

Installing and running VisualAge for COBOL on OS/2.

"VisualAge for COBOL for OS/2 is a powerful COBOL development tool with new function and key usability enhancements for OS/2 environment. It is designed to increase developer productivity, particularly when creating and maintaining host applications from your workstation.", they write on the Vetusware website, where you can download Visual Age for COBOL standard edition - OS/2 version 1.2. I tried in on OS/2 Warp 4.52; it should also work on Warp 4, and Warp 3.

VisualAge for COBOL for OS/2 is an amazing piece of software, that includes all that you need to build not only console programs, but also OS/2 desktop applications, the creation of the GUI not being done by complicated API-calls, but using a visual designer, that allows to create the GUI by dragging and dropping components, and automatically generates a part of the COBOL source. This tutorial is about the installation of the software, and about how to build programs for the command line. It does not include information about GUI applications. I will write some day a separate tutorial about that...

The download is a .7z archive (if you don't know how to open it, download the freeware 7-Zip). I unpacked the files on my Windows 10, and burned them onto a CDROM (aka: created a CD ISO). To install the software, on your OS/2 computer, open the CD-drive in Icon View, and double-click the file INSTALL.CMD.

After the display of an "Instructions" window, the setup program starts up, asking if you want to install the software. Be sure that the checkbox Update CONFIG.SYS is selected, when pushing the OK button.

VisualAge for COBOL on OS/2: Installation - Startup of the installation program

In the next window, you can select the components that you actually want to install. Besides the ones selected by default, I also selected the 4 not selected Warp Toolkit components. The default installation directory for all components is C:\IBMCOBOL; I kept this directory.

VisualAge for COBOL on OS/2: Installation - Components and installation directories selection

Files are copied from the CD to the harddisk. If you have selected to install the SMARTdata Utilities, an informational message box shows up, telling you that you'll be asked for some options controlling the behavior of SMARTsort. Then, the SMARTsort Defaults dialog box lets you set these values. I accepted the defaults.

VisualAge for COBOL on OS/2: Installation - SMARTsort options

You are then asked if you want to run the Compiler Default Options Tool, that allows to set a whole bunch of all kinds of options concerning the configuration of the VisualAge for COBOL development environment. I ran it here; you can run it later on, if you prefer. The screenshot shows the available option "categories". Click one of the buttons to open the corresponding settings window.

VisualAge for COBOL on OS/2: Installation - Compiler Default Options Tool [1]

The screenshots below show two of the settings windows. Note, that in the first of these windows, I changed the second option from "NOLIB" to "LIB", what will allow the usage of copy books by default. This is actually the only change that I made to the preselected option values. Adapt the options to your needs and wishes, if you want. Or let all as is, and run the tool later, when changes to the preselected values are required.

VisualAge for COBOL on OS/2: Installation - Compiler Default Options Tool [2]
VisualAge for COBOL on OS/2: Installation - Compiler Default Options Tool [3]

When the installation is terminated, you'll have to reboot your computer. If you look at your desktop, you see that a VisualAge for COBOL icon has been created. It's actually a folder, containing the different items included with the development environment.

In the VisualAge for COBOL Icon View, you find an item called How To Start. Double-clicking it opens the window shown on the screenshot below. Among others, it gives access to the Getting Started Guide, a really well done introduction to the software, including step-by-step tutorials to build command line and desktop applications.

VisualAge for COBOL on OS/2: Access to the 'Getting Started Guide' and other documentation

Building command line programs.

Important: Be sure to create the directory where you want to store your VisualAge for COBOL project, before creating the project. If you don't, a directory with a default name (8 first characters of the project title) will be (or, at least, risks to be) created.

I decided to place all my VisualAge for COBOL projects in the directory C:\Devel\Cobol. It's in this directory, that a subdirectory for each project has to be created.

Program sample 1: Simple "Hello World" program.

After having created the directory C:\Devel\Cobol\Hello, open VisualAge for COBOL Icon View, and double-click the Create New Project item. The IBM VisualAge COBOL - Create New Project window opens. Be sure that the Create a default COBOL project radio button is selected. Enter a project name (I chose "Hello User"), the path to the project folder (in my case C:\Devel\Cobol\Hello), and the build target, i.e. the name of the executable to create (I chose "hello.exe").

VisualAge for COBOL on OS/2: Building command line programs - Creating a default COBOL project

A folder called "Hello User" is created on the desktop (you can choose another location by changing the compiler options), and its Icon View is opened, when you push the OK button in the window above. From the menu bar, choose Project > Create > Create New Text File with the COBOL Editor.

VisualAge for COBOL on OS/2: Building command line programs - Choosing to create a new file with the COBOL editor

Even though the editor is called "COBOL Editor", it is in fact a multiple languages programming editor, with highlighting and syntax checking support not only for COBOL, but also C++, and several other languages. The language support is chosen in the window that shows up next; in our case, the language profile to choose from the listbox is CBL.

VisualAge for COBOL on OS/2: Building command line programs - Choosing the 'CBL' language profile

This opens the COBOL Editor with CBL support. It's here where you can now enter the source code of the COBOL program. Note that, by default, the editor is in "replace" mode. To switch to "insert" mode, push the INS key on the keyboard.

VisualAge for COBOL on OS/2: Building command line programs - The (empty) COBOL editor

Here is the source code of the sample program hello.cbl.

       identification division.
       program-id. hello.
       data division.
       working-storage section.
       77  Name     pic X(25) value spaces.
       77  Greeting pic X(33).
       procedure division.
           display "Please, enter your name? "
               no advancing.
           accept Name.
           if Name = spaces
               move "World!" to Name
           end-if.
           string "Hello " delimited by size,
               Name delimited by space,
               "!" delimited by size
               into Greeting.
           display Greeting.
           stop run.

Note: I actually wrote this program (as well as the other ones used in this tutorial) for GnuCOBOL on Windows 10 (cf. my article GnuCOBOL: A full featured multi-platform COBOL compiler). On Windows 10, I copied the source files onto a floppy diskette, and opened them on my OS/2 machine with the system editor. Then, I used copy/paste to insert the source code into the COBOL Editor window. No idea where the problem is, but this did not work entirely correctly. In fact, some lines started with one or several unknown characters. These lines have, of course, to be corrected: Just replace the unknown characters by spaces.

The screenshot below shows the (syntax based highlighted) source code in COBOL Editor. To save the file, choose File > Save As from the menu bar.

VisualAge for COBOL on OS/2: Building command line programs - Saving the source file in COBOL Editor [1]

In the opening Save As dialog box, make sure that the save directory is well your project folder! Enter the file name with extension .cbl (in my case: hello.cbl), and push the Save As button.

VisualAge for COBOL on OS/2: Building command line programs - Saving the source file in COBOL Editor [2]

Go back to the Hello User - Icon View window. Push the F5 keyboard key to refresh the folder content. The icon of the file hello.cbl should now be visible.

VisualAge for COBOL on OS/2: Building command line programs - The COBOL source file in the project's 'Icon View'

Nearly done. To build the project, choose Project > Build from the menu bar. If all went well the last message of the compiler will be "Action complete, RC=0". The screenshot shows the successful build of hello.cbl. Note the files created in the project folder, among them the executable hello.exe.

VisualAge for COBOL on OS/2: Building command line programs - Successful build of a default COBOL project

You can run the executable from within the IDE, but, unless there is some statement at the end of the source code that waits for user input, you will not see the output, as the window will automatically be closed. Thus, the best way to run the program, is to do it in OS/2 Command Prompt.

VisualAge for COBOL on OS/2: Building command line programs - Running the executable

Note: The files in the project folder are not enough to run the program on another computer, where VisualAge for COBOL isn't installed. If you try to do so, you'll get an error message concerning missing files. I suppose that these are some DLLs of the COBOL runtime environment, and if we copy them to the other system, the execution of the program should be successful (?).

Program sample 2: Simple sort.

Here is the source code of sort1.cbl, a simple COBOL program, that takes as input the column-structured text file AA.TXT (containing information about the 20 major amino acids) and creates the output file AA2.TXT, with the records (lines) sorted on the content of one of the columns (the amino acid 1-letter codes). To note that this code is identical to the one, that I wrote for GnuCOBOL on Windows 10.

       identification division.
       program-id. sort1.
       environment division.
       input-output section.
       file-control.
           select INFILE assign to "aa.txt"
               organization is line sequential.
           select OUTFILE assign to "aa2.txt"
               organization is line sequential.
           select SORTFILE assign to "sort.tmp".
       data division.
       file section.
       fd  INFILE.
       01  Infile-record pic x(63).
       fd  OUTFILE.
       01  Outfile-record pic x(63).
       sd  SORTFILE.
       01  Sortfile-record.
           05  Sortfile-name pic X(13).
           05  filler pic X.
           05  Sortfile-code3 pic XXX.
           05  filler pic X.
           05  Sortfile-code1 pic X.
           05  filler pic X.
           05  Sortfile-formula1 pic X(10).
           05  filler pic X.
           05  Sortfile-formula2 pic X(32).
       procedure division.
           display "Sorting 'aa.txt' by 1-letter code".
           display "Writing sorted amino acids to aa2.txt".
           sort SORTFILE
               on ascending key Sortfile-code1
               using INFILE
               giving OUTFILE.
           stop run.

The screenshots show the input and output files (AA.TXT and AA2.TXT), opened in OS/2 System Editor.

VisualAge for COBOL on OS/2: Building command line programs - Sort input file, opened in OS/2 System Editor
VisualAge for COBOL on OS/2: Building command line programs - Sort output file, opened in OS/2 System Editor

Note: When you open these files with OS/2 System Editor, they appear without any column-based structure. This is due to the default font used in System Editor. To get a proper display of structured text files, you should change the font used in System Editor, changing it from System Proportional to System Monospaced.

Program sample 3: Sort with output procedure.

The build of my sort with output procedure, written for GnuCOBOL on Windows 10 succeeded, however, the output was just a mess! The two implementations of this kind of sort seem not to be compatible. If some day (maybe) I review the program, I'll publish the code that works for VisualAge for COBOL...

Program sample 4a: Creating an ISAM file.

I must say that I was really surprised when I realized that the ISAM programs, that I wrote for GnuCOBOL on Windows, work without any modifications with VisualAge for COBOL on OS/2. The declaratives, handling file errors, sequential read, write by key, as well as read using the primary or alternate key ... exactly the same source code for both COBOL distributions!

To note that the two implementations of the ISAM file format are not compatible. Giving the file name "aa.dat", GnuCOBOL creates two files, called respectively "aa.dat" and "aa.dat.idx". VisualAge for COBOL creates three files: "aa.dat", "aa.dat.@00", and "@aa.dat". I did not take the time to look up what's the effective content of these three files...

Here is the code of isam1.cbl, that creates an indexed-sequential file from a column-structured text file (the amino acids file AA.TXT, already used with the sort sample).

       identification division.
       program-id. isam1.
       environment division.
       input-output section.
       file-control.
           select INFILE assign to "aa.txt"
               organization is line sequential
               status is Infile-status.
           select OUTFILE assign to "aa.dat"
               organization is indexed
               access is random
               record key is Outfile-code1
               alternate key is Outfile-code3
               status is Outfile-status.
       data division.
       file section.
       fd  INFILE.
       01  Infile-record.
           05  Infile-name pic X(13).
           05  filler pic X.
           05  Infile-code3 pic XXX.
           05  filler pic X.
           05  Infile-code1 pic X.
           05  filler pic X.
           05  Infile-formula1 pic X(10).
           05  filler pic X.
           05  Infile-formula2 pic X(32).
       fd  OUTFILE.
       01  Outfile-record.
           05  Outfile-code1 pic X.
           05  Outfile-code3 pic XXX.
           05  Outfile-name pic X(13).
           05  Outfile-formula1 pic X(10).
           05  Outfile-formula2 pic X(32).
       working-storage section.
       77  Record-Count pic 99.
       77  Infile-eof pic 9.
       77  Infile-status pic XX.
       77  Outfile-status pic XX.
       procedure division.
       declaratives.
       Infile-errors section.
           use after error procedure
               on INFILE.
       Infile-error.
           display "Error when reading 'aa.txt': " no advancing.
           display Infile-status.
           stop run.
       Infile-error-out.
           exit.
       Outfile-errors section.
           use after error procedure
               on OUTFILE.
       Outfile-error.
           display "Error when writing 'aa.dat': " no advancing.
           display Outfile-status.
           stop run.
       Outfile-error-out.
           exit.
       end declaratives.
       Main section.
           display "Copying 'aa.txt' to 'aa.dat'".
           perform Open-files.
           move 0 to Infile-eof.
           move 0 to Record-Count.
           perform Copy-files until Infile-eof = 1.
           perform Display-count.
           perform Close-files.
           stop run.
       Open-files.
           open input INFILE.
           open output OUTFILE.
       Copy-files.
           read INFILE
               at end
                   move 1 to Infile-eof
               not at end
                   perform Write-file.
       Write-file.
           move Infile-code1 to Outfile-code1.
           move Infile-code3 to Outfile-code3.
           move Infile-name to Outfile-name.
           move Infile-formula1 to Outfile-formula1.
           move Infile-formula2 to Outfile-formula2.
           write Outfile-record.
           add 1 to Record-Count.
       Display-count.
           display "Number of records copied: " no advancing.
           display Record-Count.
       Close-files.
           close INFILE.
           close OUTFILE.

Program sample 4b: Displaying all records of an ISAM file.

The sample program isam2.cbl reads the ISAM file created by isam1.cbl sequentially and displays the records onto the console.

       identification division.
       program-id. isam2.
       environment division.
       input-output section.
       file-control.
           select INFILE assign to "aa.dat"
               organization is indexed
               access is sequential
               record key is Infile-code1
               alternate key is Infile-code3
               status is Infile-status.
       data division.
       file section.
       fd  INFILE.
       01  Infile-record.
           05  Infile-code1 pic X.
           05  Infile-code3 pic XXX.
           05  Infile-name pic X(13).
           05  Infile-formula1 pic X(10).
           05  Infile-formula2 pic X(32).
       working-storage section.
       77  Infile-eof pic 9.
       77  Infile-status pic XX.
       01  Display-line.
           05  Display-code1 pic X.
           05  filler pic XX value spaces.
           05  Display-code3 pic XXX.
           05  filler pic XX value spaces.
           05  Display-name pic X(13).
           05  filler pic XX value spaces.
           05  Display-formula1 pic X(10).
           05  filler pic XX value spaces.
           05  Display-formula2 pic X(32).
       procedure division.
       declaratives.
       Infile-errors section.
           use after error procedure
               on INFILE.
       Infile-error.
           display "Error when reading 'aa.dat': " no advancing.
           display Infile-status.
           stop run.
       Infile-error-out.
           exit.
       end declaratives.
       Main section.
           display "Displaying the content of 'aa.dat'".
           open input INFILE.
           move 0 to Infile-eof.
           perform Read-and-Display until Infile-eof = 1.
           close INFILE.
           stop run.
       Read-and-Display.
           read INFILE
               at end
                   move 1 to Infile-eof
               not at end
                   perform Display-record.
       Display-record.
           move Infile-code1 to Display-code1.
           move Infile-code3 to Display-code3.
           move Infile-name to Display-name.
           move Infile-formula1 to Display-formula1.
           move Infile-formula2 to Display-formula2.
           display Display-line.

Here is the program output.

VisualAge for COBOL on OS/2: Building command line programs - Output of an ISAM sequential read program

Program sample 4c: Displaying a given record of an ISAM file.

The sample program isam3.cbl asks the user for an amino acid code (either the 1-letter-code, or the 3-letter code), and then displays the corresponding record, read by (primary or alternate) key from the ISAM file created by isam1.cbl.

       identification division.
       program-id. isam3.
       environment division.
       input-output section.
       file-control.
           select INFILE assign to "aa.dat"
               organization is indexed
               access is random
               record key is Infile-code1
               alternate key is Infile-code3
               status is Infile-status.
       data division.
       file section.
       fd INFILE.
       01 Infile-record.
           05 Infile-code1 pic X.
           05 Infile-code3 pic XXX.
           05 Infile-name pic X(13).
           05 Infile-formula1 pic X(10).
           05 Infile-formula2 pic X(32).
       working-storage section.
       77 Program-option pic X.
       77 Infile-status pic XX.
       01 Display-line.
           05 Display-code1 pic X.
           05 filler pic XX value spaces.
           05 Display-code3 pic XXX.
           05 filler pic XX value spaces.
           05 Display-name pic X(13).
           05 filler pic XX value spaces.
           05 Display-formula1 pic X(10).
           05 filler pic XX value spaces.
           05 Display-formula2 pic X(32).
       procedure division.
       declaratives.
       Infile-errors section.
           use after error procedure
               on INFILE.
       Infile-error.
           display "Error when reading 'aa.dat': " no advancing.
           display Infile-status.
           stop run.
       Infile-error-out.
           exit.
       end declaratives.
       Main section.
           open input INFILE.
           perform Ask-for-option
               until Program-option = "0".
           close INFILE.
           stop run.
       Ask-for-option.
           display "Options: 1=1-letter code, 3=3-letter code ? "
               no advancing.
           accept Program-option.
           if Program-option = "1"
               perform Search-with-1-letter-code
           else
               if Program-option = "3"
                   perform Search-with-3-letter-code
               else
                   move "0" to Program-option.
       Search-with-1-letter-code.
           display "1-letter AA code ? " no advancing.
           accept Infile-code1.
           read INFILE
               invalid key
                   perform Key-Not-Found
               not invalid key
                   perform Display-record.
       Search-with-3-letter-code.
           display "3-letter AA code ? " no advancing.
           accept Infile-code3.
           read INFILE
               key is Infile-code3
               invalid key
                   perform Key-Not-Found
               not invalid key
                   perform Display-record.
       Display-record.
           move Infile-code1 to Display-code1.
           move Infile-code3 to Display-code3.
           move Infile-name to Display-name.
           move Infile-formula1 to Display-formula1.
           move Infile-formula2 to Display-formula2.
           display Display-line.
       Key-Not-Found.
           display "Invalid or unknown AA code".

Here is the screenshot of a program execution.

VisualAge for COBOL on OS/2: Building command line programs - Output of an ISAM random read program

Click the following link to download the source code of the tutorial program samples. Please, note, these are just the .cbl files. In other words, you'll have to create the VisualAge for COBOL projects by yourself...


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