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
174 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
Industry Leaders: 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

710 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