Program DecodeBudun;
var
fs, fd : file;
fst, fdt : Text;
BuffS : String;
Buff : array[0..255] of Byte absolute BuffS;
i, j : Word;
N : Word;
Prm : String;
begin
if ParamCount<=1 then
begin
WriteLn('Слишком мало параметров (Имя-файла [/DECODE] или [/ENCODE])');
Halt;
end;
Prm := ParamStr(2);
if (Prm<>'/DECODE') and (Prm<>'/ENCODE') then
begin
WriteLn('Неправильные параметры!');
Halt;
end;
if Prm='/DECODE' then
begin
Assign(fs, ParamStr(1));
Assign(fdt, 'layout.tmp');
Reset(fs, 1);
ReWrite(fdt);
N := FileSize(fs) div 256;
Seek(fs, 0);
for i := 1 to N do
begin
BlockRead(fs, Buff, 256);
for j := 1 to 255 do
if Buff[j]<>32 then Buff[j]:= Buff[j]-3;
Buff[0] := Pos(' ', Buffs);
WriteLn(fdt, BuffS);
end;
Close(fs);
Close(fdt);
end;
if Prm='/ENCODE' then
begin
Assign(fst, ParamStr(1));
Assign(fd, 'layout.tmp');
Reset(fst);
ReWrite(fd, 1);
While not EOF(fst) do
begin
FillChar(Buff, 256, 32);
ReadLn(fst, BuffS);
Buff[0]:=255;
for j := 1 to 255 do
if Buff[j]<>32 then Buff[j]:= Buff[j]+3;
BlockWrite(fd, Buff, 256);
end;
Close(fst);
Close(fd);
end;
end.