#7 Comparison btw. objects causes error

open
nobody
5
2003-03-16
2003-03-16
ALu
No

type TA = class
end;

var A : TA = TA.Create;
var B : TA = A;

if A = B then // <--- fails [X]
println('EQUAL');

[X] fails with Runtime Error: Invalid Variant Operation

Discussion

  • ALu
    ALu
    2003-03-16

    Logged In: YES
    user_id=382292

    The problem is, that two Interface-Variants (varUnknown) are
    compared for testing "A=B". Delphi normally cannot handle
    this. In Delphi 6 you can replace the default VariantManager
    by your own one that handles this case (replace VarCmp).

    As solution for DWS: replace the standard TRelOpExpr for
    comparison by another one that executes the compare for
    objects (IScriptObj).

     
  • ALu
    ALu
    2003-03-16

    • assigned_to: aluleich --> nobody