ErosOlmi
18-03-2007, 10:19
This thinBasic script will download default thinBasic web site page locally.
The same can be used for whatever file from internet. Just change the url.
uses "INet"
dim ret as number
ret = INET_URLDownLoad("http://www.thinbasic.com", APP_SOURCEPATH + "Home.html")
IF ret <> %TRUE THEN
msgbox(0, "Error: " + ret)
END IF
spiritsoul
19-11-2008, 00:56
This thinBasic script will download default thinBasic web site page locally.
The same can be used for whatever file from internet. Just change the url.
uses "INet"
dim ret as number
ret = INET_URLDownLoad("http://www.thinbasic.com", APP_SOURCEPATH + "Home.html")
IF ret <> %TRUE THEN
msgbox(0, "Error: " + ret)
END IF
The code looks right to me, but for some reason, I can't get it to work on my computer. Using Windows XP home edtion.
What might I be doing wrong. It doesn't produce any error messages, it just doesn't download the page.
Thanks
Bob
If you look in the folder where you saved the program you should find the downloaded html file.
I'm running Vista & the program seems to work fine here. :)
The page will [download] AKA:(Save to file)... EG, it will not [doanload & display] AKA:(Launch a viewer/browser.)
INET_UrlDownload = Save to file. (If no path is set, it saves in script location. Dont forget the "http://" on the URL and the ".htm" on the file name.)
INET_UrlDownload ("http://www.isawhim.com", "test.htm")
Or...
Load directly into a STRING
INET_UrlGetString ("http://www.isawhim.com")
To display/launch/run the file you downloaded, you would need to launch a viewer, or you can program your own viewer. If you want to open it with MSIE or FireFox or Opera or Netscape or Chrome... etc... you can use the commands in the "OS" module, called "OS_ShellExecute", which will (launch/open) the file.
OS_ShellExecute("open", "test.htm", "", "", 1)
or
OS_ShellExecute("open", "test.htm", "", ".\", 1)
Or, you can load the file into a string, with the "File" module using the "FILE_Load" command, that loads a file in one line. That is if you wish to edit the file data, or use the HTML-Data inside the file, to display your own way.
USES "Console"
USES "File"
USES "OS"
USES "INET"
DIM x AS STRING
Console_PrintLine ""
Console_PrintLine " --- Hit any key to begin ---"
WAITKEY
Console_Cls
Console_PrintLine "Loading URL to STRING from URL"
WAITKEY (3)
x = INET_UrlGetString ("http://www.isawhim.com")
Console_PrintLine x
Console_PrintLine ""
Console_PrintLine " --- Hit any key to continue ---"
WAITKEY
Console_Cls
Console_PrintLine "Loading URL to FILE from URL"
WAITKEY (1)
Console_PrintLine " - One moment, fetching file..."
INET_UrlDownload ("http://www.isawhim.com", "test.htm")
Console_PrintLine "File downloaded, check script folder for ""test.htm"" file."
Console_PrintLine ""
Console_PrintLine " --- Hit any key to continue ---"
WAITKEY
Console_Cls
Console_PrintLine "Loading FILE to STRING from FILE"
WAITKEY (3)
x = ""
x = FILE_Load("test.htm")
Console_PrintLine x
Console_PrintLine ""
Console_PrintLine " --- Hit any key to continue ---"
WAITKEY
Console_Cls
Console_PrintLine "Launching FILE from THIS FOLDER"
OS_ShellExecute("open", "test.htm", "", ".\", 1)
Console_PrintLine " - File launched..."
Console_PrintLine ""
Console_PrintLine " --- Hit any key to exit ---"
WAITKEY
Remember, these commands, most of them, are from a programs perspective. From a user perspective, "Download" is "Get it, and show it", from a program perspective, "Download" is "Get it, and put it here".
Hope that helps a little.
If you want to make life a little easier, you can designate a special folder in C:\ for all your experimantal file read/write operations. Or, since the default location is "Where the script is run from." Develop all scripts in a special folder.
spiritsoul
19-11-2008, 13:23
If you look in the folder where you saved the program you should find the downloaded html file.
I'm running Vista & the program seems to work fine here. :)
Thanks Matthew, I found it and it did work. Now to get it to come up and run when I ask it to...
Thanks again.
Bob