Board index » delphi » HELP!Connecting progress bar with file load

HELP!Connecting progress bar with file load

How can I connect progress bar to show progress of file loading?
    10x in advance!

 

Re:HELP!Connecting progress bar with file load


Brett Lathrope <lathr...@netcom.com> wrote in article
<33e98f7b.209164...@10.0.2.1>...

Quote
> On Sun, 03 Aug 1997 20:03:19 +0200, Stasa Stanisic

<sta...@EUnet.yu>

Quote
> wrote:

> >How can I connect progress bar to show progress of file
loading?
> >    10x in advance!

> If your file is a text file, then you really can't since
Delphi
> doesn't offer facilities to retreive the file size of a text
file.

> What I do is set the progress bar's MAX property to a value I
believe
> will be more than enough, then I bump the POSITION property
everytime
> I do a READLN or WRITELN....sometimes you'll finish before
the
> progress bar shows 100%, but at least it let's your user know
> something is going on.  :)

Seems like you could open it as a file of byte first, get the
size in bytes, then reopen it as a text file, then bump the
progress bar based on the size of each string read in.  Haven't
done it; just a thought...
Quote

[snip]

Re:HELP!Connecting progress bar with file load


{===============================================}
{Returns the filesize of "filename" as an integer}
{===============================================}
function filesize(filename: string): longint;
var
 ts: tsearchrec;
begin
 findfirst(filename,faAnyFile,ts);
 filesize:=ts.size;
end;

Quote
Brett Lathrope wrote:
> On Sun, 03 Aug 1997 20:03:19 +0200, Stasa Stanisic <sta...@EUnet.yu>
> wrote:

> >How can I connect progress bar to show progress of file loading?
> >    10x in advance!

> If your file is a text file, then you really can't since Delphi
> doesn't offer facilities to retreive the file size of a text file.

> What I do is set the progress bar's MAX property to a value I believe
> will be more than enough, then I bump the POSITION property everytime
> I do a READLN or WRITELN....sometimes you'll finish before the
> progress bar shows 100%, but at least it let's your user know
> something is going on.  :)

> If it's a file of records (a binary file)...after you've opened the
> file, you can use FILESIZE to get the number of records, and then set
> the MAX property of your progress bar FileSize and then INC the
> position property of the progress bar everytime you read a record.

> Hope that helps.

> Brett

Re:HELP!Connecting progress bar with file load


This is a question more than a statement, but, in 32-bit,
shouldn't he be doing a FindClose before he exits the function?

Chuck Hall <cqh...@4dcorp.com> wrote in article
<33EA8179.F546...@4dcorp.com>...

Quote
> {===============================================}
> {Returns the filesize of "filename" as an integer}
> {===============================================}
> function filesize(filename: string): longint;
> var
>  ts: tsearchrec;
> begin
>  findfirst(filename,faAnyFile,ts);
>  filesize:=ts.size;
> end;

[snip]

Re:HELP!Connecting progress bar with file load


You're right!

I wrote the function for 16-bit, which doesn't require (or even respond)
to the FindClose, but FindClose should be used for 32-bit to free up the
handle.

Quote
Keith G. Murphy wrote:
> This is a question more than a statement, but, in 32-bit,
> shouldn't he be doing a FindClose before he exits the function?

> Chuck Hall <cqh...@4dcorp.com> wrote in article
> <33EA8179.F546...@4dcorp.com>...
> > {===============================================}
> > {Returns the filesize of "filename" as an integer}
> > {===============================================}
> > function filesize(filename: string): longint;
> > var
> >  ts: tsearchrec;
> > begin
> >  findfirst(filename,faAnyFile,ts);
> >  filesize:=ts.size;
> > end;

> [snip]

Other Threads