January 1, 2005

WinTask - DownloadFile$

'
' DownloadFile$ - Download HTML from a URL in the background and put it in a string variable
'
' Author: Joe Strazzere
'

Function DownloadFile$(URL$)
    Local ReturnedString$
    Local TempString$
 Local TempFile$

 TempFile$="c:jsstemp.txt"

    If Exist(TempFile$) then
      Kill(TempFile$)
    End If

    Write(TempFile$, "URL not found!")

    External("urlmon.dll", "URLDownloadToFileA", 0, URL$, TempFile$, 0, 0)

    SetReadPos(TempFile$,0)
    TempString$=""

    Repeat
      Read(TempFile$, ReturnedString$)
     TempString$ = TempString$ + ReturnedString$
    Until EOF(TempFile$)

    DownloadFile$ = TempString$
EndFunction

'
' try it
'
var$=DownloadFile$("http://www.google.com/intl/en/about.html")
msgbox(var$)