asmodeus94

polskieZnaki

Apr 9th, 2012
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 2.95 KB | None | 0 0
  1.              {#################################################
  2.               # Aby usunac wszystkie polskie znaki z pliku,   #
  3.               # nalezy wkleic zawartosc pliku, do pliku       #
  4.               # napisy.txt, a nastepnie odpalic program       #
  5.               # polskieZnaki.exe                              #
  6.               # autor: asmodeus94                             #
  7.               #################################################}
  8. program polskieZnaki;
  9. uses crt,dos;
  10. var t,t2 : text;
  11. zs,podp,linia : string;
  12. pusty,byl,x,y,jestRozsz : byte;
  13. ile,aktIle : integer;
  14. const s = 'napisy.txt';rozsz='txt';
  15. procedure ogonki;
  16. begin
  17.  if linia[x] = 'ą' then linia[x]:='a';
  18.       if linia[x] = 'Ą' then linia[x]:='A';
  19.       if linia[x] = 'ę' then linia[x]:='e';
  20.       if linia[x] = 'Ę' then linia[x]:='E';
  21.       if linia[x] = 'ś' then linia[x]:='s';
  22.       if linia[x] = 'Ś' then linia[x]:='S';
  23.       if linia[x] = 'ć' then linia[x]:='c';
  24.       if linia[x] = 'Ć' then linia[x]:='C';
  25.       if (linia[x] = 'ż')OR(linia[x] = 'ź') then linia[x]:='z';
  26.       if (linia[x] = 'Ż')OR(linia[x] = 'Ź') then linia[x]:='Z';
  27.       if linia[x] = 'ń' then linia[x]:='n';
  28.       if linia[x] = 'Ń' then linia[x]:='N';
  29.       if linia[x] = 'ł' then linia[x]:='l';
  30.       if linia[x] = 'Ł' then linia[x]:='L';
  31.       if linia[x] = 'ó' then linia[x]:='o';
  32.       if linia[x] = 'Ó' then linia[x]:='O';
  33. end;
  34. begin clrscr;
  35. if fSearch(s,'') = '' then begin
  36. write('Plik ',s,' nie istnieje...');readkey;clrscr;
  37. assign(t,s);
  38. rewrite(t);
  39. close(t);
  40. writeln('Plik ',s,' zostal utworzony. Teraz mozesz wkleic tam napisy.');readkey;
  41. end;
  42. pusty:=1;
  43. assign(t,s);
  44. reset(t);
  45. ile:=0;
  46. REPEAT
  47. ile:=ile+1;
  48. readln(t,linia);
  49. if (linia<>'')AND(linia<>' ') then begin pusty:=0;end;
  50. UNTIL eof(t);
  51. close(t);
  52. if pusty=1 then begin clrscr;textbackground(7);textcolor(red);write('Plik napisy.txt jest pusty');readkey;exit;end;
  53. write('Jedna linijka nie moze zawierac wiecej niz 255 znakow!'); readkey;
  54. REPEAT clrscr;writeln('Nazwa pliku wyjsciowego (s - nazwa standardowa): ');REPEAT write('>');readln(zs);UNTIL (zs<>'')OR(zs='cls');UNTIL zs<>'cls';
  55. if zs = 's' then zs:='napisyP.txt';clrscr;
  56. jestRozsz:=0;x:=0;
  57. REPEAT
  58. x:=x+1;y:=0;
  59.       REPEAT
  60.             y:=y+1;
  61.             if zs[x+y-1]=rozsz[y] then jestRozsz:=1 ELSE begin jestRozsz:=0;break;end;
  62.       UNTIL y=3;
  63. UNTIL (x=length(zs))OR(jestRozsz=1);
  64. if jestRozsz=0 then zs:=zs+'.txt';
  65. x:=0;byl:=0;
  66. REPEAT
  67. x:=x+1;
  68. if zs[x]='\' then byl:=1;
  69. UNTIL (x=length(zs))OR(byl=1);
  70. if byl=0 then podp:='w aktualnym katalogu' ELSE podp:='w nastepujacej lokalizacji';
  71. assign(t,s);
  72. assign(t2,zs);
  73. reset(t);
  74. rewrite(t2);
  75. aktIle:=0;
  76. REPEAT
  77. aktIle:=aktIle+1;
  78. readln(t,linia);
  79.      for x:=1 to length(linia) do begin
  80.          ogonki;
  81.      end;
  82. if (aktIle<>ile)AND(aktIle<>1) then writeln(t2,''); write(t2,linia);
  83. UNTIL eof(t);
  84. close(t);
  85. close(t2);
  86. textbackground(white);textcolor(red);
  87. write('Zapisano ' ,podp,': ',zs);
  88. readkey;end.
Advertisement
Add Comment
Please, Sign In to add comment