Advertisement
RevolutIIon

Untitled

Nov 4th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.59 KB | None | 0 0
  1. procedure OutputInf(NumbersFromString: TStringArray);
  2. var
  3.    Output: TextFile;
  4.    FileName: String;
  5.    Iteration, Index: Integer;
  6.    OutputToFile, AppendInfToFile: Boolean;
  7. begin
  8.    if Length(NumbersFromString) <> 0 then
  9.    begin
  10.       Writeln('There are ', length(NumbersFromString), ' integers in your string.');
  11.       Iteration := Length(NumbersFromString) - 1;
  12.       for Index := 0 to Iteration do
  13.          Writeln(NumbersFromString[Index]);
  14.       Writeln('Do you want to output data to a file?');
  15.       OutputToFile := UserChooce();
  16.       if OutputToFile then
  17.       begin
  18.          Write('Please, enter name of the file');
  19.          Writeln('Example: Text.txt');
  20.          Readln(FileName);
  21.          AssignFile(Output, FileName);
  22.          try
  23.             if FileExists(FileName) then
  24.             begin
  25.                Write('A file with this name already exists, ');
  26.                Writeln('do you want to append information');
  27.                AppendInfToFile := UserChooce();
  28.                if AppendInfToFile then
  29.                   Append(Output)
  30.                else
  31.                   Rewrite(Output);
  32.             end
  33.             else
  34.                Rewrite(Output);
  35.          except
  36.             Writeln('Error writing to file');
  37.          end;
  38.          Writeln(Output, 'There are ', length(NumbersFromString), ' integers in your string.');
  39.          for Index := 0 to Iteration do
  40.          Writeln(Output, NumbersFromString[Index]);
  41.          CloseFile(Output);
  42.          Writeln('Write was successfully');
  43.       end;
  44.    end
  45.    else
  46.       Writeln('Your string have not integers.')
  47. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement