program text2dat; {Konvertiert Textfiles nach .dat-Files}
uses crt;         {macht kein Layout: d.h. Files mssen schon 53 Zeichen breit sein}
type tmem=array[0..1000] of string[60];

var f:file;
    addi:shortint;
    maxzeil,zahler,j,i:word;
    miss,asp,b:byte;
    textmem:^tmem;
    hilf:string[60];
    ding:string[1];
    datname,name:string;



begin
  new(textmem);
  for i:=0 to 1000 do
    for j:=1 to 60 do
      textmem^[i,j]:=#32;

  writeln('Artikelname:');
  readln(name);
  writeln('DAT-Filename:');
  readln(datname);

  assign(f,name);
  reset(f,1);

  maxzeil:=0;
  repeat         {text ab textmem zeile 1 einlesen}
    inc(maxzeil);
    j:=0;
    repeat
      inc(j);
      blockread(f,textmem^[maxzeil,j],1);
    until textmem^[maxzeil,j]=char(13);
    blockread(f,b,1);      {return lesen}
    textmem^[maxzeil,0]:=char(j+1);
  until eof(f);
  close(f);



  assign(f,datname+'.dat');   {text ab zeile 1 schreiben}
  rewrite(f,1);
  for i:=1 to maxzeil do begin
    blockwrite(f,textmem^[i,0],2);
    for j:=1 to byte(textmem^[i,0]) do
      textmem^[i,j]:=char(254-byte(textmem^[i,j]));
    blockwrite(f,textmem^[i,1],byte(textmem^[i,0]));
  end;
  close(f);



  readkey;
end.




