User Tools

Site Tools


downloading_20a_20file_20from_20a_20url

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
downloading_20a_20file_20from_20a_20url [2018/03/31 13:19] – external edit 127.0.0.1downloading_20a_20file_20from_20a_20url [2024/01/05 00:22] (current) – external edit 127.0.0.1
Line 2: Line 2:
  
 //by Richard Russell, August 2007; amended July 2009//\\ \\  The simplest method of downloading a file (e.g. a web page) from an internet URL is to use the **URLDownloadToFile** API function as described in the main [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwine.html#urlmon|documentation]]. The following program segment illustrates how to do that:\\ \\  //by Richard Russell, August 2007; amended July 2009//\\ \\  The simplest method of downloading a file (e.g. a web page) from an internet URL is to use the **URLDownloadToFile** API function as described in the main [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwine.html#urlmon|documentation]]. The following program segment illustrates how to do that:\\ \\ 
 +<code bb4w>
         url$ = "http://www.bbcbasic.co.uk/bbcwin/bbcwin.html"         url$ = "http://www.bbcbasic.co.uk/bbcwin/bbcwin.html"
         file$ = @tmp$+"bbcwin.html"         file$ = @tmp$+"bbcwin.html"
Line 15: Line 16:
         IF res% ERROR 100, "Couldn't download "+url$         IF res% ERROR 100, "Couldn't download "+url$
         ENDPROC         ENDPROC
 +</code>
 If you need to flush the cache to ensure you retrieve the latest version (e.g. it's a webcam picture) then it becomes slightly more complicated:\\ \\  If you need to flush the cache to ensure you retrieve the latest version (e.g. it's a webcam picture) then it becomes slightly more complicated:\\ \\ 
 +<code bb4w>
         url$ = "http://www.bbcbasic.co.uk/bbcwin/bbcwin.html"         url$ = "http://www.bbcbasic.co.uk/bbcwin/bbcwin.html"
         file$ = @tmp$+"bbcwin.html"         file$ = @tmp$+"bbcwin.html"
Line 33: Line 36:
         IF res% ERROR 100, "Couldn't download "+url$         IF res% ERROR 100, "Couldn't download "+url$
         ENDPROC         ENDPROC
 +</code>
 These routines can be used for both **HTTP** and **FTP** downloads.\\ \\  However under some circumstances the above methods do not work reliably. In that case you may find the following routine to be more successful:\\ \\  These routines can be used for both **HTTP** and **FTP** downloads.\\ \\  However under some circumstances the above methods do not work reliably. In that case you may find the following routine to be more successful:\\ \\ 
 +<code bb4w>
         url$ = "http://www.bbcbasic.co.uk/bbcwin/bbcwin.html"         url$ = "http://www.bbcbasic.co.uk/bbcwin/bbcwin.html"
         file$ = @tmp$+"bbcwin.html"         file$ = @tmp$+"bbcwin.html"
Line 90: Line 95:
         wininet% += 0 : IF wininet% SYS "FreeLibrary", wininet% : wininet% = 0         wininet% += 0 : IF wininet% SYS "FreeLibrary", wininet% : wininet% = 0
         ENDPROC         ENDPROC
-Unfortunately with early versions of Internet Explorer (pre 4.0) the above code results in a memory leak when used for **http** downloads (see http://support.microsoft.com/kb/174897). If you need your code to work with such old versions you can use the following routine instead (note that because the HTTP protocol is implied, you must **not** include the **"http://"** in the supplied **server$**):\\ \\ +</code> 
 +Unfortunately with early versions of Internet Explorer (pre 4.0) the above code results in a memory leak when used for **http** downloads (see http://support.microsoft.com/kb/174897). If you need your code to work with such old versions you can use the following routine instead (note that because the HTTP protocol is implied, you must **not** include the **<nowiki>"http://"</nowiki>** in the supplied **server$**):\\ \\  
 +<code bb4w>
         server$ = "www.bbcbasic.co.uk"         server$ = "www.bbcbasic.co.uk"
         request$ = "bbcwin/bbcwin.html"         request$ = "bbcwin/bbcwin.html"
Line 167: Line 174:
         wininet% += 0 : IF wininet% SYS "FreeLibrary", wininet% : wininet% = 0         wininet% += 0 : IF wininet% SYS "FreeLibrary", wininet% : wininet% = 0
         ENDPROC         ENDPROC
 +</code>
downloading_20a_20file_20from_20a_20url.1522502357.txt.gz · Last modified: 2024/01/05 00:18 (external edit)