I need help with the following problem. As I understand it, this code (being a part of the moxquizz.tcl) is responsible for calculating a duration and prettyprinting it. Now I want to add milliseconds to the equation, but I don't know how.
The main problem is that "unixtime" does not keep track of fractions of a second. You could always use "clock clicks" if it is available on your platform; keep in mind however, that this will return a system-dependant time-measurement, often the smallest time-period your system may measure (cpu-clock or such). As of tcl8.3 there is an option "-milliseconds" that will guarantee measurements in milliseconds across platforms, which you might be able to utilize. Keep in mind that you might have to handle overflow situations in some cases, as integers in tcl are not large enough to hold the additional information compared to "unixtime". Also, keep in mind that the integer returned by "clock clicks -milliseconds" is a signed integer.
Now, keeping in mind of these issues, it should'nt be too hard to use clock-clicks in your current code. You'd obviously have to convert your millisecond time into "unixtime" time when using the "duration" command. A simple division should solve that, while a modulus would extract the millisecond offset.
"duration" expects the time to be in seconds, hence you'll need to take apropriate actions to convert the millisecond-based time into second-based. See my previous post on suggestions on how to do this.