Attribute VB_Name = "TIMENOW"
' *******************************************************
' TIMENOW.BAS
'
' Time related routines.
' *******************************************************
' Copyright (C) 1995-1997 John Wiley & Sons, Inc.
' All rights reserved. See additional copyright
' information in RIGHTS.TXT.
' *******************************************************

Option Explicit

#If Win32 Then
    ' Use GetTickCount for 32-bit environments.
    Declare Function GetTickCount Lib "kernel32" () As Long
#Else
    ' Use TimerCount for 16-bit environments.
    Type TIMERINFO
        dwSize As Long          ' 12 bytes
        dwmsSinceStart As Long  ' Time since task start
        dwThisVM As Long        ' Time since virtual machine start
    End Type
    
    Declare Function TimerCount Lib "toolhelp.dll" (t As TIMERINFO) As Integer
#End If

' *******************************************************
' Return current system time in seconds. This has a finer
' resolution than the Timer function.
' *******************************************************
Function CurrentTime() As Double
#If Win32 Then
    CurrentTime = GetTickCount() / 1000#
#Else
    Dim the_time As TIMERINFO
    
        the_time.dwSize = 12
        If TimerCount(the_time) Then
            CurrentTime = the_time.dwThisVM / 1000#
        Else
            CurrentTime = Timer
        End If
#End If
End Function
' *******************************************************
' Pause for a certain number of seconds.
' *******************************************************
Sub Pause(secs As Single)
Dim delay As Single
Dim stop_time As Single

    ' Run DoEvents until the time to go is small.
    stop_time = Timer + secs
    Do
        DoEvents
        delay = stop_time - Timer
    Loop While delay > 1

    ' Tight loop now that the time to go is small.
    Do While Timer < stop_time
    Loop
End Sub

