Re: URL to Internet
Posted: Thu May 28, 2020 12:44 pm
It did indeed work quite well. Thank you. I never would have thought to look in Rosetta for the sample code. Here's a working demo, to save others a bit of head scratching.
Code: Select all
URL$="http://tgftp.nws.noaa.gov/data/observations/metar/stations/KPHL.TXT"
FileName$="ReceivedData$"
ReturnCode=DownloadToFile(URL$, FileName$)
if ReturnCode=0 then
open FileName$ for input as #f
FileText$ = input$(#f, LOF(#f))
close #f
print FileText$
else
print "ReturnCode = "; ReturnCode
end if
print "Program Complete."
end
function DownloadToFile(urlfile$, localfile$)
open "URLmon" for dll as #url
calldll #url, "URLDownloadToFileA",_
0 as long,_ 'null
urlfile$ as ptr,_ 'url to download
localfile$ as ptr,_ 'save file name
0 as long,_ 'reserved, must be 0
0 as long,_ 'callback address, can be 0
DownloadToFile as ulong '0=success
close #url
end function