Problem about loops
Posted on 2000-01-01
Hi, I have the following code:
procedure TForm1.Button1Click(Sender: TObject);
for i:=1 to 100 do
temp:=i; (temp is a global var)
Form1.SomethingDone; (this will use temp somewhere)
if something=1 then ...
if something=2 then ...
if something=3 then ...
if something=10 then ...
My question is that: AFTER the execution of somethingdone, it will be called once again if something<>10 (ie. itself is an event)
But the problem arises, after somethingdone is executed once ONLY, the for loop in button1click continues executing immediately. How can I make the for loop "wait" and continue executing until SomethingDone has been executed 10 times? (The var something will increase by 1 each time)
Please dont suggest me to include the code in somethingdone in the button1click, since somethingdone is actually a component's event.