By trial found an easy way to compare whether a file is a new version of the other
Here is code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
function TfrmETools.isNewVersion(local, web: string): Boolean; var l,atoms: TstringList; ver1, ver2: integer; nums1, nums2: string; b1,b2,b3,b4:boolean; procedure differ_this2(s, delim: string); var i: integer; sTmp: string; begin i := 1; atoms.Clear; sTmp := ''; while i <= length(s) do begin if (copy(s, i, 1) = delim) then begin atoms.Add(sTmp); sTmp := ''; end else sTmp := sTmp + copy(s, i, 1); inc(i); end; if sTmp <> '' then atoms.Add(sTmp); end; begin l := TstringList.Create; if not assigned(atoms) then atoms := TstringList.Create; differ_this2(local, '.'); l.Text := atoms.Text; differ_this2(web, '.'); result := false; b1:=false; b2:=false; b3:=false; b4:=false; if strToint(atoms[0])>strToint(l[0]) then b1:=true; if strToint(atoms[1])>strToint(l[1]) then b2:=true; if strToint(atoms[2])>strToint(l[2]) then b3:=true; if strToint(atoms[3])>strToint(l[3]) then b4:=true; if b1 then result:=true else if (not b1) and (b2) then result:=true else if (not b1)and(not b2)and(b3) then result:=true else if (not b1)and(not b2)and(not b3)and(b4) then result:=true; l.Free; end; |