Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure TProgramm3_3.OpenFileClick(Sender: TObject);
- var
- NewMatrix: TMatrix;
- i, j, Max: Integer;
- Check: string;
- InputFile: TextFile;
- Error, isCorrect: Boolean;
- begin
- if OpenFileToRead.Execute then
- begin
- isCorrect := True;
- AssignFile(InputFile, OpenFileToRead.FileName);
- Reset(InputFile);
- If SeekEof(InputFile) then
- begin
- MessageDlg('Файл пуст', mtError,[mbOK],0);
- isCorrect := False;
- end
- else
- begin
- isCorrect := True;
- try
- i := -1;
- while (not EoF(InputFile)) and (i < 8) do
- begin
- Inc(i);
- SetLength(NewMatrix, i + 1);
- j := -1;
- while not (SeekEoLn(InputFile)) and (j < 8) do
- begin
- Inc(j);
- SetLength(NewMatrix[i], j + 1);
- Read(InputFile, NewMatrix[i, j]);
- end;
- Readln(InputFile);
- end;
- except
- ShowMessage('Некорректные данные в файле');
- isCorrect := False;
- end;
- end;
- if isCorrect then
- begin
- if i < j then
- SetLength(NewMatrix, i+1, i+1)
- else
- SetLength(NewMatrix, j+1, j+1);
- Order.Text := IntToStr((Length(NewMatrix)));
- for i := 0 to Length(NewMatrix)-1 do
- for j := 0 to Length(NewMatrix[0])-1 do
- begin
- Matrix.Cells[j, i] := IntToStr(NewMatrix[i, j]);
- end;
- end;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement