home *** CD-ROM | disk | FTP | other *** search
/ The Party 1994: Try This At Home / disk_image.bin / source / astrasrc / postproc.pas < prev   
Pascal/Delphi Source File  |  1994-08-13  |  876b  |  39 lines

  1.  
  2.   (* special post processing utility for COM-files, cuts the unused
  3.      zeros from the end, JHH/93 *)
  4.  
  5.   type
  6.     a = array [1..65535] of byte;
  7.   var
  8.     f : file;
  9.     b : ^a;
  10.     l : word;
  11.     s : word;
  12.  
  13.   procedure xHalt (msg: string);
  14.   begin
  15.     write (msg);
  16.     halt;
  17.   end;
  18.  
  19.   begin
  20.     if ParamCount <> 1 then xHalt ('usage: POSTPROC <com-file>');
  21.     if MaxAvail < 65535 then xHalt ('out of memory!');
  22.     GetMem (b, 65535);
  23.     assign (f, ParamStr (1));
  24.     {$I-}
  25.     reset (f, 1);
  26.     if ioResult <> 0 then xHalt ('usage: POSTPROC <com-file>');
  27.     write ('reading..');
  28.     blockread (f, b^, 65535, l);
  29.     close (f);
  30.     write (' processing..');
  31.     s := l;
  32.     while b^[s] = 00 do  dec (s);
  33.     rewrite (f, 1);
  34.     write (' writing..');
  35.     blockwrite (f, b^, s);
  36.     close (f);
  37.     write (' total: ', s, ' bytes.');
  38.   end.
  39.