944,193 Members | Top Members by Rank

Ad:
Jul 19th, 2006
0

FTP Delivery Client

Expand Post »
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
Similar Threads
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
Jul 19th, 2006
0

Re: FTP Delivery Client

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.
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
Jul 19th, 2006
0

Re: FTP Delivery Client

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;
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Pascal and Delphi Forum Timeline: Need a help!!
Next Thread in Pascal and Delphi Forum Timeline: Delphi 7 tools for computer music??





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC