Computing: DOS, OS/2 & Windows Programming

Installing Borland C++ on OS/2 2.11.

Borland C++ 2.0 can be downloaded from the WinWorld website. The download is a CDROM ISO, so just insert it into your virtual CD-drive, and on your OS/2 machine, browse to the CD content and double-click INSTALL.EXE to run it in order to start installation.

The screenshot on the left shows the setup program asking for the installation directory; the default is C:\BCOS2. The screenshot on the right shows how the files are copied from the CDROM to the harddisk.

Borland C++ on OS/2 2.11: Installation - Directories selection
Borland C++ on OS/2 2.11: Installation - File copy

Notes:

  1. When asked if you want to update CONFIG.SYS, be sure to answer "Yes".
  2. During file copy, you may have the impression, that the program hangs. It's just that some unpacking takes time; simply wait, the installation should finish successfully.

The setup program creates a new program group called "Borland C++" in Presentation Manager. It contains 3 shortcuts: Borland Debugger, Borland C++ (the IDE), and Resource Workshop (that you may use to create GUI elements).

Borland C++ on OS/2 2.11: The 'Borland C++' program group

Lets try a simple command line "Hello World" program. Here is the code:
    #include <iostream.h>
    int main() {
        cout << "Hello World!" << endl;
        return 0;
    }

The screenshot shows the source code of hello.cpp, opened in the editor of the Borland C++ IDE.

Borland C++ on OS/2 2.11: Creating a simple 'Hello World' program

Before we can compile the program, we'll have to indicate the program target. This is done in Project Settings: for an OS/2 command line program, choose OS2 Exe.

Borland C++ on OS/2 2.11: Selecting the program target

To build the program (more exactly: to build the project), choose Compile > Build All from the menu bar. You can execute the program from within the IDE by choosing Run > Run. The screenshot shows the execution of hello.exe.

Borland C++ on OS/2 2.11: Running a simple 'Hello World' program

Here is another code example: The program leapyear.cpp checks if the year, entered by the user, is a leap year, or not.
    #include <iostream.h>
    int main() {
        int year, isleapyear;
        cout << "Enter a year: ";
        cin >> year;
        // Leap year if divisible by 400
        if (year % 400 == 0) {
            isleapyear = 1;
        }
        // Not a leap year if not divisible by 400, but divisible by 100
        else if (year % 100 == 0) {
            isleapyear = 0;
        }
        // Leap year if not divisible by 100, but divisible by 4
        else if (year % 4 == 0) {
            isleapyear = 1;
        }
        // All other years are not leap years
        else {
            isleapyear = 0;
        }
        if (isleapyear == 1) {
            cout << year << " is a leap year.";
        }
        else {
            cout << year << " is not a leap year.";
        }
        return 0;
    }

The screenshot shows an execution of the program in an OS/2 window.

Borland C++ on OS/2 2.11: Running a program in an OS/2 command line window

Note: By default, the executable is not created in the folder, that contains the sources, but in the \bin folder of the Borland C++ installation directory (I actually moved leapyear.exe before taking the screenshot above...).

We can also use Borland C++ to create desktop applications, i.e. GUI based applications, running in OS/2 Presentation Manager. The installation files include several examples. As a difference with our simple programs above, the sources of such an application are organized in a project, and to load them into the IDE, we have to use the menu command Project > Open, rather than just opening a C++ file (opening a .PRJ file with the File > Open command, does not load the project, but loads this file's content into the editor). Also, be sure to use the target PM Exe when building the project.

The screenshots below show how I built the project PMHELLO.PRJ (screenshot on the left), and how I executed it in from the Icons window in Presentation Manager (screenshot on the right).

Borland C++ on OS/2 2.11: Building a Presentation Manager application
Borland C++ on OS/2 2.11: Running a Presentation Manager application

Another example included is the project CLOCK.PRJ. The screenshot shows the execution of CLOCK.EXE, resulting from the build of this project.

Borland C++ on OS/2 2.11: Running the included 'Clock' Presentation Manager application

And, to be complete, here are screenshots of the Borland Debugger (on the left) and the Resource Workshop (on the right). I don't know these applications from the past, and I didn't try them out on my OS/2 2.11 VMware virtual machine. So, no idea how helpful they are in practice...

Borland C++ on OS/2 2.11: The Borland Debugger
Borland C++ on OS/2 2.11: The Resource Workshop

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