flat assembler
Message board for the users of flat assembler.
Index
> Main > Progress Bar Counting. Goto page 1, 2 Next |
Author |
|
revolution 01 Aug 2011, 14:57
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.
|
|||
01 Aug 2011, 14:57 |
|
typedef 01 Aug 2011, 15:59
a good approach also would be to use a worker thread.
|
|||
01 Aug 2011, 15:59 |
|
gunblade 01 Aug 2011, 16:37
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 :)) |
|||
01 Aug 2011, 16:37 |
|
vid 01 Aug 2011, 16:52
Is your problem with rewriting in console display, or with watching status or downloading, or what?
|
|||
01 Aug 2011, 16:52 |
|
typedef 01 Aug 2011, 17:23
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 ? |
|||
01 Aug 2011, 17:23 |
|
LocoDelAssembly 01 Aug 2011, 18:22
|
|||
01 Aug 2011, 18:22 |
|
typedef 01 Aug 2011, 18:56
LocoDelAssembly wrote: You are really a posts count miner, even though we are preparing a special penalty for you LOL and what would that penalty be... ...meanwhile Code: lea rax,[users] inc [rax+typedef_post_count*8] |
|||
01 Aug 2011, 18:56 |
|
typedef 01 Aug 2011, 18:58
es.wikipedia.org/wiki/GNU_Wget
|
|||
01 Aug 2011, 18:58 |
|
typedef 01 Aug 2011, 18:59
^^^how do I translate to english ? :
|
|||
01 Aug 2011, 18:59 |
|
edfed 01 Aug 2011, 19:06
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. |
|||
01 Aug 2011, 19:06 |
|
Overflowz 01 Aug 2011, 20:02
gunblade
Sorry, I don't understand C but I though same technique Code: (DownloadBytes / FileSize)*100 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 |
|||
01 Aug 2011, 20:02 |
|
Enko 01 Aug 2011, 20:10
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 |
|||
01 Aug 2011, 20:10 |
|
JohnFound 01 Aug 2011, 20:12
(2*DownloadedBytes*MaximalBarLength +FileSize) div (2*FileSize) will give you the length of the "processed" part of the bar, rounded properly.
|
|||
01 Aug 2011, 20:12 |
|
Overflowz 01 Aug 2011, 20:31
How to get remote file size if I haven't downloaded it yet ?
|
|||
01 Aug 2011, 20:31 |
|
Enko 01 Aug 2011, 20:40
for getting the filesize, you should read the proper HTTP response.
CONTENT-LENGTH http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html |
|||
01 Aug 2011, 20:40 |
|
TmX 03 Aug 2011, 04:08
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.
|
|||||||||||
03 Aug 2011, 04:08 |
|
Overflowz 03 Aug 2011, 11:45
Thanks guys, I'll study on that now.
TmX I really don't understand C )) It's like brainfuck for me)) Thanks anyway! |
|||
03 Aug 2011, 11:45 |
|
Madis731 03 Aug 2011, 13:02
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 (I just couldn't resist) |
|||
03 Aug 2011, 13:02 |
|
JohnFound 03 Aug 2011, 13:15
Madis731 wrote: I usually avoid divisions and in this case I would make the progress bar a 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. |
|||
03 Aug 2011, 13:15 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.