Solved

Getting single line of text from web.

Posted on 1998-08-29
3
138 Views
Last Modified: 2010-04-04
I want to add a simple version check to my app... What would be the easiest way to get the contents of a file (will contain the newest version number) off my web server? I could then compare the two numbers and tell if they had the most current version. Any help would be great.

Thanks
0
Comment
Question by:Kmiller
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 100 total points
ID: 1338091
I just created some code..you could try it an see if that's what you want...
---------------------------------
function CompareVersions(OldVer, NewVer : String):String;
var
  RealVer : String;
  Iold, IIold, Inew, IInew, nPosI, nPosII : Integer;
begin
  RealVer := '';
  nPosI := Pos('.', OldVer);
  nPosII := Pos('.', NewVer);
  if nPosI = nPosII then
  begin
    Iold := StrToInt(Copy(OldVer, nPosI - 1, 1));
    Inew := StrToInt(Copy(NewVer, nPosII - 1, 1));
    IIold := StrToInt(Copy(OldVer, nPosI + 1, Length(OldVer)));
    IInew := StrToInt(Copy(NewVer, nPosII + 1, Length(NewVer)));
    if Inew > Iold then
      RealVer := NewVer;
    if Iold > Inew then
      Realver := OldVer;
    if Inew = Iold then
    begin
      if IInew > IIold then
        RealVer := NewVer
      else
        RealVer := OldVer;
    end;
  end;
  Result := RealVer;
end;
//Example call
procedure TForm1.Button1Click(Sender: TObject);
begin
  Old.Text := 'V, 1.000';
  New.Text := 'V, 2.000';
  ShowMessage ( CompareVersions ( old.text, new.text ) ) ;
  //Old and New are TEdit components....
end;
--------------------
This can be used only if the version text looks something like this.....

V, 2.000    or  2.000  and you need to have a period  -> 3.003

Regards,
Viktor Ivanov
0
 

Author Comment

by:Kmiller
ID: 1338092
That seems to work for comparing the versions... but my main question was how to get the data from a file off my web server. It's this file that will contain the latest version infomation that will be used to compare agaist the version the user has. Sorry if my orginal question didn't make this clear.

Thanks
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1338093
How about this piece of code???
----------
var
  F : TextFile;
  str : string;
begin
  AssignFile(F, 'C:\windows\desktop\test.txt');
  Reset(F);
  ReadLn(F,str);
  CloseFile(F);
  ShowMessage(str);
end;
------------
Regards,
Viktor Ivanov
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi 10 Seattle Dataset Actions 5 79
Copy file in dll not working but working on exe ! 18 88
ddeman not working in activex 3 93
Delphi application Soap connection 5 96
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now