That wont work for 2 considerably large reasons.
(1) $ticks shows 1/1000ths of a second NOT 1/10000th so using he last 4 digits means your showing a value that represents from 0.000 seconds to 9.999 seconds, but u show it at .0000 to .9999, this means that should you loop enought times you would see 8:00:00:5000 >>> 8:00:01:6000 >>> 8:00:02:7000 the .#### well never have rolled over in 3 seconds becuase it takes 10 to roll over.
(2) which may have confused you when looking at yopur results is that $ticks does not roll over the 1000 marker when the second rolls over, as the second rolls over it might be 1111111543 then one second later be 1111112543 then 1111113543, this of course makes the above (1) problem harder to see as it might look like this 8:00:00:5543 >>> 8:00:01:6543 >>> 8:00:02:7543
Heres the code i use, its actually for something else (it inserts ms .000 time stamping into the timestamp format anywhere there is a .000 to .999 in it (dot and 3 digits))
But you can also just request $mstime and it brings back the 3 didgits of the ms so u could use $asctime($+({mmddyy¦HH:nn:ss:,$mstime,$(},)))
Or you could just set the timestamp format to {mmddyy¦HH:nn:ss.000} and it well update on its own.
on *:START:{ ms.timestampfmt }
alias ms.timestampfmt {
var %ctime = $calc($ctime + 1)
while (%ctime >= $ctime) { }
set $iif(($version < 6.17),-u1000000000,-e) %ms.timestampfmt.fix $calc($ticks % 1000)
.timer.ms.timestampfmt.fix -imo 0 15 ms.timestampfmt.fix
}
alias ms.timestampfmt.fix {
var %timestampfmt = $timestampfmt , %re = /s\.\d{3,3}/g
if ($regsub(%timestampfmt,%re,$+(s.,$mstime),%timestampfmt)) { .timestamp -f %timestampfmt }
}
;
;* you must add ".000" to any s in the time stamp, to enable this timer to know where to insert the ms
;* example [HH:nn:ss.000]
;
alias mstime { return $right($calc($ticks - %ms.timestampfmt.fix),3) }