?
Solved

Getting single line of text from web.

Posted on 1998-08-29
3
Medium Priority
?
145 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 400 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month9 days, 5 hours left to enroll

764 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