0

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;
2
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by Annex
0

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.

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.