The developed text editor which enables printing of text on the printer

Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
Category: KMP (Club of young programmers)

Author: Gabriel Staroň
Program: Tlaciare.pas
File exe: Tlaciare.exe

The developed text editor which enables printing of text on the printer.
{ TLACIARE.PAS                                                      }
{                                                                   }
{ Author: Gabriel Staron                                            }
{ Date  : 15.02.1997                           http://www.trsek.com }
 
PROGRAM _g_ext602;
uses crt,dos;
var f,t,l,d  : text;
    su,st,sd : string;
    ch,a     : char;
    nd,maz   : boolean;
    x,y,i    : integer;
 
procedure obrazovka;
var i:integer;
begin
 clrscr;
 for i:=2 to 79 do begin
     gotoxy(i,1);write('Í');
     gotoxy(i,24);write('Í');
    end;
 for i:=2 to 23 do begin
     gotoxy(1,i);write('ş');
     gotoxy(80,i);write('ş');
    end;
 gotoxy( 1, 1);write('É');
 gotoxy(80, 1);write('ť');
 gotoxy( 1,24);write('Č');
 gotoxy(80,24);write('ź');
 gotoxy(1,25);
 write('F1-pomoc F2-prepis F3-tlac text F4-tlac subor F5-otvorit F6-dopisat ESC-koniec');
end;
 
begin
 obrazovka;
 x:=3;y:=2;
 nd:=false;
 
 repeat
   gotoxy(x,y);
   ch:=readkey;
   if not(ch=#0) then begin
      write(ch);
      x:=x+1;
      if x>79 then y:=y+1;
      gotoxy(x,y);
     end;
 
   if (ch=#0) then begin
      maz:=true;
      ch:=readkey;
      gotoxy(2,y);write('Ż');
      if (ch='H') then begin y:=y-1;maz:=false;end;            { hore }
      if (ch='P') then begin y:=y+1;maz:=false;end;            { dole }
      if (ch='K') then begin x:=x-1;maz:=false;end;            { vlavo }
      if (ch='M') then begin x:=x+1;maz:=false;end;            { vpravo }
      if (y< 2) then y:=2;
      if (y>23) then y:=23;
      gotoxy(2,y);write('Ż');
 
      { F2 }    if (ch='<') then begin
                      obrazovka;
                      gotoxy(1,25);
                      write('Napis text, ktory chces zapisat do suboru(text.txt):');
                      gotoxy(3,2);readln(su);
                      gotoxy(3,3);writeln('Naozaj to chces zapisat? a/n');
                      readln(a);
                      if (a='a') then begin
                          assign(t,'subor.txt');
                          rewrite(t);
                          writeln(t,su);
                          close(t);
                         end;
                     end;
 
        { F3 }    if (ch='=') then begin
                      gotoxy(3,2);writeln('Napis, co mas na srdci tlacit:');
		      gotoxy(3,3);readln(st);
                      gotoxy(3,4);writeln('Naozaj to chces tlacit? a/n');
                      readln(a);
                      if (a='a') then begin
                          assign(f,'lpt1');
                          rewrite(f);
                          writeln(f,st);
                          close(f);
                         end;
                     end;
 
        { F4 }    if (ch='>') then begin
                      writeln('Naozaj tento subor vytlacit? a/n');
		      readln(a);
		      if (a='a') then begin
                          assign(f,'lpt1');
                          rewrite(f);
                          Assign(t,'subor.txt');
                          ReSet(t);
                          repeat
                           Readln(t,su);
                           Writeln(f,su);
                          until (Eof(t));
                          close(f);
                          close(t);
                         end;
                      end;
 
        { F5 }    if (ch='?') then begin
                      assign(l,'subor.txt');
                      reset(l);
                      readln(l,st);
                      close(l);
                      gotoxy(3,2);writeln('Tu je text:',st);
                      reset(l);
                      gotoxy(3,3);writeln('Naozaj to chces vidiet? a/n');
                      readln(a);
                      if (a='a') then begin
                         obrazovka;
                         i:=1;
                         Repeat
                          readln(l,st);
                          inc(i);
                          gotoxy(3,i);writeln(st);
                         until (eof(l) or (i>22));
                         close(l);
                        end;
                        maz:=false;
                      end;
 
        { F6 }    if (ch='@') then begin
                      obrazovka;
                      gotoxy(3,2);
                      writeln('Tu napis text na dopisanie suboru:');
                      assign(d,'subor.txt');
                      gotoxy(3,3);readln(sd);
                      gotoxy(3,4);writeln('Naozaj to chces zapisat? a/n');
                      readln(a);
                      if (a='a') then begin
                          append(d);
                          writeln(d,sd);
                          close(d);
                         end;
                      end;
        { F7 }    if (ch='A') then nd:=true;
        if maz then obrazovka;
       end;
 until ((ch=#27) or nd);
end.