You should treat the udf as a black box and not changing anything.

here a sample of how to use it in a script :

Code:


break on

$err = FTPget("ftp.sonnenwaermeag.de/test.txt","c:\daten","user","password")

if not $err
"File downloaded.." ?
else
"Download Error: " + $err ?
endif

? "Hit a key ..."
get $

exit 0

; udf --- do not change below

Function FTPget($sURL, $sTargetFile, optional $sUser, optional $sPass)
Dim $oFTP, $oStream
$sUser=""+$sUser
$oFTP = CreateObject("Microsoft.XMLHTTP")
if @error $ftpget=1 exit 1 endif
$oStream = CreateObject("ADODB.Stream")
if @error $ftpget=2 exit 2 endif
if $sUser
$oFTP.Open("GET", $sURL, not 1, $sUser, $sPass)
else
$oFTP.Open("GET", $sURL, not 1)
endif
if @error $ftpget=3 exit 3 endif
$oFTP.Send
$oStream.Type = 1
$oStream.Mode = 3
$oStream.open
$oStream.Write($oFTP.responseBody)
if @error $ftpget=4 exit 4 endif
$oStream.SaveToFile($sTargetFile, 2)
if @error $ftpget=5 exit 5 endif
$oStream.Close
EndFunction



more info on this topic : How to use udfs


Edited by Jochen (2005-12-01 12:07 PM)
_________________________