home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 18 / CD_ASCQ_18_111294_W.iso / dos / prg / pas / gfxfx / conv.pas < prev    next >
Pascal/Delphi Source File  |  1994-04-20  |  890b  |  40 lines

  1.  
  2. program FileConverter;
  3. { Convert binairy file to textfile, by Bas van Gaalen, Holland, PD }
  4. uses dos;
  5. const BufSize = 1024;
  6. var
  7.   InFile : file;
  8.   OutFile : text;
  9.   Buffer : array[0..BufSize-1] of byte;
  10.   FileName : pathstr;
  11.   I,NofRead : integer;
  12.  
  13. begin
  14.   writeln;
  15.   FileName := paramstr(1); if FileName = '' then begin
  16.     writeln('Enter filename on commandline...');
  17.     halt(1);
  18.   end;
  19.   assign(InFile,FileName);
  20.   {$I-} reset(InFile,1); {$I+}
  21.   if ioresult <> 0 then begin
  22.     writeln('Error opening file ',FileName);
  23.     halt(1);
  24.   end;
  25.  
  26.   assign(OutFile,'OUTFILE1.DAT');
  27.   rewrite(OutFile);
  28.  
  29.   repeat
  30.     blockread(InFile,Buffer,BufSize,NofRead);
  31.     for I := 0 to NofRead-1 do begin
  32.       if I mod 16 = 15 then writeln(OutFile);
  33.       write(OutFile,Buffer[I],',');
  34.     end;
  35.   until NofRead < BufSize;
  36.  
  37.   close(InFile);
  38.   close(OutFile);
  39. end.
  40.