Topic Path: Symbol Reference > Functions > GetTickDiff Function
GetTickDiff Function

Calculates the elapsed tick count from two tick count values.

function GetTickDiff(
    const AOldTickCount: Cardinal; 
    const ANewTickCount: Cardinal
): Cardinal;
Time value for the comparision.
Time value for the comparision. 

Cardinal - Elapsed tick count for the specified arguments.

GetTickDiff is a Cardinal function that calculates the elapsed tick count using the values in AOldTickCount and ANewTickCount. AOldTickCount and ANewTickCount are the starting and ending tick counts as returned by the Ticks function. GetTickDiff exists because a Ticks value can rollover to zero (0) when it exceeds the maximum value represented in the Cardinal data type. 

GetTickDiff handles this situation in calculating the elapsed tick count. When ANewTickCount is greater than (or equal to) AOldTickCount, the return value is calculated using: 


  ANewTickCount - AOldTickCount;


When ANewTickCount is less than AOldTickCount, the return value is adjusted and calculated using: 


  High(Cardinal) - AOldTickCount + ANewTickCount;


GetTickDiff is used when calculating the values returned in TIdEcho.EchoTime and TIdEchoUDP.EchoTime, as well as the values returned in TIdTime.RoundTripDelay and TIdTimeUDP.RoundTripDelay.

Copyright 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.