RE: Internet UTC



Hi Carlos
Here is a example of how to pull web pages from a fox application and sift
through the html for the data you want.
I was pulling stock quotes and pushing the results into sql server on a time
interval then sending alarm emails when thresholds were tripped but you can
use the same code to pull the time or any other data by changing the URL..

Good luck
Linwood

***********code*********************

Parameters pcSymbol

Local lcQuote As String, ;
lcTempTxtFile As String, ;
lnGetResults As Integer, ;
lcURL As String

lcQuote = ""
*-- Set up a variable referring to a temp .TXT file.
*-- Uses the current VFP TEMP DIR [SYS(2023)]
*-- and a random file name [SYS(2015)]
lcTempTxtFile = Forceext(Addbs(Sys(2023)) + Sys(2015), "TXT")
lnGetResults = 0

lcGetURl ="http://money.cnn.com/quote/quote.html?shownav=true&symb="; +
ALLT(pcSymbol)


Declare Long URLDownloadToFile In URLMON.Dll ;
LONG, String, String, Long, Long

*-- Get the quote using the Urlmon.dll and store it
*-- to a temp .TXT file.
*-- This function returns non-zero if it fails.
lnGetResults = URLDownloadToFile(0, lcGetURl, lcTempTxtFile, 0, 0)
If lnGetResults # 0
Messagebox("Download Failed",0,"")
Return .F.
Endif

*-- Read the Web page into a variable, and then erase it.
lcQuote = Filetostr(lcTempTxtFile)
Erase (lcTempTxtFile)

*-- Grab the quote from the Web page. If in VFP 7.0, we use the new
*-- STREXTRACT() function to grab the data between two delimiters.
*-- In VFP 6.0, use SUBSTR() to get the data, and then trim off any
*-- trailing HTML with the TRANSFORM() AND VAL() functions.
If Version(5) = 700
lcQuote = Strextract(lcQuote, [stockheader"> ], [<])
Else
*-- Extract the quote from the HTML
* lcQuote = Substr(lcQuote, Atc(["stockheader"], lcQuote) + 14, 8)
lcQuote=Substr(lcQuote, Atc([=40> ],lcQuote) + 10, 5)

*-- Trim off the trailing HTML. VAL() will only return the numbers,
*-- which we then change to a string with TRANSFORM()
lcQuote = Transform(Val(lcQuote))
Endif

Return lcQuote








"Carlos Jones" wrote:

Good day all,

I am developing a personnel access control app and I do not want to rely
on system time to record the events, I rather prefer to read time from an
Internet server at application initialization. Users are able to change
datetime on their computers, this is a requirement some times to operate
another app so I can not block access to the system clock.

Does somebody know about an Internet Time Server, how to access it and
obtain the time? Some code sample woud be great !

Thank you in advance for your help.

Sincerely,
Carlos Jones.



.



Relevant Pages

  • Re: forms value and php echo stops after first space
    ... HTML, but if you look at the HTML source you'll see the value is not ... interprets what's after echo here as a string delimited by double quote ... that string, not the quote marks as well, is echo-ed. ... Either include the quotes in the echo-ed string (there ...
    (comp.lang.php)
  • Re: using $dbh->quote with UTF
    ... Yes printing to HTML was ... What I am trying to do is quote a string, ...
    (perl.dbi.users)
  • Replacing "illegal characters" in html
    ... I'm new to python and need to write a function to replace certain characters ... in a string (html). ... ' (Right quote) ...
    (comp.lang.python)
  • Re: getAttribute question
    ... oddity with IE that getAttributereturns an empty string if the ... HTML specification, ... appropriate places in the HTML 4 and DOM HTML specifications. ...
    (comp.lang.javascript)
  • Re: [PHP] generating an html intro text ...
    ... You would have to search out and pull in all closing tags. ... grab 256 characters -- The string. ... html markup should not go towards the string length count, ...
    (php.general)