Advertisement
dxvmxnd

Untitled

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