I don't understand cause of error

program Project2;
{$APPTYPE CONSOLE}
uses
  SysUtils;
  function Rus(mes: string):string;
var
i: integer; // number of processed character
begin
for i:=1 to length(mes) do case mes[i] of
'A'-'n'
mes[i]:= Chr(Ord(mes[i]) - 64); 'р'..'я'// after first mes occur the Error(27): Operator not applicable to this operand type
mes[i] .:= Chr (Ord(mes [i] ) -16);
end;
rus := mes; end;

Recommended Answers

All 2 Replies

You have some serious syntax errors going there. This is my best guess as to what you mean:

function Rus( mes: string ): string;
  var i: integer; // number of processed character
  begin
  for i := 1 to length( mes ) do 
    case mes[i] of
      'A'..'Z', 'a'..'n': mes[i] := Chr( Ord( mes[i] ) - 64 )
      else                mes[i] := Chr( Ord( mes[i] ) - 16 )
      end;
  rus := mes
  end;

Notice also that I separated the test case into a list of test cases for capital letters, lowercase letters, and if you want cyrillic letters, test them separately as well. Google ISO-8859-1 to see where they appear in the codeset.

Hope this helps.

Oh, I have understood.

case mes[i] of
      'а'..'п','А'..'П':  mes[i] := Chr( Ord( mes[i] ) - 64 );
      'р'..'я','Р'..'Я':  mes[i] := Chr( Ord( mes[i] ) - 16 );
     end;

Duoas, thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.