Fix for "Runtime Error 200" bug of Borland Pascal 7 on fast PCs

Explains the cause of this bug and sumarizes solutions both for users and developers (people who do have / don't have pascal source of their programs).

Also available:

Contents:


Preface

Borland Turbo Pascal 7 is a great Pascal compiler for PC's. Unfortunately it has not been updated by Borland for many years (for a possible alternative see FPC).

All programs compiled with Borland Pascal 7 that use the system unit Crt (almost all programs do that) abort with the error message "Runtime Error 200" on all fast PCs, for example Pentium II with 233 MHz.

Programs compiled with Borland Pascal 6 are said to not abort with a runtime error, but their delay is completely wrong on fast PCs (and the problem starts there at much lower speeds than the problem of version 7).

This Web page tries to explain the problem and summarize some existing solutions.

Borland (aka Inprise) does not offer a solution for this bug (shame on them!). Instead their Pascal Developer Support recommends an Altavista search, which probably is how you have found this web page.


Cause

The bug is in the initialization for the delay procedure that is part of the initialization of the Crt unit. The delay initialization is called in every program that uses the Crt unit, not just on those that use the delay procedure. The Crt unit is included in most programs that are written in Borland Pascal.

The delay initialization counts how often a tiny do-nothing loop must be called in order to delay by 55 milliseconds (time measured by reading the Bios Time Counter at memory address 40:6C that ticks 18.2 times a second, i.e. each 55 milliseconds).

This number is then divided by 55 to get the number of calls for one millisecond. The result is written to a word (16 bit) variable. The overflow of this variable triggers the run time error (the meaning of Runtime Error 200 is division by zero, but it is caused by an overflow in this case).


Solutions

The following list shows all solutions that I currently know.
If something is missing here, please tell me: hartnegg @uni-freiburg.de

Index of recommended solutions

Note: If you have Turbo Pascal or Borland Pascal version 7.0, I recommend you contact Borland / Inprise to obtain version 7.01 because version 7.0 contains several bugs. Lately there have been reports in usenet that Borland doesn't know about a 7.01 bug fix version, it's still called 7.0, so it may be better to ask for replacement disks for version 7.0 (will come as one cdrom containing version 7.01).

Index of other solutions

bppatch   Solution by German computer magazine c't
contains description, program patch, source patch and copy of patched run time library
problem: rtl is based on version 7.0, thus reintroducing several old errors while fixing one new one, description and patch are very good though.

bp7patch   patch program for all Run Time Library files
problem: does much more changes than can be easily explained

tp7p5fix   TSR program, catches error while program starts
problem: no description available how and how well this program works,
probably only for programs that do not require precise timing

tpbug   new TPL files
problem: contain much more changes than can be easily explained


Comments

Looking through the list of files above, most of you will probably come to the conclusion that no real solution seems to be available.

Programmers using Turbo Pascal 7.01 can now solve their problem since t7tplfix.zip is available. Programmers using Borland Pascal 7.01 and still must search and apply the patch themselves to get a working version of TPP.TPL (for protected mode). Users without source of their programs can still not get a real solution if the programs rely on a precise delay function. Such a solution will probably never exist.

Of the two files recommended by Borland, one will cause the delay procedure to not run correct on fast computers, the other can be used only by owners of the full Borland Pascal package because the file TPP.TPL is required and it does a lot of suspicions changes to other units as well.

By using any of the other files, you must send your customers a program that is patched to patch itself at runtime with even its authors saying that this is not very nice. Or you can prevent the run time error but must live with a delay procedure that is known to run at unpredictable speeds. Or you must persuade your customers to install a TSR program that you don't know precisely what it does. Or you reintroduce all the bugs of Borland Pascal 7.0 when replacing a otherwise correct version 7.01 with a patched version 7.0. Or you can used a patched run time library that contains a lot of additional changes that nobody has yet explained.

It is a shame for Borland that they seem to be unable or unwilling to solve this bug themselves and offer download of fixed TURBO.TPL and TPP.TPL files from their web page!

If you feel like you should say Borland what you think about their support, please remember they have changed their name to Inprise, so you may try mailing to customer-service@inprise.com (if you get a reply, please tell me).


What's New


Web-Pages

Some other web pages that contain informations about this topic:

Official and of no big help:

Inofficial but much more help:

More about Borland Turbo Pascal:


Last change: 22-Aug-1998
Collection and Descriptions © 1998 by Klaus Hartnegg
All information and programs mentioned herein are provided without warranty. Use all on your own risk.
Best viewed with any browser. Created using The Semware Editor and vi. Ceterum censeo Microsoft esse delendam.
(Counter started 21-July-1998)
IPStat