KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Converting tick counts to milliseconds and vice versa
PRODUCT: 4D | VERSION: 11.4 | PLATFORM: Mac & Win
Published On: November 12, 2009
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

Two different time measurements are commonly used in 4D commands:

Ticks = (Milliseconds/1000)*60

Milliseconds = (Ticks*60)/1000

This distinction is important because some commands return a duration in milliseconds (such as the Milliseconds command) and some other command expect a tick count (such as the DELAY PROCESS command). These values are not interchangable and could cause unexpected results if you were to confuse the two formats.

There are 1,000 milliseconds in a second and there are 60 ticks in a second.

Suppose you issue a command that you know will take 500 milliseconds (half a second) to complete and wanted to delay the current process for 800 miliseconds (eight tenths of a second) to allow sufficient time for it to complete.

DELAY PROCESS(current process;800)


The above command would not delay for 800 milliseconds, but would actually delay the process for 13.333 seconds.

Based on the conversion listed above the correct value would 48 ticks and t5he command would be written like so:

DELAY PROCESS(current process;48)




Notes:
  • Ticks = (Milliseconds/1000)*60

  • (800 Milliseconds / 1000) = 0.8 Seconds

  • 0.8 Seconds * 60 = 48 ticks