This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v20 R7
Milliseconds

Milliseconds 


 

Milliseconds -> Function result 
Parameter Type   Description
Function result  Longint in Number of milliseconds elasped since the machine was started

Milliseconds returns the number of milliseconds (1000th of a second) elapsed since the machine was started.

The returned value is a signed longint, up to 2^31 (around 2 billion milliseconds or 24 days). When the machine has been running for more than 24 days, the number becomes negative.

The purpose of the command is to measure short periods of time with a high precision. A 24-day range is more than large enough for comparisons, but you need to be careful. When comparing values, always work with the difference between two values. Never compare the values directly since one could be negative and the other positive.

Example  

The following code waits up to 5 seconds for a locked record to become unlocked or it ends:

 If(Locked([Table_1]))
    $starttime:=Milliseconds
    Repeat
       DELAY PROCESS(Current process;15)
       LOAD RECORD([Table_1])
       $waittime:=Milliseconds-$starttime
    Until(Not(Locked([Table_1]))|(Process aborted)|($waittime>5000)) //wait 5 seconds max
 End if

Note: Always compare the difference between two calls of Milliseconds as shown above, never compare directly, e.g.:

 (Milliseconds>($starttime+5000)) //never do it like this, as one could be positive, one negative



See also 

Current time
Tickcount
Timestamp

 
PROPERTIES 

Product: 4D
Theme: Date and Time
Number: 459

This command can be run in preemptive processes

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v6

 
ARTICLE USAGE

4D Language Reference ( 4D v20 R7)