progbar = createprogressbar(200,400,200,15,0)
for f=0 to array count(ftpfiles())
if ftpfiles(f).name = "<your file to download>"
print "found file <your file to download>"
fsz = ftpfiles(f).size
bits = ftpfiles(f).bits
sync rate 0
timer()=0
sttm=timer()
ftp get file "<your file to download ftp file name>","<your file to download local name of file>",512 //,11289218
repeat
ftp proceed
fgp=ftp get progress()
setProgressBarPos progbar,fgp
set cursor 0,0 // this line speeds the download up and maintains the Mbps
print "progress: ";fgp
sync
until fgp=-1
setgadgetvisible progbar,0
entm = (timer()-sttm) / 1000
bps = (bits / entm)
print "bps: "; (bits / entm)
print "Mbps: "; bps / 1000000
sync rate 60
exit
endif
next f
If you remove the Set Cursor statement there is a slow down in speed. Obviously, we can remove the print statements and rely solely on the progress bar to do it's job.
Notice also the calculation of the bps and Mbps.
if you are new to programming and wondering what .bits is, this is the file size * 8 , i.e. ftpfiles().bits = fsz * 8 where fsz is e.g. file size({your filename})
Of course , I have divided the duration end by 1000 to produce the result in seconds and not milliseconds
Pro Programmer / Data Scientist, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others