Possible Fix: IdGlobal.Ticks Range check error Indy V9-V10

Giganews Newsgroups
Subject: Possible Fix: IdGlobal.Ticks Range check error Indy V9-V10
Posted by:  Paul Cooper (paul@nospam.publish2profit.com)
Date: Wed, 24 Nov 2004

Hi, how about:

Background:  I was getting a Range Check Error using TIdSMTP on a machine
that has been running along time (200+ days) in the Ticks routine found in
unit IdGlobal.  I traced this to the following Trunc() return a value >
High(Cardinal), so anding it with High(Cardinal) will prevent the range
check error.

Since Result is Cardinal and Trunc can return Int64 anding it with
High(Cardinal) to prevent range check error:

  Result := Trunc((nTime / Freq) * 1000) and High(Cardinal);

...only problem is Result will loop around to 0, but GetTickCount does this
also.  No way around this unless Ticks starts returning Int64.

I was also thinking that maybe Freq should be read once and stored in the
initialization section of the IdGlobal unit to save that repeated call.

Indy is an amazing piece of code, keep up the good work!

Paul C