program prace_s_textem; uses crt; const soubor = 'text.dta'; var F : text; podminka : char; text : string; procedure Novy; begin assign(F,soubor); rewrite(F); Close(F); end; procedure Pridani; begin textcolor(white); clrscr; assign(F,soubor); append(F); writeln('Vloz text, ktery chces ulozit na konec souboru : '); readln(text); writeln(F,text); close(F); end; procedure Statistika(ret: string); var l, pocet_samohlasek: integer; samA, samE, samI, samO, samU, samY : integer; samohlasky: set of char; begin samohlasky := ['A','E','I','O','U','Y','a','e','i','o','u','y']; pocet_samohlasek := 0; samA := 0; samE := 0; samI := 0; samO := 0; samU := 0; samY := 0; for l := 1 to length(ret) do begin if (ret[l] in samohlasky) then pocet_samohlasek := pocet_samohlasek + 1; case ret[l] of 'A','a': inc(samA); 'E','e': inc(samE); 'I','i': inc(samI); 'O','o': inc(samO); 'U','u': inc(samU); 'Y','y': inc(samY); end; end; writeln('Pocet samohlasek : celkem - ',pocet_samohlasek); writeln('A, a - ',samA,', E, e - ',samE,', I, i - ',samI,', O, o - ',samO,', U, u - ',samU,', Y, y - ',samY); end; procedure ZobrazeniStat; begin textcolor(yellow); clrscr; writeln('Obsah souboru :'); writeln; assign(F,soubor); reset(F); while not(eof(F)) do begin readln(F,text); textcolor(yellow); write(text,' '); textcolor(white); Statistika(text); end; textcolor(yellow); writeln; writeln('Stiskni ENTER ...'); readln; close(F); end; procedure Zobrazeni; begin textcolor(yellow); clrscr; writeln('Obsah souboru :'); writeln; assign(F,soubor); reset(F); while not(eof(F)) do begin readln(F,text); writeln(text,' '); end; writeln; writeln('Stiskni ENTER ...'); readln; close(F); end; BEGIN repeat textbackground(0); clrscr; textcolor(lightred); gotoxy(16,6); writeln('Program na demonstraci praci s textovym souborem'); gotoxy(28,8); writeln('David Padrta - IVT 3'); textcolor(white); gotoxy(4,12); writeln('Vytvoreni noveho souboru : '); gotoxy(4,13); writeln('Pridani textove polozky : '); gotoxy(4,14); writeln('Zobrazeni obsahu souboru bez statistiky samohlasek : '); gotoxy(4,15); writeln('Zobrazeni obsahu souboru se statistikou samohlasek : '); textcolor(lightred); gotoxy(4,16); writeln('ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ'); textcolor(white); gotoxy(4,18); writeln('Ukonceni programu : '); textcolor(lightgreen); gotoxy(59,12); writeln('zmackni N nebo n'); gotoxy(59,13); writeln('zmackni P nebo p'); gotoxy(59,14); writeln('zmackni O nebo o'); gotoxy(59,15); writeln('zmackni S nebo s'); gotoxy(59,18); writeln('zmackni K nebo k'); podminka := readkey; case podminka of 'N','n': Novy; 'P','p': Pridani; 'O','o': Zobrazeni; 'S','s': ZobrazeniStat; end; until ((podminka = 'K') or (podminka = 'k')); clrscr; END.