Problem about loops

Hi,  I have the following code:
procedure TForm1.Button1Click(Sender: TObject);
var
   i   :integer;
begin
......
     for i:=1 to 100 do
     begin
          temp:=i;   (temp is a global var)
          Form1.SomethingDone;   (this will use temp somewhere)
     end;
......
end;

procedure TForm1.SomethingDone;
begin
......
     if something=1 then ...
     if something=2 then ...
     if something=3 then ...
......
     if something=10 then ...
end;
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.
Thanks!!
nytAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nytAuthor Commented:
Edited text of question.
0
intheCommented:
hi,
do you want something like this:
Regards Barry

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  temp : integer = 0;
implementation

{$R *.DFM}
procedure something;
begin
showmessage('doing it '+inttostr(temp));
end;

procedure TForm1.Button1Click(Sender: TObject);
var
i ,ii: integer;
begin
for i := 0 to 100 do begin
   for ii := 0 to 9 do begin
    something;
    inc(temp);
   end;
   temp := 0;
  end;

end;

end.
0
nytAuthor Commented:
Sorry,
Actually, something is the procedure being called when the procedure something itself has been ended (Event of an component)
When temp is changing, the procedure something will do different things.  Of course, the procedure something is not simply a inc(temp)...it has more than 50 lines...
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

intheCommented:
what about adding a global boolean and inside the loop
do something like :

for i ...
begin
 MyBoolean := True;
  something;
   Repeat Aplication.Processmessages
  until
 MyBoolean = false;
end;

back to loop

and inside or after components event set myboolan := false
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nytAuthor Commented:
Thank you!  It does what I need.
0
intheCommented:
:-) glad to hear it works
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.