Virtual Pascal 2.1

From EDM2
Jump to: navigation, search

By Robert Basler

A couple of nights ago, while wondering what had happened to all the disk space on my 13.5G drive, I remembered a utility I had written back in 1993. This little utility, known as DIRSIZE, listed every directory on a disk as well as how much space it and all its subdirectories took up, and also offered information on total disk size, free, and wasted space. I wrote the utility back when I was administering a LAN that was running out of disk space and had to be monitored on a daily basis to see who was wasting space. Unfortunately the utility was written for DOS, in Pascal, and only supported 66 character paths, so it crashed when I tried to run it on my big OS/2 drives.

The first compiler I ever bought was Borland Turbo Pascal 1.0, which I continued to upgrade and use on a daily basis for my programming work through version 7. Turbo Pascal was a wonderful product, it had a nice editor with lots of shortcut keys, was amazingly fast, was great at catching source errors (like all Pascal compilers) and included good debugging support. I really cut my programming teeth on Pascal, and I still look back with fond memories.

But back to my little utility. I needed an OS/2 version that supported longer paths. I remembered I had come across Virtual Pascal 2.1 a few weeks ago, a free, full-blown Pascal compiler for OS/2, Windows and Linux. I decided to install it and see what it would do with my old Borland Pascal source code.


Running the installer was a step into the way-back machine. If you remember using applications written using Borland's Turbo Vision library then you know what it works like.

Virtual Pascal Installer

Once I got over my surprise, SETUPOS2.EXE worked like a charm and installed Virtual Pascal for me. It also includes options to import various libraries (Object Windows Library, Visual Class Library, Object Professional) from other Pascal's if you have them installed on your computer.

One thing I discovered as soon as I tried to build a project is that you need to go and have Virtual Pascal build its runtime library before you can compile anything else. To do this, open an OS/2 window, change to the VP21\SRC\RTL directory and run BUILDRTL.CMD with OS2 as the parameter. If you plan to build Windows or Linux apps, you'll have to do this for those targets as well.


Virtual Pascal comes with two IDE's, a GUI one and a character mode one. The character mode one is pretty much identical to Borland Pascal as I remember it, right down to the menu options. You will find a few extra features that have been updated such as Pentium support and support for certain OS conventions. Although the GUI IDE looks like a PM window wrapped around the character mode IDE with a couple of icons added, don't let that stop you, this is a very quick, professional, full-featured IDE.

Virtual Pascal IDE

Editing files is fast and easy if you remember all your WordStar shortcuts like ^QF for find, ^QR for top of document etc. The IDE also supports modern GUI editing features such as mouse marking. I had forgotten how quick and easy all those keyboard shortcuts made text editing once you learned them.

Compiling and Running my Project

The original DIRSIZE.PAS didn't compile right away, I had to remove one MS-DOS interrupt call which got the disk cluster size (I run all HPFS now, so I just had it return 512 bytes, if you run other types of drives, you might want to modify it to actually get the real cluster size,) plus a compiler directive that set up the Borland heap manager. Once that was done, the program DIRSIZEOS2.PAS compiled and ran.

Of course it didn't work quite right. A big drive back when the utility was written was 500M. It got a little confused when the total size of all the files went over 2G and with a drive size also over 2G. To fix this problem I adjusted all the file size counters to use doubles rather than longints. I also had to adjust the formatting as the original 10 digit number format I had selected wasn't quite wide enough.

Running the resulting app results in the following screen for a moment:


then a long list of directories followed by a summary like:

OS2 Window

All the numbers are accurate except Disk Size and Unaccounted which use VP's DiskSize function which unfortunately tops out at 2G. If anyone knows how to get the right number back, I'd like to hear it. Waste Space is calculated based on the cluster size, so if you aren't running HPFS, that number will be incorrect as well. Free Space is good until the amount of free space on the drive goes over 2G. Hmmm, that number seems to keep popping up. If you compare the output to DIR, you will notice that the number of files doesn't match. This is because DIR counts . and .. where DIRSIZEOS2 doesn't.


I typically run the program with the command line DIRSIZEOS2 C:|SORT/R|MORE which displays the directories on my hard disk in order from largest to smallest so that I can see where all my disk space is being taken up. In my case, I discovered 1.2G of AVI files I didn't need anymore.


I haven't yet spent a lot of time with Virtual Pascal as I mainly just wanted to compile this one old utility, but it does appear to contain everything you would need to program modern Pascal applications on OS/2 including a compiler, linker, IDE and debugger. It comes with two professionally written PDF manuals, a Language Reference Manual and a User's Guide as well as a wide variety of sample applications including OS/2 PM GUI applications. Quite a few professional apps have been written in Virtual Pascal, there is a list on their website.

Virtual Pascal used to be a commercial product, only the most recent version is freeware, so it is quite feature-complete and a spectacular bargain. If you haven't tried programming before, Pascal is certainly a good place to start since it offers lots of power while being a lot more forgiving than C and not nearly as complex as Java has become.

If you want to use DIRSIZEOS2.EXE on your own computer, go ahead and give it a try. Drop me a note if you like it.