User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 423,002 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,857 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser: Programming Forums
Views: 2907 | Replies: 2
Reply
Join Date: Jul 2006
Location: Deptford, London
Posts: 954
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 48
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

FTP Delivery Client

  #1  
Jul 19th, 2006
Hi there. I'm new to this forum, and new to Delphi, my programming experience goes from BASIC > Visual Basic, C++ (DirectX not MFC or GDI), and Java/Java3D. I did a little Pascal programming in college a few years ago, but what I remember isn't sufficient to help me much with Delphi.

I'm looking for some good learning resources, specifically some that can help me get my client-side distribution app working. The app is going to be used to search for, and if neccessary install updates to my Java program, which will be stored on a server with datestamped files for each class/resource file.

If things go well with this little utility, I'll integrate features to allow users to write command/JIT scripts for the program, and test their JIT scripts in a console environment.

Basically, this program will be the "face" of my Java application.

I've been playing around with Delphi and find it most comparable to Visual Basic, which I do have alot of experience in.

To get things started I want the program to load an HTML file, but not display it. I tried out the browser control, but I don't really want to open the page for display then get a hold of the information, I want to directly download the HTML page into a data object and then run through the raw HTML (infact it will probably be XML), to see if the relevant file has changed or been moved. This should be entirely invisible as far as the user is concerned.

What would be the best way to go about doing this? Are there inbuilt Delphi units or controls that support this functionality? I use Windows but I'm using Delphi 7, and want my app to be cross-platform so I can't use the Windows APIs to any extent.

I suppose the most suitable thing would be an FTP control or library; as I want to download binary files aswell and put them onto the user's filesystem..

I really don't want to dump a thirdparty control on the form and be done with it, because that limits my learning from this, and I want to make sure the Windows API is entirely avoided.

A link to a useful site would be appreciated, a brief overview of how to get a string from a page on my server to a delphi form on my computer would be wonderful :mrgreen:

Thanks in advance,

Matt
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 954
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 48
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: FTP Delivery Client

  #2  
Jul 19th, 2006
OK, I found the IndyFTP control, and things are coming along OK, only problem atm is at my FTP server end not letting me have acceptable access anonymously :eek:

I'll post updates on my learning progress, I'm finding Delphi VERY similar to VB.

[edit]I'm amazed it was so simple, if anyone ever needs to do this, put an IndyFTPClient called ftpClient, a button and a listbox called lstStatus onto a Delphi form, and add this code to the Form unit:[/edit]

procedure TForm1.Button1Click(Sender: TObject);
begin
ftpClient.Host := 'ftp.fusiongroupuk.com';
ftpClient.Username := 'currentversion@fusiongroupuk.com';
ftpClient.Password := 'password';
try
  ftpClient.Connect(True);
  ftpClient.Get('ftpTest.html', 'c:\ftpTestResult.html');
except
    on E : Exception do
      ShowMessage(E.ClassName+' error raised, with message : '+E.Message);
end;
end;
procedure TForm1.ftpClientStatus(ASender: TObject;
  const AStatus: TIdStatus; const AStatusText: String);
begin
  lstStatus.AddItem(AStatusText, nil);
end;
end.
 
Last edited by MattEvans : Jul 19th, 2006 at 1:33 pm.
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 954
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 48
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: FTP Delivery Client

  #3  
Jul 19th, 2006
I'm having another problem now.

Is there a way to get the data in a TMemoryStream object into a String; it seems to support multiple object types for the buffer parameter, but not String. When I use the code below, the output is not the string in the file, it's the right length, but the values are wrong... I've tried ANSI, unicode and UTF-8 encoding, i've tried with html and txt data files, i've tried PChar, Byte arrays and char arrays as buffers, and everytime I get a slightly different string of non-standard characters... If I use String as the buffer directly, it creates an empty string

At present I'm using:

procedure TForm1.Button1Click(Sender: TObject);
var
  fStream : TMemoryStream;
  fBuffer : PChar;
  sResult : String;
begin
ftpClient.Host := 'ftp.fusiongroupuk.com';
ftpClient.Username := 'currentversion@fusiongroupuk.com';
ftpClient.Password := 'password';
try
  ftpClient.Connect(True);
  ftpClient.TransferType := ftBinary;
  fStream := TMemoryStream.Create();
  ftpClient.Get('ftpTest.txt', fStream);
  fStream.Read(fBuffer,fStream.Size);
  SetString(sResult,fBuffer, Length(fBuffer));
  lstStatus.AddItem(sResult, nil);
except
    on E : Exception do
      ShowMessage(E.ClassName+' error raised, with message : '+E.Message);
end;
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Pascal and Delphi Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Pascal and Delphi Forum

All times are GMT -4. The time now is 3:49 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC