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
170 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

18 Experts available now in Live!

Get 1:1 Help Now