Coder's Guild Mailing List

Re Re: TURBO PASCAL, CRASHING ON PIII 450!!!

Posted by Fox on 2000-01-24

> I have just bought myself an Intel Pentium III 450
> machine.
> 
> My versions of turbo pascal keep crashing with a divde
> by zero error. I use TP version 7.
> 
> The error only occurs when I run the program with the
> Crt unit included.
> 
> Is there something I need to set up to resolve this
> error?

//
A divide by zero error is when you attempt to do something like this:

a = 7 / 0;

This can't happen because nothing divides into something an infinite number of 
times.  Thus, the computer stops it when it sees it.

Check your program for any case where something like this might happen.  
Usually this ocurrs in a loop(if this is incorrect, sorry; my PASCAL is a bit rusty.  
Hopefully you get the idea :-):

for  i upto 10  do
  begin
   a := 10 / i;
  end

When writing code like this, it's easy to overlook that you're dividing by zero in the 
first run of the loop.

Simply add a case that detects the error early and takes some action to make 
sure it doesn't happen.

for  i upto 10  do
  begin
   if (i <> 0) then {this skips the dividing if it's zero.  }
     a := 10 / i;
  end
________________________________________________________
Signed: Fox
        sfox@xxxxxxxx.xxx

Unbeknowst to most computer users, the "Hertz" is the unit
of measurement for how much faster and smarter the computer
is compared to you.
To signoff send a mail to listserver@xxxx.xx.xx with 
  "signoff tcg" in the body of your message.