flat assembler
Message board for the users of flat assembler.

Index > Main > Progress Bar Counting.

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz
Hello everyone, I need some help. I'm trying to make something like wget (console downloader) but I don't know how to "increase" progress bar blocks. Here's how it should like:
Code:
[=======>             ] 50%
[====================>] 100%    

or something like that.. like wget has. Can anybody explain me how to do such thing ? I need only progress bar information, how to increase it or count things etc.. Thanks! Smile
Post 01 Aug 2011, 14:52
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17716
Location: In your JS exploiting you and your system
revolution
You just keep redrawing the bar at periodic intervals to match the current status of the task. Depending upon how your program works you could use a timer to update the display.
Post 01 Aug 2011, 14:57
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
a good approach also would be to use a worker thread.
Post 01 Aug 2011, 15:59
View user's profile Send private message Reply with quote
gunblade



Joined: 19 Feb 2004
Posts: 209
gunblade
Well, you can take a look at wget's progress code (its C, but easy enough to understand):
http://bzr.savannah.gnu.org/lh/wget/trunk/annotate/head:/src/progress.c
Although wget's code seems a bit excessive for what it is.

Easiest way I can think of.. do:

(Downloaded Bytes / Total Size) * Progress Bar Length

That'll give you a value between 0 and Progress Bar Length (number of equals in the progress bar). Then just use that value in a loop to do:
Code:
for (x=0;x<val;x++){
  progress[val] = '=';
}
progress[val+1] = '>';
    


Probably not optimal.. but the idea should work. (Sorry about the C :))
Post 01 Aug 2011, 16:37
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Is your problem with rewriting in console display, or with watching status or downloading, or what?
Post 01 Aug 2011, 16:52
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
Is this wget a new thing or am I just not up to date with the technology. The reason why I am asking is because I've seen people mentioning it in forums and I thought it might just be a new thing in town.

Is it ?
Post 01 Aug 2011, 17:23
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Post 01 Aug 2011, 18:22
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef

LOL and what would that penalty be... Very Happy Very Happy


...meanwhile
Code:
lea rax,[users]
inc [rax+typedef_post_count*8]
    
Post 01 Aug 2011, 18:56
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
es.wikipedia.org/wiki/GNU_Wget Shocked
Post 01 Aug 2011, 18:58
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
^^^how do I translate to english ? :Cool Rolling Eyes Laughing
Post 01 Aug 2011, 18:59
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
a progress bar is just a sort of cross product.

one side is the real data about what is progressing, let say, a counter and a size value.

the other side is the display of this cross product, inside a rectangle, as a simple horizontal or vertical line.

combinate both and you have the progress bar, you just have to redraw the rectangle that shows the progress.

to combinate, you will just divide the count by the size, and multiply by the size in pixels of the progress bar. in fact, you multiply the count by the size of progress bar, and divide by the maximal size to process; to don't loose resolution, because only count >= size will give result more than 0.

then:
Code:
count dd 30
max dd 235
bar:
.lengh dd 100
.cursor dd ?

mov eax,[count]
mul eax,[bar.lengh]
cdq 
div [max]
mov [bar.cursor],eax
    

after this little calculation, you just have to use the datas to display as you like.
Post 01 Aug 2011, 19:06
View user's profile Send private message Visit poster's website Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz
gunblade
Sorry, I don't understand C Sad but I though same technique Smile
Code:
(DownloadBytes / FileSize)*100    
like percentages. if it will 1%, then it will raise block with 1 and so on.. If I'm thinking correctly.
typedef
It's like Unix based systems download manager or something like that. (Also available on windows too.)
revolution
My problem is how to count bytes or progress, therefore, I can increase progress with result. I need just know how to get file size even if I haven't downloaded it yet.. I'm using winsock. Thanks Smile
Post 01 Aug 2011, 20:02
View user's profile Send private message Reply with quote
Enko



Joined: 03 Apr 2007
Posts: 678
Location: Mar del Plata
Enko
Personally I prefear more the apps console when they write a lot of stuff smothing like:
Code:
wget starting
initialiating connection
connecting with server
starting download http:/www.xxxxxx.com/xxxxxx.xxx
creating connection 1/4
Downloaded 5%
creating connection 2/4
Downloaded 10%
creating connection 3/4
creating connection 4/4 fail: connections limit
Downloaded 20%
Downloaded 30%
Downloaded 40%
Downloaded 70%
File downloaded succesfully
    

Black background, green font and of course, every time you write a character, there should be a nasty BIP sound.
This way 1t l00ks l1k3 real h4k3rZ!

hahaha
Post 01 Aug 2011, 20:10
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
(2*DownloadedBytes*MaximalBarLength +FileSize) div (2*FileSize) will give you the length of the "processed" part of the bar, rounded properly.
Post 01 Aug 2011, 20:12
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz
How to get remote file size if I haven't downloaded it yet ?
Post 01 Aug 2011, 20:31
View user's profile Send private message Reply with quote
Enko



Joined: 03 Apr 2007
Posts: 678
Location: Mar del Plata
Enko
for getting the filesize, you should read the proper HTTP response.
CONTENT-LENGTH

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
Post 01 Aug 2011, 20:40
View user's profile Send private message Reply with quote
TmX



Joined: 02 Mar 2006
Posts: 824
Location: Jakarta, Indonesia
TmX
I have the progress bar sample code (translated from BCX). Unfortunately, it's in C, but I think you can get the general idea.

Source + binary attached.


Description:
Download
Filename: progbar.zip
Filesize: 9.2 KB
Downloaded: 179 Time(s)

Post 03 Aug 2011, 04:08
View user's profile Send private message Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz
Thanks guys, I'll study on that now.
TmX
I really don't understand C )) It's like brainfuck for me)) Thanks anyway!
Post 03 Aug 2011, 11:45
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
I usually avoid divisions and in this case I would make the progress bar a
multiple of 2 i.e. 64. That way your div becomes shr 6. There are even samples out there to divide by 80 (the console width) without using div instruction.

Offtopic:
BrainF* is like C to me Smile
(I just couldn't resist)
Post 03 Aug 2011, 13:02
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Madis731 wrote:
I usually avoid divisions and in this case I would make the progress bar a
multiple of 2 i.e. 64. That way your div becomes shr 6. There are even samples out there to divide by 80 (the console width) without using div instruction.

You have to divide to the size_of_the_whole, not the length of the progress bar. See the above formulas.
You can try to use subtraction instead of division (like in Bresenham's algorithm), but it will work only on incremental progress.
Post 03 Aug 2011, 13:15
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.