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
171 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now