PDA

View Full Version : Do you need to download multiple files / pages from internet?



ErosOlmi
16-10-2006, 10:46
Imagine you have to download multiple pages from internet. Some files, some pages, some FTP ...
Here an example you can amend as you prefer.

Name the following file as "Sites.txt". It will contain the list of the downloads you need to perform. Just an example

http://www.thinbasic.com/
http://www.codingmonkeys.com
ftp://ftp.suse.com/pub/projects/tcl/README


And this is the thinBasic script

Uses "File" '---Load File module needed for File_Load function
Uses "iNet" '---Load iNet module needed for iNet_UrlDownload function

'---Loads all file lines
DIM Sites AS STRING = File_Load(App_SourcePath & "Sites.txt")

'---Determine the number of lines
DIM nLines AS LONG = PARSECOUNT(Sites, $CRLF)

'---This function will parse the input string for $CRLF delimiters
' filling and dimensioning sLines array
DIM sLines() AS STRING
PARSE Sites, sLines, $CRLF

'---Now scan the array in order to find whatever string
' If string is found, corresponding line will be appended
' to output buffer
DIM Count AS LONG
DIM Ret AS LONG
FOR Count = 1 TO nLines
Ret = INET_URLDownLoad(sLines(Count), APP_SOURCEPATH + "FileOut" & Count & ".txt")
IF Ret <> %TRUE THEN
msgbox(0, "Error code for line " & Count & ": " + Ret)
END IF
NEXT

'---End
MSGBOX 0, "End of the script"