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
172 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

786 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