Search code examples
delphimigrationdelphi-7delphi-xe5

Incompatible Types error in Delphi


Iam migrating an app from Delphi 7 to Delphi XE5, the below is my function.

function InternalDecrypt(const S: AnsiString; Key: Word): AnsiString;
var
  I: Word;
  Seed: Word;
begin
  Result := S;
  Seed := Key;
  for I := 1 to Length(Result) do
  begin
    Result[I] := Char(Byte(Result[I]) xor (Seed shr 8)); //Error is here
    Seed := (Byte(S[I]) + Seed) * Word(C1) + Word(C2)
  end
end;

My Error is : incompatible types 'ansichar' and 'char' delphi, Can any one just guide me in the right way.


Solution

  • Try

    Result[I] := AnsiChar(Byte(Result[I]) xor (Seed shr 8));
    

    with c1 and c2 as ansichar type.