Solved

Got a load of file's I am converting to a different format, but I need to figure out the Percentage of space between the files before and after

Posted on 2004-03-25
8
175 Views
Last Modified: 2010-04-05
I read the total file size of all the files I am converting, then loop through them and do the conversion and get the new size of all the files once complete.

So I end up with (in bytes)

StartSize := 956896475
EndSize  :=  25698

So ok, to get the percentage I do (I think) StartSize / EndSize = Percentage.

Is there anyway to do this on the fly with a progressbar?

So, I have the Startsize off ALL the files
I have the EndSize as each file is converted,

StartSize := 956896475
EndSize  :=  103

How can I get the percentage to set a progress bar up with?

Cheers
0
Comment
Question by:satmanuk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10675916
?? what will you display

a progress or a result
0
 
LVL 1

Author Comment

by:satmanuk
ID: 10675976
well, while the conversion is going on, i wanted to display a over-all progress bar of the results so far. But at the end, i want to just display the Total size before conversion and after and also a percentage of the difrence.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10676077
you formula should be

progessbar1.position := (CurrentProcessedEndSize / CurrentProcessedStartSize) * 100;

this could be called during and at end of your processing

for displaying the sizenumbers u could simple labels

meikl ;-)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:satmanuk
ID: 10676153
ok, tried that, but get the following message.
Incompatable types: 'Integer' and 'extended'

I am having to use a int64 to hold the file size because it can get very large.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10676200
try to change it to

progessbar1.position := integer((CurrentProcessedEndSize / CurrentProcessedStartSize) * 100);

or

progessbar1.position := trunc((CurrentProcessedEndSize / CurrentProcessedStartSize) * 100);


0
 
LVL 1

Author Comment

by:satmanuk
ID: 10676275
EndSize and  StartSize are both INT64

Tried
progressbar1.position := trunc((EndSize / StartSize) * 100);

compiles and runs, but get a error
floatingpoint division by zero

With

progressbar1.position := integer((EndSize /StartSize) * 100);
i get the folowing compile error

[Error] Unit1.pas(201): Invalid typecast

0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 300 total points
ID: 10676308
well, ok, your startsize seems to be 0 sometimes,
just change it to
if startsize <> 0 then
  progressbar1.position := trunc((EndSize / StartSize) * 100);

forget the integer alternative

meikl ;-)
0
 
LVL 1

Author Comment

by:satmanuk
ID: 10676340
cheers
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month10 days, 21 hours left to enroll

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question