Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure OutputInf(NumbersFromString: TStringArray);
- var
- Output: TextFile;
- FileName: String;
- Iteration, Index: Integer;
- OutputToFile, AppendInfToFile: Boolean;
- begin
- if Length(NumbersFromString) <> 0 then
- begin
- Writeln('There are ', length(NumbersFromString), ' integers in your string.');
- Iteration := Length(NumbersFromString) - 1;
- for Index := 0 to Iteration do
- Writeln(NumbersFromString[Index]);
- Writeln('Do you want to output data to a file?');
- OutputToFile := UserChooce();
- if OutputToFile then
- begin
- Write('Please, enter name of the file');
- Writeln('Example: Text.txt');
- Readln(FileName);
- AssignFile(Output, FileName);
- try
- if FileExists(FileName) then
- begin
- Write('A file with this name already exists, ');
- Writeln('do you want to append information');
- AppendInfToFile := UserChooce();
- if AppendInfToFile then
- Append(Output)
- else
- Rewrite(Output);
- end
- else
- Rewrite(Output);
- except
- Writeln('Error writing to file');
- end;
- Writeln(Output, 'There are ', length(NumbersFromString), ' integers in your string.');
- for Index := 0 to Iteration do
- Writeln(Output, NumbersFromString[Index]);
- CloseFile(Output);
- Writeln('Write was successfully');
- end;
- end
- else
- Writeln('Your string have not integers.')
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement