Solved

Getting single line of text from web.

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

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 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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

706 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

15 Experts available now in Live!

Get 1:1 Help Now