@Hawkeye219: if UInt64(V1) <= UInt64(V2) then
PS: bei FNewVersion hätt ich gedacht, daß dieses True ist, wenn NewXYZ > XYZ wird und nicht bei <=
also insgesammt glaub ich, stümmt was bei der anfänglich genannten IF-Verschachtelung nicht
Delphi-Quellcode:
if NewMajor < Major then
begin
if (NewMajor = Major) and (NewMinor < Minor) then
begin
if (NewMinor = Minor) and (NewRelease < Release) then
begin
if (NewRelease = Release) and (NewBuild < Build) then
begin
FNewVersion := false;
end else
FNewVersion := true;
end else
FNewVersion := true;
end else
FNewVersion := true;
end else
FNewVersion := true;
oder seh ich das grad irgendwie falsch?
gekürzt:
Delphi-Quellcode:
isNewVersion := (NewMajor > Major) or
((NewMajor = Major) and ((NewMinor > Minor) or
((NewMinor = Minor) and ((NewRelease > Release) or
((NewRelease = Release) and (NewBuild > Build))))));
Selber nutze ich auch gern Records, welche sich dann auch mal ganz leicht nach LongWord, bzw. LargeInt/UInt64 casten lassen:
Delphi-Quellcode:
Type TSmallVersion = packed Record
Build: Word;
Minor, Major: Byte;
End;
TVersion = packed Record
Build, Release: Word;
Minor, Major: Word;
End;
Oder wie wäre es mal mit den neuen Funktionalitäten von Delphi?
und dann einfach nur noch
Delphi-Quellcode:
Var NewVersion, Version: TVersion;
...
If NewVersion <= Version Then ...
Delphi-Quellcode:
Type TSmallVersion = packed Record
Build: Word;
Minor, Major: Byte;
Class Operator Implicit(Rec: TSmallVersion): LongWord;
Class Operator Implicit(Value: LongWord): TSmallVersion;
Class Operator Implicit(Rec: TSmallVersion): String;
Class Operator Implicit(Value: String): TSmallVersion;
Class Operator Explicit(Rec: TSmallVersion): LongWord;
Class Operator Explicit(Value: LongWord): TSmallVersion;
Class Operator Explicit(Rec: TSmallVersion): String;
Class Operator Explicit(Value: String): TSmallVersion;
Class Operator Equal (Oper1, Oper2: TSmallVersion): Boolean;
Class Operator NotEqual (Oper1, Oper2: TSmallVersion): Boolean;
Class Operator LessThan (Oper1, Oper2: TSmallVersion): Boolean;
Class Operator LessThanOrEqual (Oper1, Oper2: TSmallVersion): Boolean;
Class Operator GreaterThan (Oper1, Oper2: TSmallVersion): Boolean;
Class Operator GreaterThanOrEqual(Oper1, Oper2: TSmallVersion): Boolean;
Class Operator Add (Oper1, Oper2: TSmallVersion): TSmallVersion;
Class Operator Subtract (Oper1, Oper2: TSmallVersion): TSmallVersion;
Class Operator BitwiseAnd(Oper1, Oper2: TSmallVersion): TSmallVersion;
Class Operator BitwiseOr (Oper1, Oper2: TSmallVersion): TSmallVersion;
End;
TVersion = packed Record
Build, Release: Word;
Minor, Major: Word;
Class Operator Implicit(Rec: TSmallVersion): UInt64;
Class Operator Implicit(Value: LongWord): TSmallVersion;
Class Operator Implicit(Rec: TSmallVersion): String;
Class Operator Implicit(Value: String): TSmallVersion;
Class Operator Explicit(Rec: TSmallVersion): UInt64;
Class Operator Explicit(Value: UInt64): TSmallVersion;
Class Operator Explicit(Rec: TSmallVersion): String;
Class Operator Explicit(Value: String): TSmallVersion;
Class Operator Equal (Oper1, Oper2: TSmallVersion): Boolean;
Class Operator NotEqual (Oper1, Oper2: TSmallVersion): Boolean;
Class Operator LessThan (Oper1, Oper2: TSmallVersion): Boolean;
Class Operator LessThanOrEqual (Oper1, Oper2: TSmallVersion): Boolean;
Class Operator GreaterThan (Oper1, Oper2: TSmallVersion): Boolean;
Class Operator GreaterThanOrEqual(Oper1, Oper2: TSmallVersion): Boolean;
Class Operator Add (Oper1, Oper2: TSmallVersion): TSmallVersion;
Class Operator Subtract (Oper1, Oper2: TSmallVersion): TSmallVersion;
Class Operator BitwiseAnd(Oper1, Oper2: TSmallVersion): TSmallVersion;
Class Operator BitwiseOr (Oper1, Oper2: TSmallVersion): TSmallVersion;
End;
// die Definitionen der Funktionen hab ich mir erstmal gesparrt