klasscho

Untitled

May 10th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. procedure TForm5.N2Click(Sender: TObject);
  2. var
  3. inputFile: TextFile;
  4. temp, i,j: integer;
  5. begin
  6. if Open.Execute then
  7. begin
  8. try
  9. AssignFile(inputFile, Open.FileName);
  10. Reset(inputFile);
  11. n := 0;
  12. ReadLn(inputFile, n);
  13. SG.ColCount := n + 1;
  14. SG.RowCount := n + 1;
  15. if SeekEof(inputFile) then
  16. begin
  17. MessageDlg('Данный файл пустой. Попробуйте снова.', mtError, [mbRetry], 0);
  18. CloseFile(inputFile);
  19. end
  20. else
  21. begin
  22. for i:= 1 to n do
  23. for j:= 1 to n do
  24. begin
  25. Read(InputFile, temp);
  26. SG.Cells[j,i]:= IntToStr(temp);
  27. end;
  28. CloseFile(inputFile);
  29. end;
  30. except
  31. MessageDlg('Проверьте введенные данные.', mtError, [mbRetry], 0);
  32. CloseFile(inputFile);
  33. end;
  34. for i:= 1 to n do
  35. begin
  36. SG.Cells[i,0] := IntToStr(i);
  37. SG.Cells[0,i] := IntToStr(i);
  38. end;
  39.  
  40. end;
  41. end;
Advertisement
Add Comment
Please, Sign In to add comment