{ labai ma‘ai tarp—, ta‡iau labai daug bazini— (turbo) paskalio ‘od‘i—,
 kintam—j— vardai labai panaž–s i bazinius tipus}
uses crt;
label skiploop,skipper;
var f1,f2:string;
chars :array[1..64000] of char;
file1,file2:file;
byt:byte;
br,reps,character:integer;
ed,chara,a : char;

procedure decode;
begin
Write('Source:');
Readln(f1);
Write('Destination:');
Readln(f2);
assign(file1,f1);
reset(file1,1);
assign(file2,f2);
rewrite(file2,1);
for reps := 1 to filesize(file1) do begin
blockread(file1,chara,1);
character := ord(chara)-128;
if character < 0 then character := character + 255;
chara := chr(character);
clrscr;
Write(round(reps/filesize(file1)*100));
blockwrite(file2,chara,1);
end;
end;

procedure dispfile;
var lines,subl:integer;
begin
Write('File:');
Readln(f1);
assign(file1,f1);
reset(file1,1);
subl:=0;
lines:=0;
for reps := 1 to filesize(file1) do begin
subl:=subl+1;
if subl = 80 then begin
 lines := lines + 1;
 subl := 0;
end;
if lines >= 25 then begin
 a:=readkey;
 clrscr;
 lines:=0;
 subl:=0;
end;
blockread(file1,chara,1);
if ord(chara) = 13 then begin
 lines:=lines+1;
 subl:=0;
end;
Write(chara);
end;
a:=readkey;
end;

procedure encode;
begin
Write('Source:');
Readln(f1);
Write('Destination:');
Readln(f2);
assign(file1,f1);
reset(file1,1);
assign(file2,f2);
rewrite(file2,1);
for reps := 1 to filesize(file1) do begin
blockread(file1,chara,1);
character := ord(chara)+128;
if character >= 255 then character := character - 255;
chara:= chr(character);
clrscr;
Write(round(reps/filesize(file1)*100));
blockwrite(file2,chara,1);
end;
end;

begin
skipper:
clrscr;
Writeln;
Writeln;
Writeln('                                Main Menu');
Writeln;
Writeln('                            (1)Encode');
Writeln('                            (2)Decode');
Writeln('                            (3)Display File');
Writeln('                            (4)Exit');
Writeln;
Writeln;
write('>');
a:=readkey;
writeln(a);
if a = '1' then encode;
if a = '2' then decode;
if a = '3' then dispfile;
if a = '4' then goto skiploop;
goto skipper;
skiploop:
end.