Hello,
I am using Lazarus 2.0.1 on Raspberry Pi directly. Application is for a vending machine and LCD display cannot handle national letters. I wanted to convert them to ASCII letters as below:
function TfrmVendingMain.GetLatinLetters(const Value: AnsiString): string;
var
I: Integer;
begin
SetLength(Result, Value.Length);
for I := 1 to Result.Length do
begin
case Value[I] of
'Ü', 'ü': Result[I] := 'U'; // below error is for that line
'Ğ', 'ğ': Result[I] := 'G';
'İ', 'ı': Result[I] := 'I';
'Ş', 'ş': Result[I] := 'S';
'Ç', 'ç': Result[I] := 'C';
'Ö', 'ö': Result[I] := 'O';
else Result[I] := UpperCase(Value[I]);
end;
end;
end;
Compiler says:
uvendingmain.pas(453,11) Error: Constant and CASE types do not match
uvendingmain.pas(453,11) Error: Ordinal expression expected
On the other hand, using something like below works:
Result := StringReplace(Value, 'Ü', 'U', [rfReplaceAll]);
Result := StringReplace(Result, 'Ğ', 'G', [rfReplaceAll]);
Result := StringReplace(Result, 'İ', 'I', [rfReplaceAll]);
Result := StringReplace(Result, 'Ş', 'S', [rfReplaceAll]);
Result := StringReplace(Result, 'Ö', 'O', [rfReplaceAll]);
Result := StringReplace(Result, 'Ç', 'C', [rfReplaceAll]);
Result := StringReplace(Result, 'ü', 'u', [rfReplaceAll]);
Result := StringReplace(Result, 'ğ', 'g', [rfReplaceAll]);
Result := StringReplace(Result, 'ı', 'i', [rfReplaceAll]);
Result := StringReplace(Result, 'ş', 's', [rfReplaceAll]);
Result := StringReplace(Result, 'ö', 'o', [rfReplaceAll]);
Result := StringReplace(Result, 'ç', 'c', [rfReplaceAll]);
I am not willing to use that later code example. Is there a way I can use my initial implementation?
Thanks & regards,
Ertan