Re: TIdFTP lies in OnWork event

Giganews Newsgroups
Subject: Re: TIdFTP lies in OnWork event
Posted by:  Remy Lebeau (TeamB) (no.spam@no.spam.com)
Date: Tue, 16 May 2006

"Mitis" <mit…@tej.pl> wrote in message
news:8c8ff74d9a0e8c8474187a9ca…@news.atozedsoftware.com...

> TIdFTP->OnWork lies about WorkCount

No, it doesn't.

> while I setup IOHandler to 8Kb.

What do you mean?

>  if (uploading) then AwokrCount := aworkcount div 2;
///////////////
> <----HERE

You should be using the AWorkMode parameter instead of your own variable.
Also, the AWorkCount is already a running count of the total number of bytes
sent, so you should not be tracking the bytes yourself manually as well.
Try this code instead:

    procedure Tfdotransfer.ftpWorkBegin(ASender: TObject; AWorkMode:
TWorkMode; AWorkCountMax: Integer);
    begin
        if AWorkMode = wmWrite then
        begin
            pb.Position := 0;
            pb.Max = AWorkCountMax;
            ldsize.Caption := size2string(0, 'kb');
        end;
    end;

    procedure Tfdotransfer.ftpWork(ASender: TObject; AWorkMode: TWorkMode;
AWorkCount: Integer);
    begin
        if AWorkMode = wmWrite then
        begin
            pb.Position := AWorkCount;
            ldsize.Caption := size2string(AWorkCount, 'kb');
            if fabort and (not faborted) then
            begin
                faborted := true;
                ftp.Abort;
            end;
        end;
    end;

    procedure Tfdotransfer.ftpWorkEnd(ASender: TObject; AWorkMode:
TWorkMode);
    begin
        if AWorkMode = wmWrite then
        begin
            pb.Position := pb.Max;
            ldsize.Caption := size2string(pb.Max, 'kb');
        end;
    end;

Gambit

Replies

In response to

TIdFTP lies in OnWork event posted by Mitis on Tue, 16 May 2006