Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here






I am writing an app that archives files from one box to another. It connects using the NMFTP1 component and I retrieve a listing. The issue is that the listing never completes. I use the ListItem method and can get all the directory info but the call gets stuck in NMFTP->List(). I have set a timer to every 5 seconds and set a flag manually to say whether I have a directory entry .i.e has the ListItem method been called. If the timer completes and I have not seen a new directory entry in ListItem then I call NMFTP->Abort() and then Application->Terminate. HOWEVER this still does not work, the application just remains running at a high CPU rate and doesn't stop.

This is an issue I think with the box I am connecting to as I have used NMFTP loads of times successfully I am not new to it. I need to get this software to recognize that the listing has ended and move on but I can't . Any help much appreciated, full source below.

Just to emphasize the following code I think works perfectly against a "normal" windows FTP server but it hangs when I go against this other box. ( Just to clarify the other box is a bespoke hardware voice recorder that allows ftp connections , thats all I know about it ). What I am after is a way that once the Timer event spots the timeout and starts printing "Done" on the Memo for the application to just stop. By the way it does print "Done" in the Memo, it just does it every 5 seconds instead of printing it once and then exiting. I want the program to exit but it won't and that is what I really need with : how can I force my program to just stop and exit, Application->Terminate() doesn't do it in this case.

This is my form in text format :

object Form1: TForm1
Left = 304
Top = 141
Width = 696
Height = 354
Caption = 'Voice Archive'
Color = clBtnFace
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
Menu = MainMenu1
OldCreateOrder = False
Position = poDesktopCenter
PixelsPerInch = 96
TextHeight = 13
object Panel2: TPanel
Left = 0
Top = 0
Width = 680
Height = 296
Align = alClient
Caption = 'Panel2'
TabOrder = 0
object Memo1: TMemo
Left = 1
Top = 1
Width = 336
Height = 294
Align = alLeft
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Courier New'
Font.Style = []
Lines.Strings = (
ParentFont = False
TabOrder = 0
object Memo2: TMemo
Left = 337
Top = 1
Width = 342
Height = 294
Align = alClient
Lines.Strings = (
TabOrder = 1
Port = 21
ReportLevel = 16
OnConnect = NMFTP1Connect
OnStatus = NMFTP1Status
OnListItem = NMFTP1ListItem
Vendor = 2411
ParseList = False
ProxyPort = 0
Passive = False
FirewallType = FTUser
FWAuthenticate = False
Left = 160
Top = 24
object MainMenu1: TMainMenu
Left = 216
Top = 8
object File1: TMenuItem
Caption = 'File'
object Start1: TMenuItem
Caption = 'Start'
OnClick = Start1Click
object Timer1: TTimer
Enabled = False
Interval = 5000
OnTimer = Timer1Timer
Left = 392
Top = 48

This is my header Unit1.h

#ifndef Unit1H
#define Unit1H
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <NMFtp.hpp>;
#include <Psock.hpp>
#include <Menus.hpp>
class TForm1 : public TForm
__published: // IDE-managed Components
TPanel *Panel2;
TMemo *Memo1;
TMainMenu *MainMenu1;
TMenuItem *File1;
TMenuItem *Start1;
TMemo *Memo2;
TTimer *Timer1;
void __fastcall NMFTP1Connect(TObject *Sender);
void __fastcall NMFTP1ListItem(AnsiString Listing);
void __fastcall Start1Click(TObject *Sender);
void __fastcall NMFTP1Status(TComponent *Sender, AnsiString Status);
void __fastcall Timer1Timer(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
bool RecordSeen;
extern PACKAGE TForm1 *Form1;

This is my code unit1.cpp

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)

void __fastcall TForm1::NMFTP1Connect(TObject *Sender)
RecordSeen = false;
Timer1->Enabled = true;

void __fastcall TForm1::NMFTP1ListItem(AnsiString Listing)
Memo1->Lines->Add ( Listing );
RecordSeen = true;
Application->ProcessMessages() ;

void __fastcall TForm1::Start1Click(TObject *Sender)
NMFTP1->Host = "";
NMFTP1->UserID = "0000";
NMFTP1->Password = "0000";


void __fastcall TForm1::NMFTP1Status(TComponent *Sender, AnsiString Status)
Memo2->Lines->Add ( Status );

void __fastcall TForm1::Timer1Timer(TObject *Sender)
Timer1->Enabled = false;
if ( ! RecordSeen )
Memo1->Lines->SaveToFile ( "ftplist.txt");
Memo1->Lines->Add ( "Done");
RecordSeen = false;

Timer1->Enabled = true;


Hope this helps!



Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close