Advertisement
venik2405

lab6_2

Apr 29th, 2021
615
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 2.95 KB | None | 0 0
  1. function CheckFile(Path: String): Boolean;
  2. var
  3.     FileToCheck: TextFile;
  4.     N, I, J, Num: Integer;
  5. begin
  6.     AssignFile(FileToCheck, Path);
  7.     Reset(FileToCheck);
  8.     CheckFile := true;
  9.     try
  10.         Readln(FileToCheck, N);
  11.     except
  12.         CheckFile := false;
  13.     end;
  14.     if ((N < 2) or (N > 7)) then
  15.         CheckFile := False;
  16.     for J := 0 to N - 1 do
  17.     Begin
  18.         for I := 0 to N - 1 do
  19.         Begin
  20.             try
  21.                 Read(FileToCheck, Num);
  22.             except
  23.                 CheckFile := false;
  24.             end;
  25.             if ((Num < 0) or (Num > 999)) then
  26.                 CheckFile := False;
  27.             Read(FileToCheck);
  28.         End;
  29.         Readln(FileToCheck);
  30.     End;
  31.     CloseFile(FileToCheck);
  32. end;
  33.  
  34. procedure CheckData();
  35. Var
  36.     I, J, Num: Integer;
  37. Begin
  38.     for I := 1 to MainForm.SizeSpinEdit.Value do
  39.         for J := 1 to MainForm.SizeSpinEdit.Value do
  40.         Begin
  41.             try
  42.                 Num := StrToInt(MainForm.FieldSTRG.Cells[I, J]);
  43.             except
  44.                 MainForm.Calculate.Enabled := false;
  45.             end;
  46.             if (Num > 999) Or (Num < 0) then
  47.                 MainForm.Calculate.Enabled := false;
  48.         End;
  49. End;
  50.  
  51. Function FindIfExists(X, Y: Integer): Boolean;
  52. var
  53.     IfExists: Boolean;
  54. Begin
  55.     IfExists := True;
  56.     if (X > MainForm.SizeSpinEdit.Value) or (Y > MainForm.SizeSpinEdit.Value) then
  57.         IfExists := False;
  58.     if (X < 1) or (Y < 1) then
  59.         IfExists := False;
  60.     FindIfExists := IfExists;
  61. End;
  62.  
  63. Function WasChecked(X, Y: Integer): Boolean;
  64. Begin
  65.     WasChecked := Checked[X - 1,Y - 1];
  66. End;
  67.  
  68. Function FindIfPossible(X1, Y1, X2, Y2: Integer): Boolean;
  69. Var
  70.     FHigh, SHeigh: Integer;
  71. Begin
  72.     FHigh := StrToInt(MainForm.FieldSTRG.Cells[X1, Y1]);
  73.     SHeigh := StrToInt(MainForm.FieldSTRG.Cells[X2, Y2]);
  74.     if FHigh > Sheigh then
  75.         FindIfPossible := True
  76.     Else
  77.         FindIfPossible := False;
  78. End;
  79.  
  80. Procedure TMainForm.CoordinatesEditChange(Sender: TObject);
  81. Var
  82.     Num, Finish: Integer;
  83. Begin
  84.     MainForm.Height := 500;
  85.     FinalLabel.Caption := '';
  86.     Finish := MainForm.SizeSpinEdit.Value;
  87.     Calculate.Enabled := True;
  88.     try
  89.         Num := StrToInt(FirstXEdit.Text);
  90.     except
  91.         Calculate.Enabled := false;
  92.     end;
  93.     if (Num > Finish) Or (Num < 1) then
  94.         Calculate.Enabled := false;
  95.     try
  96.         Num := StrToInt(FirstYEdit.Text);
  97.     except
  98.         Calculate.Enabled := false;
  99.     end;
  100.     if (Num > Finish) Or (Num < 1) then
  101.         Calculate.Enabled := false;
  102.     try
  103.         Num := StrToInt(SecXEdit.Text);
  104.     except
  105.         Calculate.Enabled := false;
  106.     end;
  107.     if (Num > Finish) Or (Num < 1) then
  108.         Calculate.Enabled := false;
  109.     try
  110.         Num := StrToInt(SecYEdit.Text);
  111.     except
  112.         Calculate.Enabled := false;
  113.     end;
  114.     if (Num > Finish) Or (Num < 1) then
  115.         Calculate.Enabled := false;
  116.     CheckData();
  117. End;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement