home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / zip / portfoli / strip.lzh / strip.pas < prev   
Pascal/Delphi Source File  |  1991-08-21  |  1KB  |  61 lines

  1. program STRIP(input,output);
  2.  
  3. const
  4.   end_of_file = #26;
  5.   space = #32;
  6.   cr = #13;
  7.   lf = #10;
  8.   null = '';
  9.  
  10. var
  11.   ch : char;
  12.   line : string[255];
  13.   newfile,datafile : text;
  14.   infile,outfile : string[80];
  15.   period_pos : integer;
  16. begin
  17.   case paramcount of
  18.     2 : begin
  19.           infile := paramSTR(1);
  20.           outfile := paramSTR(2)
  21.         end;
  22.     1 : begin
  23.           infile := paramSTR(1);
  24.           period_pos := pos('.',infile);
  25.           outfile := copy(infile,1,period_pos) + 'txt'
  26.         end;
  27.     else begin
  28.            writeln('Syntax:  [d:][path]STRIP [d:][path]filename  [d:][path][filename]');
  29.            halt
  30.          end;
  31.   end; {case}
  32.   assign(datafile, infile);
  33.   assign(newfile, outfile);
  34. {$I-}
  35.   reset(datafile);
  36. {$I+}
  37.   if IOresult <> 0 then
  38.     begin
  39.       writeln(infile,' not found');
  40.       halt
  41.     end;
  42.   rewrite(newfile);
  43.   while not eof(datafile) do
  44.     begin
  45.       read(datafile,ch);
  46.       if ch = lf then
  47.         begin
  48.           read(datafile,ch);
  49.           while ch = space do
  50.             read(datafile,ch);
  51.           if ch = cr then
  52.             writeln(newfile,cr,lf);
  53.         end;
  54.       if ch <> cr then
  55.         write(newfile,ch);
  56.     end;
  57.   write(newfile,end_of_file);
  58.   close(datafile);
  59.   close(newfile);
  60. end.
  61. ə