Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CheckFile(Path: String): Boolean;
- var
- FileToCheck: TextFile;
- N, I, J, Num: Integer;
- begin
- AssignFile(FileToCheck, Path);
- Reset(FileToCheck);
- CheckFile := true;
- try
- Readln(FileToCheck, N);
- except
- CheckFile := false;
- end;
- if ((N < 2) or (N > 7)) then
- CheckFile := False;
- for J := 0 to N - 1 do
- Begin
- for I := 0 to N - 1 do
- Begin
- try
- Read(FileToCheck, Num);
- except
- CheckFile := false;
- end;
- if ((Num < 0) or (Num > 999)) then
- CheckFile := False;
- Read(FileToCheck);
- End;
- Readln(FileToCheck);
- End;
- CloseFile(FileToCheck);
- end;
- procedure CheckData();
- Var
- I, J, Num: Integer;
- Begin
- for I := 1 to MainForm.SizeSpinEdit.Value do
- for J := 1 to MainForm.SizeSpinEdit.Value do
- Begin
- try
- Num := StrToInt(MainForm.FieldSTRG.Cells[I, J]);
- except
- MainForm.Calculate.Enabled := false;
- end;
- if (Num > 999) Or (Num < 0) then
- MainForm.Calculate.Enabled := false;
- End;
- End;
- Function FindIfExists(X, Y: Integer): Boolean;
- var
- IfExists: Boolean;
- Begin
- IfExists := True;
- if (X > MainForm.SizeSpinEdit.Value) or (Y > MainForm.SizeSpinEdit.Value) then
- IfExists := False;
- if (X < 1) or (Y < 1) then
- IfExists := False;
- FindIfExists := IfExists;
- End;
- Function WasChecked(X, Y: Integer): Boolean;
- Begin
- WasChecked := Checked[X - 1,Y - 1];
- End;
- Function FindIfPossible(X1, Y1, X2, Y2: Integer): Boolean;
- Var
- FHigh, SHeigh: Integer;
- Begin
- FHigh := StrToInt(MainForm.FieldSTRG.Cells[X1, Y1]);
- SHeigh := StrToInt(MainForm.FieldSTRG.Cells[X2, Y2]);
- if FHigh > Sheigh then
- FindIfPossible := True
- Else
- FindIfPossible := False;
- End;
- Procedure TMainForm.CoordinatesEditChange(Sender: TObject);
- Var
- Num, Finish: Integer;
- Begin
- MainForm.Height := 500;
- FinalLabel.Caption := '';
- Finish := MainForm.SizeSpinEdit.Value;
- Calculate.Enabled := True;
- try
- Num := StrToInt(FirstXEdit.Text);
- except
- Calculate.Enabled := false;
- end;
- if (Num > Finish) Or (Num < 1) then
- Calculate.Enabled := false;
- try
- Num := StrToInt(FirstYEdit.Text);
- except
- Calculate.Enabled := false;
- end;
- if (Num > Finish) Or (Num < 1) then
- Calculate.Enabled := false;
- try
- Num := StrToInt(SecXEdit.Text);
- except
- Calculate.Enabled := false;
- end;
- if (Num > Finish) Or (Num < 1) then
- Calculate.Enabled := false;
- try
- Num := StrToInt(SecYEdit.Text);
- except
- Calculate.Enabled := false;
- end;
- if (Num > Finish) Or (Num < 1) then
- Calculate.Enabled := false;
- CheckData();
- End;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement