Показать сообщение отдельно
  #4  
Старый 18.06.2010, 09:08
Rjkzy Rjkzy вне форума
Прохожий
 
Регистрация: 15.06.2010
Адрес: дома
Сообщения: 34
Репутация: 10
По умолчанию

конечно можно оптимизировать, но нужно ли?
Код:
procedure TForm1.Button1Click(Sender: TObject);
var
CurPos, LastPos:Cardinal;
Findstr, VrStr:String;
begin
CurPos:=0;
LastPos:=0;
VrStr:=Memo1.Text;
repeat
  Findstr:=RightStr(VrStr,length(VrStr)-LastPos+1);
  CurPos:=pos('.',Findstr);
  LastPos:=LastPos+CurPos;
  if Findstr[CurPos+1]<>' ' then
    begin
    if LastPos=CurPos then
      begin
      Insert(' ',VrStr,LastPos+1);
      end
    else
      Insert(' ',VrStr,LastPos);
    end;

   if LastPos=CurPos then
      begin
      if (ord(VrStr[LastPos+2]) in [224..255]) or (ord(VrStr[LastPos+2]) in [97..122]) then
        begin
        VrStr[LastPos+2]:=chr(Ord(VrStr[LastPos+2])-32);
        end;
      if (ord(VrStr[LastPos+2])=184) then VrStr[LastPos+2]:=chr(Ord(VrStr[LastPos+2])-16);
      end
    else
      begin
      if (ord(VrStr[LastPos+1]) in [224..255]) or (ord(VrStr[LastPos+1]) in [97..122]) then
        begin
        VrStr[LastPos+1]:=chr(Ord(VrStr[LastPos+1])-32);
        end;
      if (ord(VrStr[LastPos+1])=184) then VrStr[LastPos+1]:=chr(Ord(VrStr[LastPos+1])-16);
    end;
until CurPos=0;
Memo1.Text:=VrStr;

end; 
Ответить с цитированием