home *** CD-ROM | disk | FTP | other *** search
/ RBBS in a Box Volume 1 #2 / RBBS_vol1_no2.iso / 050z / spacedel.pas < prev    next >
Pascal/Delphi Source File  |  1985-04-06  |  3KB  |  117 lines

  1. Program SPACDELonversion;
  2. {
  3.      Purpose    to DELete unwanted leading spaces from a text
  4.                 file.
  5.  
  6.      Started    April 6, 1985
  7.  
  8.      Last
  9.      Update     April 6, 1985
  10.  
  11. }
  12. const
  13.     OutFileName  = 'temp.dat';
  14. Var
  15.     InFile,
  16.     OutFile      :      Text;
  17.     Line,
  18.     Answer,
  19.     MinusLine    :      string[200];
  20.     NumNet       :      Real;
  21.     I,M,N,P,
  22.     datesl,
  23.     NumLines,
  24.     MaxDelete,
  25.     scrnclr      :      Integer;
  26.     StillSpace,
  27.     FileFound    :      Boolean;
  28.     MyFileIn,
  29.     MyFileOut,
  30.     Atest,t      :      String[20];
  31.  
  32. Procedure OpenInFile;    {Procedure to check for Input File}
  33. Begin
  34.   Repeat
  35.     Gotoxy(8,6);Write('Enter the name of the file to list: ');
  36.     ReadLn(MyFileIn);
  37.     Gotoxy(8,7);ClrEol;
  38.     Assign(Infile,MyFileIn);
  39.     {$I-} Reset(InFile) {$I+} ;
  40.     FileFound := (IOresult = 0);
  41.     If not FileFound then
  42.       begin
  43.         Gotoxy(8,7);sound(440);Delay(500);Nosound;
  44.         Write('CANNOT FIND FILE ',MyFileIn);
  45.       end;
  46.     Until FileFound;
  47.  End;
  48. Procedure CheckOutFile;    {Procedure to check for OutputFile}
  49. Begin
  50.   Repeat
  51.     Gotoxy(8,8);Write('Enter the name for the output file: ');
  52.     ReadLn(MyFileOut);
  53.     Gotoxy(8,9);ClrEol;
  54.     Assign(OutFile,MyFileOut);
  55.     {$I-} Reset(OutFile) {$I+} ;
  56.     FileFound := (IOresult = 0);
  57.     If FileFound then
  58.       begin
  59.         Gotoxy(8,9);sound(440);Delay(500);Nosound;Close(OutFile);
  60.         Write('That file already exists do you wish to continue (y): ');
  61.         Read(Answer);
  62.         If Upcase(Answer)='Y' then FileFound := False;
  63.       end;
  64.     Until not FileFound;
  65.  End;
  66.  
  67. begin
  68.     ClrScr;
  69.     OpenInFile;
  70.     CheckOutFile;
  71.     Gotoxy(8,10);Write('Enter the maximum number of spaces to delete: ');
  72.     ReadLn(MaxDelete);
  73.     Reset(InFile);
  74.     Assign(OutFile,MyFileOut);
  75.     Rewrite(OutFile);
  76.     Gotoxy(8,12);Write('The Input file is  ' + MyFileIn);
  77.     Gotoxy(8,14);Write('The Output file is ' + MyFileOut);
  78.     Gotoxy(8,16);Write('Working ON Line: ');
  79.     WriteLn(' ');
  80.     Scrnclr := 0;
  81.     NumLines := 0;
  82.  
  83.   while not EOF(InFile) do begin
  84.  
  85.       ReadLn(InFile,Line);
  86.       Numlines := Numlines + 1;
  87.       N:=0;
  88.       StillSpace := True;
  89.       {WriteLn(Line);}
  90.       While StillSpace Do
  91.         Begin
  92.           I:=N+1;
  93.           If Line[I]=' '
  94.             then N := N+1
  95.           Else StillSpace := False
  96.       end;
  97.       DELETE(Line,1,N);
  98.         {If scrnclr > 10 then
  99.            begin
  100.            ClrScr;
  101.            scrnclr:=0;
  102.         end
  103.         else scrnclr := scrnclr + 1;}
  104.       GotoXY(25,16);
  105.       WriteLn(NumLines);
  106.       WriteLn(OutFile,Line);
  107.     end;
  108.  
  109.     WriteLn(' ');
  110.     WriteLn('All Done');
  111.     Close(InFile);
  112.     Close(OutFile);
  113. end.
  114.  
  115.  
  116. Ln(OutFile,Line);
  117.     en