Read the time from the US Naval Observatory web site which reports the current time. Uses the Desktop agent.
The sample will read the page, alert if the computer time is more than 1 minute different than that read.
| http://dataflask.com/samples/time.dfp |
Package contains time.dfg and time.dfb.
time.dfg, along with its script peer time.dfb, will read http:://tycho.usno.navy.mil/cgi-bin/timer.pl (External) and compare the Usno time to the computer's time.
If the time is more than 60 seconds difference, the Tray Icon will flash a warning.

If the program is run hidden, time.dfg and time.dfb will close.

time.dfg
time.dfg is a line controlled text file. Line 7 is EST. Pick File/Reload Data/Reload Update to update just line seven.

time.dfg Data Link
To choose your time zone, pick File/Reload Data/Reload to see all available time zones, then delete .
| Sub Main Dim sUsno, sWarning, sUrl Dim dUsno, dNow Dim nSecondsOff, nTolerance 'Update Grid sUrl=Grid.LinkProperties(2) If Not Grid.DataRead( &h100 ) OrLeft(Grid.Cell(2,1),4)<>"<BR>" Then '&h100 means Reload Update App.History.Debug.Prompt "Could not Update from " & sUrl & "." App.Flash Exit Sub End If dNow=now 'Format sUsno = Mid(Grid.Cell(2,1), 5) 'Nov. 20, 12:32:49 AM EST sUsno=Left(sUsno, Len(sUsno)-4) 'Nov. 20, 12:32:49 AM sUsno=Replace(sUsno, ",", "") 'Nov. 20 12:32:49 AM dUsno=DateValue(sUsno)+TimeValue(sUsno) 'Debug App.History.Debug.Prompt("dNow: "& formatdatetime(dNow, vbLongdate)& " " & formatdatetime(dNow, vbLongtime)) App.History.Debug.Prompt("dUsno: "& formatdatetime(dUsno, vbLongdate)& " " & formatdatetime(dUsno, vbLongtime)) 'Compare the time in seconds nSecondsOff=DateDiff("s", dUsno, dNow) 'Check '================ nTolerance=60 '60 Seconds '================ If(nSecondsOff>nTolerance) Then sWarning="Computer is " & nSecondsOff & " seconds ahead of Usno time." End If If(nSecondsOff<-nTolerance) Then App.StatusBar="Computer is " & nSecondsOff & " seconds behind Usno time." End If 'Warning If Not IsEmpty(sWarning) Then App.History.Debug.Prompt(sWarning) App.StatusBar=sWarning 'Tray Icon popup message App.Flash End If 'Unload If Not Grid.Document.Visible Then 'Close the grid, and this document if run hidden Grid.Document.Close End If End Sub |
Comment on Grid.DataRead: The ( &h100 ) indicates Reload Update. When using a line number controlled grid, DataRead will return True only if the Text for line numbers that already exist in the grid have changed. Of course http:://tycho.usno.navy.mil/cgi-bin/timer.pl will always change because it reports a time to the nearest second. However, if you were to use a different web location, the return value could be used to monitor if a particular line in a web page has changed.
End. Tutorials.
Data
Flask Copyright © 2006 Interscape
Corporation