procedure error(msg : string);
begin
  writeln('Error: ', msg);
  halt;
end;

function qs1(c : char) : char;
begin
  if c>=#32 then qs1:=chr(287-ord(c))
    else qs1:=c;
end;

var
  f,f2 : text;
  name : string;
  c : char;
begin
  name:=paramStr(1);
  if name='' then error('converter QS1 to QST'#13#10'usage:  file.qs1');
  assign(f,name);
  {$I-}reset(f);{$I+}
  if IOresult<>0 then error('file <'+name+'> not found');
  {=============}
  name:=copy(name,1,length(name)-pos('.',name)-1)+'.qst';
  assign(f2,name);
  {$I-}rewrite(f2);{$I+}
  if IOresult<>0 then error('file can''t create <'+name+'>');
  {=============}
  while not eof(f) do
  begin
    read(f,c);
    write(f2, qs1(c));
  end;
  close(f2);
  close(f);
end.
