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

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.

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 := [EMAIL="'currentversion@fusiongroupuk.com'"]'currentversion@fusiongroupuk.com'[/EMAIL];
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;
This article has been dead for over six months. Start a new discussion instead.