EDITOR2.PAS 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. Uses CRT;
  2. Var
  3. s1 : string;
  4. errorpos : array [1..255] of boolean;
  5. k,j : byte;
  6. NumOfWords, NumOfConv :byte;
  7. {-----------------------------------------------------}
  8. Function UpCas(s : char) : char;
  9. Begin
  10. if ord(s) in [128..175, 224..239] then
  11. begin
  12. if ord(s) in [160..175] then UpCas := Chr(ord(s) - 32);
  13. if ord(s) in [224..239] then UpCas := Chr(ord(s) - 80);
  14. end
  15. else UpCas := UpCase(s);
  16. end; {UpCas}
  17. {------------------------------------------------------------}
  18. Procedure Colored(pos : byte);
  19. Var i :byte;
  20. Begin
  21. Delay(2000);
  22. GotoXY(1,11);
  23. TextColor(LightGreen);
  24. for i := 1 to length(s1) do begin
  25. Write(s1[i]);
  26. if i = pos then TextColor(7);
  27. end;
  28. End; {Colored}
  29. {------------------------------------------------------------}
  30. Procedure Testing(s1 : string; Var s2:string);
  31. Begin
  32. s2 := s1;
  33. For k := 1 to length(s1) do
  34. if s1[1] = ' ' then begin
  35. delete(s2,1,1);
  36. errorspos[k] := true;
  37. end;
  38. S2[1] := UpCas(s2[1]);
  39. For j := 1 to 15 do
  40. For k := 1 to length(s2) do
  41. if (s2[k] = ' ') and ((s2[k+1] = ',') or (s2[k+1] = '.')
  42. or (s2[K+1] = '!') or (s2[k+1] = ' ')) then begin
  43. delete(s2,k,1);
  44. errorspos[k] := true;
  45. end;
  46. For k := 1 to length(s2) do
  47. if ((s2[k] = ',') or (s2[k] = '.') or (s2[k] = '!'))
  48. and (s2[k+1] <> ' ') then begin
  49. insert(' ',s2,k+1);
  50. errorpos[k] := true;
  51. errorpos[k+1] := true;
  52. end;
  53. For k := 1 to length(s2) do
  54. if s2[k] = '.' then s2[k+2] := upcas(s2[k+2]);
  55. For k := 1 to length(s2) do if s2[length(s2)] = ' '
  56. then delete(s2,length(s2),1);
  57. Insert('.',s2,length(s2)+1);
  58. End; {Testing}
  59. {-----------------------------------------------------------}
  60. Procedure LOG(s1:string);
  61. Begin
  62. For k := 1 to length(s1) do begin
  63. if s1[k] = '.' then inc(NumOfConv);
  64. if s1[k] = ' ' then inc(NumOfWords);
  65. End;
  66. Inc(NumOfWords);
  67. GotoXY(2,13);
  68. Write('Всего слов в тексте: ', NumOfWords);
  69. GotoXY(2,14);
  70. Write('Всего предложений в тексте: ', NumOfConv);
  71. End;{LOG}
  72. {---------------------------------------------------------}
  73. Begin
  74. ClrScr;
  75. GotoXY(10,10);
  76. Writeln('Введите строчку для редактирования: ');
  77. ReadLn(s1);
  78. Testing(s1);
  79. GotoXY(1,11);
  80. ClrEOL;
  81. Writeln(s1);
  82. Log(s1);
  83. GotoXY(80,25);
  84. ReadKey;
  85. End.