Note sparse

#

Listato 1

Il convertitore Turbo Pascal da Wordstar a Ventura
 
program conversione_wordstar_rs;

(*$F+*)

uses convutil;

procedure help;
begin
writeln('This program convert text files generated with Wordstar 3.40');
writeln('in "document-mode" into files for Xerox Ventura Publisher');
writeln('in "generated" format (with RS extensions).');
license('RS','.DOC','.TXT');
end;

procedure make_conversion;
const dot=46;  (* . symbol        *)
type codestr = string[5];
var firstchar : boolean;
    ch : byte;

  procedure wcode(x : codestr);
  var j : integer;
  begin
  out(pa);
  for j := 1 to length(x) do out(ord(x[j]));
  out(pc);
  end;

  procedure hicode(ch : byte);
  var x : codestr;
  begin
  str(ord(ch):3 , x);
  wcode(x);
  end;

begin
firstchar := true;

repeat       (* inizio conversione *)
  rd(ch);
  while (ch = dot) and firstchar do begin  (* se la linea contiene un  *)
    repeat rd(ch) until ch = 10;           (* comando punto la elimina *)
    rd(ch);
    end;
  firstchar := false;

  case ch of
    cr : begin              (* Il paragrafo in Ventura termina con *)
         out(ch);           (* una doppia coppia CR LF             *)
         out(10);
         out(ch);
         out(10);
         firstchar := true;
         rd(ch);
         end;

    141 : begin                        (* Il codice 141 � anche un CR con *)
         rd(ch);                       (* l'ottavo bit alzato ed in WS    *)
         if ch<>10 then hicode(141);   (* segnala la giustificazione; va  *)
         end;                          (* convertito solo se � una '�'    *)

    130,133,138,149,151 : hicode(ch);  (* vocali accentate *)

    32 : out(ch);  (* gli spazi inseriti per giustificare hanno l'ottavo  *)
    end;           (* bit alzato e non vanno considerati                  *)

  ch := ch and 127;                  (* abbassa l'ottavo bit e se stampabile *)
  if (ch > 32) then case ch of       (* lo scrive nel file di uscita         *)
    64 : begin
         wcode('M^');
         hicode(190);
         wcode('D');
         end;
    94 : hicode(191);
    else out(ch);
    end;

  until eof(infile);
end;

begin
intestazione('Wordstar to Ventura Publisher converter rel. 2.11');
loop(help,make_conversion,'.DOC','.TXT');
end.
Inizio pagina
 
Home page