Khryus Posted April 25, 2012 Share Posted April 25, 2012 (edited) Hi there, I'm using InetGet to download files off of my vps (will use this script to make my own patcher). I have tried doing this: Func downloadFile($fUrl, $fDir, $fName) Local $hDownload = InetGet($fUrl, $fDir&"\"&$fName, 1, 1) $dlPrc=(InetGetInfo($hDownload, 0)/InetGetInfo($hDownload, 1))*100 Do $dlPrc=(InetGetInfo($hDownload, 0)/InetGetInfo($hDownload, 1))*100 _GUICtrlStatusBar_SetText("Status: retrieving index file... ("&$dlPrc&"%)") Sleep(10) $dlPrc=(InetGetInfo($hDownload, 0)/InetGetInfo($hDownload, 1))*100 Until InetGetInfo($hDownload, 2) ; Check if the download is complete. Local $nBytes = InetGetInfo($hDownload, 0) InetClose($hDownload) ; Close the handle to release resources. Return InetGetInfo($hDownload, 2) EndFunc ;note, I modified the code from the help file to suit my needs And then called the function to download the file in my @TempDir. The problem is that the statusbar isn't being updated. I have previously set the text to "Status: idle", and even after I call the downloadFile function, it doesn't change. I know the file is downloaded because I can see it. How can I get it to display $dlPrc in my StatusBar? Edited April 25, 2012 by megablox "The story of a blade is linked in Blood." ―Yasuo Link to comment Share on other sites More sharing options...
hannes08 Posted April 25, 2012 Share Posted April 25, 2012 Hi megablox, have a look at the example of _GUICtrlStatusBar_EmbedControl() Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
Khryus Posted April 25, 2012 Author Share Posted April 25, 2012 Hi hannes, I'm sorry to say that but it confused me more : "The story of a blade is linked in Blood." ―Yasuo Link to comment Share on other sites More sharing options...
Khryus Posted April 25, 2012 Author Share Posted April 25, 2012 Oh okay, I tried running the example script, and that's definitely not what I'm trying to do. What I am trying to do, is to download a file from my VPS and display the progress of the download (in text format) on the Status Bar. For example, if the progress of the download was 47%, the Status Bar would say: "Status: retrieving index file... (47%)" But it only goes "Status: retrieiving index file... (100%)" (once it's finished, of course) "The story of a blade is linked in Blood." ―Yasuo Link to comment Share on other sites More sharing options...
MrMitchell Posted April 25, 2012 Share Posted April 25, 2012 (edited) Try using INetGetSize() instead of INetGetInfo() to get the size of the download - and just call that once and assign to a variable you can use for calculations. Not sure if that will make a difference or not, but now I'm actually curious what the difference could be between the two. Edit: Nevermind...I guess...didn't help for me. Still want to know what the difference is though! Edited April 25, 2012 by MrMitchell Link to comment Share on other sites More sharing options...
Khryus Posted April 25, 2012 Author Share Posted April 25, 2012 I'm going to skip this for now, so I can fix it later. If you still want to help go ahead, it'll be greatly appreciated "The story of a blade is linked in Blood." ―Yasuo Link to comment Share on other sites More sharing options...
hannes08 Posted April 25, 2012 Share Posted April 25, 2012 I would try to update the status in a label control first, and if that worked I'd try using the Status bar. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
MrMitchell Posted April 25, 2012 Share Posted April 25, 2012 Monitor $dlPrc using temporary alternate means like a ConsoleWrite(). Increase the sleep from 10 to something like 250 or even a half a second. How big is the file? Also trying monitoring InetGetInfo($hDownload, 1) to see what number is getting returned. You say your status bar eventually says 100% so there doesn't seem to be any problem setting the text. The problem seems to lie in the numbers and calculations... Link to comment Share on other sites More sharing options...
Khryus Posted April 25, 2012 Author Share Posted April 25, 2012 (edited) Hi MrMitchell, I've been monitoring $dlPrc as you asked, and I found out this: -1.#IND -1.#IND -1.#IND -1.#IND -1.#IND 1.21944593509338 1.21944593509338 5.56372207886356 5.56372207886356 16.996027720364 16.996027720364 29.3429178131845 29.3429178131845 41.6135925350617 41.6135925350617 53.5794057731655 53.5794057731655 65.926295865986 65.926295865986 77.9683244750331 77.9683244750331 90.2389991969103 90.2389991969103 100 So I decided to fix the -1.#IND by adding an if statement after each change. $dlPrc=(InetGetInfo($hDownload, 0)/InetGetInfo($hDownload, 1))*100 If $dlPrc=="-1.#IND" Then $dlPrc=0 EndIf And it doesn't output -1.#IND now. Still, no text change. P.S: The file is 1.28mb Edited April 25, 2012 by megablox "The story of a blade is linked in Blood." ―Yasuo Link to comment Share on other sites More sharing options...
MrMitchell Posted April 25, 2012 Share Posted April 25, 2012 So maybe the file is just so small it finishes too quickly and all you see is the last text you set on your status bar which is that the file download reached 100%? Link to comment Share on other sites More sharing options...
Khryus Posted April 25, 2012 Author Share Posted April 25, 2012 (edited) OH, WOW. I just noticed, I didn't add in which StatusBar's text had to change... Thanks for the support lol! Changed this _GUICtrlStatusBar_SetText("Status: retrieving index file... ("&$dlPrc&"%)") To this _GUICtrlStatusBar_SetText($StatusBar1, "Status: retrieving index file... ("&StringMid($dlPrc, 1, 5)&"%)") Edited April 25, 2012 by megablox "The story of a blade is linked in Blood." ―Yasuo Link to comment Share on other sites More sharing options...
MrMitchell Posted April 25, 2012 Share Posted April 25, 2012 Oh okay, I tried running the example script, and that's definitely not what I'm trying to do.What I am trying to do, is to download a file from my VPS and display the progress of the download (in text format) on the Status Bar.For example, if the progress of the download was 47%, the Status Bar would say:"Status: retrieving index file... (47%)"But it only goes"Status: retrieiving index file... (100%)" (once it's finished, of course)So how did it change as per your post #4? Link to comment Share on other sites More sharing options...
Khryus Posted April 25, 2012 Author Share Posted April 25, 2012 (edited) It changed because I had another_GUICtrlStatusBar_SetText("Status: retrieving index file... ("&$dlPrc&"%)")To read the $dlPrc out of the loop, and this one had the $StatusBar variable. Read the other reply Edited April 25, 2012 by megablox "The story of a blade is linked in Blood." ―Yasuo Link to comment Share on other sites More sharing options...
MrMitchell Posted April 25, 2012 Share Posted April 25, 2012 LoL ok, anyway glad it's working. Link to comment Share on other sites More sharing options...
Khryus Posted April 25, 2012 Author Share Posted April 25, 2012 Yeah, me too. Thanks for the support everyone "The story of a blade is linked in Blood." ―Yasuo Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now