FTP Delivery Client

Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2006
Posts: 1,091
Reputation: MattEvans is a jewel in the rough MattEvans is a jewel in the rough MattEvans is a jewel in the rough 
Solved Threads: 63
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Veteran Poster

FTP Delivery Client

 
0
  #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
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 1,091
Reputation: MattEvans is a jewel in the rough MattEvans is a jewel in the rough MattEvans is a jewel in the rough 
Solved Threads: 63
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Veteran Poster

Re: FTP Delivery Client

 
0
  #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]

Pascal and Delphi Syntax (Toggle Plain Text)
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3. ftpClient.Host := 'ftp.fusiongroupuk.com';
  4. ftpClient.Username := 'currentversion@fusiongroupuk.com';
  5. ftpClient.Password := 'password';
  6. try
  7. ftpClient.Connect(True);
  8. ftpClient.Get('ftpTest.html', 'c:\ftpTestResult.html');
  9. except
  10. on E : Exception do
  11. ShowMessage(E.ClassName+' error raised, with message : '+E.Message);
  12. end;
  13. end;
  14. procedure TForm1.ftpClientStatus(ASender: TObject;
  15. const AStatus: TIdStatus; const AStatusText: String);
  16. begin
  17. lstStatus.AddItem(AStatusText, nil);
  18. end;
  19. end.
Last edited by MattEvans; Jul 19th, 2006 at 2:33 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 1,091
Reputation: MattEvans is a jewel in the rough MattEvans is a jewel in the rough MattEvans is a jewel in the rough 
Solved Threads: 63
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Veteran Poster

Re: FTP Delivery Client

 
0
  #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:

Pascal and Delphi Syntax (Toggle Plain Text)
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3. fStream : TMemoryStream;
  4. fBuffer : PChar;
  5. sResult : String;
  6. begin
  7. ftpClient.Host := 'ftp.fusiongroupuk.com';
  8. ftpClient.Username := 'currentversion@fusiongroupuk.com';
  9. ftpClient.Password := 'password';
  10. try
  11. ftpClient.Connect(True);
  12. ftpClient.TransferType := ftBinary;
  13. fStream := TMemoryStream.Create();
  14. ftpClient.Get('ftpTest.txt', fStream);
  15. fStream.Read(fBuffer,fStream.Size);
  16. SetString(sResult,fBuffer, Length(fBuffer));
  17. lstStatus.AddItem(sResult, nil);
  18. except
  19. on E : Exception do
  20. ShowMessage(E.ClassName+' error raised, with message : '+E.Message);
  21. end;
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Pascal and Delphi Forum
Thread Tools Search this Thread



Tag cloud for Pascal and Delphi
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC