Solved

Getting single line of text from web.

Posted on 1998-08-29
3
141 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 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb download file link ? 1 183
Delphi selector screen 2 97
DBGrid or StringGrid ? 6 135
Connect to SQL 2008 r2 server over the Internet 4 78
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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