Advertisement
dxvmxnd

Untitled

Oct 29th, 2024
8
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. Function ChoosePath() : String;
  2. Var
  3. Path : String;
  4. IsCorrect : Boolean;
  5. InputFile : TextFile;
  6. Begin
  7. Begin
  8. Repeat
  9. Writeln('Введите путь к файлу для ввода информации: ');
  10. IsCorrect := True;
  11. Readln(Path);
  12. Try
  13. AssignFile(InputFile, Path);
  14. Reset(InputFile);
  15. Except
  16. IsCorrect := False;
  17. End;
  18. If (Not IsCorrect) Or (Length(Path) < 5) Then
  19. Begin
  20. IsCorrect := False;
  21. Writeln('Ошибка ввода! Повторите попытку.');
  22. End
  23. Else
  24. Begin
  25. If ((Path[High(Path)] <> 't') And (Path[High(Path) - 1] <> 'x') And (Path[High(Path) - 2] <> 't') And (Path[High(Path) - 3] <> '.')) Then
  26. Begin
  27. IsCorrect := False;
  28. Writeln('Ошибка ввода! Повторите попытку.');
  29. End;
  30. End;
  31. Until IsCorrect;
  32. End;
  33.  
  34. CloseFile(InputFile);
  35.  
  36. ChoosePath := Path;
  37. End;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement