home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug043.arc / RTW.PAS < prev    next >
Pascal/Delphi Source File  |  1979-12-31  |  3KB  |  93 lines

  1. {Program to recover crashed Wordstar/Turbo files}
  2. {CRS 25-9-85}
  3.  
  4. const
  5.  
  6. {Wordstar Constants}
  7.   wc_file = $846d;   {Address of base of crashed file}
  8.   wo_fname = $34b9;  {String containing the old filename}
  9.  
  10. {Turbo Constants}
  11.   tc_file = $8118;   {Address of base of crashed file}
  12.   to_fname = $4500;  {String containing the old filename}
  13.  
  14. var
  15.   x,r_type : char;
  16.   wend_mkr : integer absolute $37bc; {Worstar end of file address}
  17.   tend_mkr : integer absolute $4528; {Turbo end of file address}
  18.   i,j,end_mkr,c_file,o_fname : integer;
  19.   o_file : text;
  20.   fname : string[16];
  21.  
  22.  
  23. procedure getfn(num,base : integer);
  24.  
  25. var
  26.   i : integer;
  27.  
  28. begin
  29.   i := 0;
  30.   while (i <= num) and (mem[to_fname+i+base] <> $20) do begin
  31.     fname := fname + chr(mem[to_fname+i+base]);
  32.     i := i + 1;
  33.   end;
  34. end;
  35.  
  36.  
  37. begin
  38.   writeln('Program to Recover Crashed Wordstar/Turbo Files');
  39.   writeln('CRS 25-September-85');
  40.   writeln;
  41.   write('Turbo or Wordstar file to restore (T or W) ?');
  42.   repeat read(kbd,r_type) until (upcase(r_type) = 'T') or (upcase(r_type) = 'W');
  43.   r_type := upcase(r_type);
  44.   writeln(r_type);
  45.   writeln;
  46.   if r_type = 'T' then begin
  47.     end_mkr := tend_mkr-1;
  48.     c_file := tc_file;
  49.     fname := '';
  50.     getfn(8,0);
  51.     fname := fname + '.';
  52.     getfn(3,8);
  53.   end else begin
  54.     end_mkr := wend_mkr;
  55.     c_file := wc_file;
  56.     i := 0;
  57.     fname := '';
  58.     while (mem[wo_fname+i] <> 0) do begin
  59.       fname := fname + chr(mem[wo_fname+i]);
  60.       i := i + 1;
  61.     end;
  62.   end;
  63.  
  64.  
  65.  
  66.   if end_mkr = c_file then begin
  67.     writeln('The file you are attempting to restore is either of zero');
  68.     writeln('length or is an unchanged image of an existing file.');
  69.   end else begin
  70.     writeln('Calculated length of restorable image is ',end_mkr-c_file,' bytes');
  71.     writeln;
  72.  
  73.     writeln('Old name of file is ',fname);
  74.     write('Use this name (Y or N)? ');
  75.     repeat
  76.       read(kbd,x);
  77.     until (upcase(x) = 'Y') or (upcase(x) = 'N');
  78.     x := upcase(x);
  79.     writeln(x);
  80.     writeln;
  81.     if upcase(x) = 'N' then begin
  82.       write('Enter new name ? ');
  83.       readln(fname);
  84.     end;
  85.  
  86.     assign(o_file,fname);
  87.     rewrite(o_file);
  88.     for i := c_file to end_mkr-1 do write(o_file,chr(mem[i]));
  89.     close(o_file);
  90.     writeln('File closed.');
  91.   end;
  92. end.
  93.  ä M0$ <> "L" ë 890f ä A1 = 0 ë ü A1 = 360p ü A1 = A1 - A2z ä M0$ = "R" ë ü A1 = A1 + A2ä