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.
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
That should be ftp:// rather than http:// surely? If it's also available via the HTTP protocol you should be able to use httpget$() which is a built-in function in Liberty BASIC 4.5 and is available in LBB via the lb45func.bas library.
And indeed I can confirm that this does work. Seems to me that you have been making a mountain out of a molehill (and the information you received that it was only available via FTP was at the very least misleading):
Hmm. Both programs work regardless if the message is prefixed with http:// or ftp://. I guess I misunderstood that that the data was available only by FTP. Is this all a molehill? Over and out.
JackKelly wrote: ↑Fri May 29, 2020 1:10 am
Both programs work regardless if the message is prefixed with http:// or ftp://.
That's probably because the file is available via HTTP anyway. My understanding is that URLDownloadToFile will successfully download a file using FTP (so long as the URL starts ftp:// and there is no requirement for a username or password) but I would expect httpget$() to work only if it can be downloaded via HTTP (probably the specified protocol is ignored in that case). Obviously when httpget$() works it's far easier than any other solution, especially in LB 4.5.