Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TIdFTP component

Status
Not open for further replies.

liaml1

MIS
Nov 24, 2004
63
DM
Good day I am using a TIdFTP component fom the Indy Clients bar in Delphi 7. Whenever I call the STATUS command my application freezes completely. Below is a copy of the source code that calls the STATUS command:

procedure TForm1.CheckFTPStatus;
var
MyStatusList: TStringList;
i: integer;

begin
if idFTP1.Connected then ListBOx1.Items.Add('CONNECTED');
idFtp1.Status(MyStatusList);
for i:=0 to (idFTP1.DirectoryListing.Count -1) do
Listbox1.Items.Add(idFTP1.DirectoryListing.Items.Data);
end;

Basically what I am trying to do is read the STATUS information of teh FTP Server and store this info in a ListBox component. When the idFTP1.Status(MyStatusList) command is executed the app freezes completely.

Any help on this would surely be appreciated.

Liam

 
did you create the TStringList?

I've always done something more like

var
MyStatusList : TStrings;
begin
MStatusList := TStringList.Create;
//then add stuff to the StringList
MStatusList.Add('SomeString');
end;

what are you trying to accomplish with the StringList?


Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for anyone working with databases: The Fundamentals of Relational Database Design
 
I am trying to read the FTP Status information but to do so you need to pass a StringList as parameter to the idFTP.Status procedure. My dilema is that the program freezes when the idFTP.Status command is executed.

Liam
 
ok, except you don't have a StringList.....you have a variable that can become a Tstringlist, but you have to create it...

According to the TStringList Help Topic
[tt]If you use a string list only for the duration of a single routine, you can create it, use it, and destroy it all in one place. This is the safest way to work with string lists. Because the string-list object allocates memory for itself and its strings, you should use a try...finally block to ensure that the memory is freed even if an exception occurs.

1 Construct the string-list object.
2 In the try part of a try...finally block, use the string list.
3 In the finally part, free the string-list object.

The following event handler responds to a button click by constructing a string list, using it, and then destroying it.

procedure TForm1.Button1Click(Sender: TObject);

var
TempList: TStrings; { declare the list }
begin
TempList := TStringList.Create; { construct the list object }
try
{ use the string list }
finally
TempList.Free; { destroy the list object }
end;
end;[/tt]

Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for anyone working with databases: The Fundamentals of Relational Database Design
 
Additionally, I can't find 'STATUS' as a property or method of the TidFTP component....what version of Delphi are you using?

leslie
 
I tried your suggestion but I get the following error:
EIdInvalidFTPListingFormat 'Unknown FTP listing format'.

Does this mean that Delphi is unable to read the status of the server because it presents the information in a foemat that is unrecognizable?

Liam
 
Ok, I re-read the OP and see that you're using Delphi 7. Here's a thread ( found that has the same problem in 7, but it worked in 6, the code that worked in 6 has the same structure I showed you:
Code:
procedure GetStatus;
Var       a:tStringList;
begin
 a:=TStringList.Create;
 Form1.idFtp1.Status(a);
 Form1.Memo1.Lines.Clear;
 Form1.Memo1.Lines.AddStrings(a);
 a.Free;
end;

You may want to register with that site to get the answer provided to this other person.

I'll keep looking to see if I can find any other helpful information.
Leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top