Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure ReadFromFile(var Words: String);
- var
- FileName: String;
- IsCorrect, CorrectName: Boolean;
- InFile: Text;
- begin
- repeat
- Writeln('Enter a file name for data entry in the format Name.txt');
- repeat
- Readln(FileName);
- if FileExists(FileName) then
- CorrectName := True
- else
- begin
- Writeln('The file name was entered incorrectly. Try again. Example: Name.txt');
- CorrectName := False;
- end;
- until CorrectName;
- IsCorrect := True;
- Assign(InFile, FileName);
- Reset(InFile);
- if IOResult <> 0 then
- begin
- Writeln(' File does not exist!');
- IsCorrect := False;
- end
- else
- begin
- Read(InFile, Words);
- if length(Words) = 0 then
- begin
- Writeln('File is empty!');
- IsCorrect := False;
- end;
- end;
- until IsCorrect;
- Close(InFile);
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement