BREAK ON
CLS
"Hit any key for start time snapshot"
?
Get $
$Start=@Time+"."+@Ticks
"$$Start = "+$Start; get milliseconds (actual value not significant except to subtract from $endmsecs)
$startmsecs=val(substr($start,10,Len($start)))
?
"Milliseconds to substract from end time = "+$startmsecs
?
?
"Hit any key for end time snapshot"
?
Get $
$End=@Time+"."+@Ticks
"$$End = "+$End
; get milliseconds (only net value significant)
$endmsecs=val(substr($end,10,Len($end)))
?
"Milliseconds to substract start time from = "+$endmsecs
?
?
; convert start time to seconds
$startsecs=val(substr($start, 1, 2))*3600 + val(substr($start, 4, 2))*60 + val(substr($start, 7, 2))
"$$Startsecs= "+$Startsecs+" seconds from midnight"
?
; convert end time to seconds
$endsecs=val(substr($end,1,2))*3600+val(substr($end,4,2))*60+val(substr($end,7,2))
"$$Endsecs = "+$Endsecs+" seconds from midnight"
?
; subtract start from end milliseconds
$diffmsecs=$endmsecs-$startmsecs
?
"Total $$Diffmsecs = "+$Diffmsecs+" milliseconds"
; drop the seconds (keep only the last three places)
$diffmsecs=val(substr($diffmsecs,Len($diffmsecs)-2,Len($diffmsecs)))
; subtract start from end
$diffsecs=$endsecs-$startsecs
?
"$$Diffsecs = "+$Diffsecs+" seconds"+" and "+$Diffmsecs+" milliseconds"
; convert difference to HH:MM:SS
$hours=$diffsecs/3600
$minutes=($diffsecs-($hours*3600))/60
$seconds=($diffsecs-($hours*3600)-($minutes*60))
; convert the numbers to strings and add leading zeros if required
if $hours<10
$hours="0$hours"
else
$hours="$hours"
endif
if $minutes<10
$minutes="0$minutes"
else
$minutes="$minutes"
endif
if $seconds<10
$seconds="0$seconds"
else
$seconds="$seconds"
endif
; create string
$diff=$hours+":"+$minutes+":"+$seconds
?
"$$Diff = "+$Diff+" in HH:MM:SS format"
Get $