Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Getting single line of text from web.

Posted on 1998-08-29
3
Medium Priority
?
146 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

609 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