Discussion:
How to use TIdFTP.OnWork<...> in a console application???
(too old to reply)
Bo Berglund
2008-07-01 06:17:20 UTC
Permalink
I am writing an console application that is transfering some data via
FTP and I am using TIdFTP for this. The transfers are OK but I have a
problem in getting the user feedback working during transfers...

The TIdFTP object is created in code when the console application
starts:

FTP := TIdFTP.Create;

Then I set the events like this:
FTP.OnWorkBegin := FTPWorkBegin;
FTP.OnWork := FTPWork;
FTP.OnWorkEnd := FTPWorkEnd;

The procedures are defined like this:

procedure FTPWorkBegin(Sender: TObject; AWorkMode: TWorkMode; const
AWorkCountMax: Integer);

procedure FTPWork(Sender: TObject; AWorkMode: TWorkMode; const
AWorkCount: Integer);

procedure FTPWorkEnd(Sender: TObject; AWorkMode: TWorkMode);

The idea is to use these events to write a percent done message on the
standard output using the datya supplied by the event.

But the code won't compile, it stops and gives the error:

"[Error] Xmltv2Mei.dpr(790): Incompatible types: 'method pointer and
regular procedure'"

I *have* used this before in a GUI application so I am now baffled as
to why it won't work in a console app when everything else works just
fine.

Any ideas about what I can do to fix this???
(I cannot change the application around to a GUI app because of the
way it is going to be executed)

I am using Delphi 7 and the Indy 10 snapshot from about 1 month ago.


/BoB
Chad Z. Hower aka Kudzu
2008-07-01 11:41:13 UTC
Permalink
Make a class and pass it a method instead of a non object procedure.
Post by Bo Berglund
I am writing an console application that is transfering some data via
FTP and I am using TIdFTP for this. The transfers are OK but I have a
problem in getting the user feedback working during transfers...
The TIdFTP object is created in code when the console application
FTP := TIdFTP.Create;
FTP.OnWorkBegin := FTPWorkBegin;
FTP.OnWork := FTPWork;
FTP.OnWorkEnd := FTPWorkEnd;
procedure FTPWorkBegin(Sender: TObject; AWorkMode: TWorkMode; const
AWorkCountMax: Integer);
procedure FTPWork(Sender: TObject; AWorkMode: TWorkMode; const
AWorkCount: Integer);
procedure FTPWorkEnd(Sender: TObject; AWorkMode: TWorkMode);
The idea is to use these events to write a percent done message on the
standard output using the datya supplied by the event.
"[Error] Xmltv2Mei.dpr(790): Incompatible types: 'method pointer and
regular procedure'"
I *have* used this before in a GUI application so I am now baffled as
to why it won't work in a console app when everything else works just
fine.
Any ideas about what I can do to fix this???
(I cannot change the application around to a GUI app because of the
way it is going to be executed)
I am using Delphi 7 and the Indy 10 snapshot from about 1 month ago.
/BoB
Remy Lebeau (TeamB)
2008-07-01 16:58:41 UTC
Permalink
Post by Bo Berglund
I am writing an console application that is transfering some data
via FTP and I am using TIdFTP for this. The transfers are OK
but I have a problem in getting the user feedback working during
transfers...
I just answered this exact same question two weeks ago. Have a look in the
"Console App with Indy10 FTP client - event handlers" discussion in this
same newsgroup.
Post by Bo Berglund
I *have* used this before in a GUI application so I am now baffled
as to why it won't work in a console app when everything else
works just fine.
That is because your event handlers were class members in the GUI app, but
are not class members in the console app.


Gambit

Loading...