Please tell me how to fix some problems when working with a form. On the form in the Memo, when you press a key, an array of 10 random numbers is generated. How to make the array appear only once, and not with each press?
procedure TForm1.Memo1Change(Sender: TObject); var a: Tarr; i: integer; str: string; begin if memchange then exit; memchange := true; randomize; str := ''; for i := 1 to 10 do begin a[i] := random(10); str := str + inttostr(a[i]) + ' '; end; Memo1.Lines.Add(str); memchange := false; end; Another form should have two edit components into which the user, after receiving the array, must enter: a number (element index), which is calculated using the formula (low(array)+high(array)) div 2 (first edit), index 4 ; number - the value of this element (second edit). And in case the user is not right, point out the error and ask to try again. I can not figure out exactly how to implement it. Made a check on the index, but nothing happens.
procedure TForm3.Edit1Change(Sender: TObject); procedure CheckPivot(var a: Tarr); var pivot, pivoted: integer; begin pivot := (low(a) + high(a)) div 2; pivoted := strtoint(Edit1.Text); if pivot <> pivoted then ShowMessage('Неверно'); Edit1.SetFocus; end; begin end;
memchange := false;- IgorReadOnly:=truepropertyReadOnly:=true2. The arrayadeclared in theMemo1Changemethod, how do you access it to callCheckPivot- androschuk