Board index » delphi » repeat until keypressed

repeat until keypressed

in pascal, it looks like this:
repeat
loop;
until keypressed;

how to make that in delphi?
the loop function runs after user click run|run and stop if user click
run|stop. do I have to use multithread?
procedure runClick;
repeat until finish=1; <- if like this, the stopClick won't be run.

procedure stopClick;
finish=1;

thanks a lot

 

Re:repeat until keypressed


in pascal, it looks like this:
repeat
loop;
until keypressed;

how to make that in delphi?
the loop function runs after user click run|run and stop if user click
run|stop. do I have to use multithread?
procedure runClick;
repeat until finish=1; <- if like this, the stopClick won't be run.

procedure stopClick;
finish=1;

thanks a lot

Re:repeat until keypressed


procedure runClick;
repeat
  {do something}
  Application.ProcessMessages;  < You need this in your loop
until finish=1;

procedure stopClick;
finish=1;
--

Rodney E Geraghty
GERA-Tech
Ottawa, Canada
gera...@ibm.net

Frans Gunawan <fra...@geocities.com> wrote in article
<35f81f6c.664...@news.rad.net.id>...

Quote
> in pascal, it looks like this:
> repeat
> loop;
> until keypressed;

> how to make that in delphi?
> the loop function runs after user click run|run and stop if user click
> run|stop. do I have to use multithread?
> procedure runClick;
> repeat until finish=1; <- if like this, the stopClick won't be run.

> procedure stopClick;
> finish=1;

> thanks a lot

Re:repeat until keypressed


Here something that will work, but you should REALLY REALLY
look for a better programming technique.  This is BAD programming.

Procedure RunClick(Sender: TObject);
begin
  while (Finished <> 1)
  begin
    {Do something}
    Application.ProcessMessages;
  end;
end;

Procedure StopClick(Sender: TObject);
begin
  Finished := 1;
end;

Quote
Frans Gunawan wrote:
> in pascal, it looks like this:
> repeat
> loop;
> until keypressed;

> how to make that in delphi?
> the loop function runs after user click run|run and stop if user click
> run|stop. do I have to use multithread?
> procedure runClick;
> repeat until finish=1; <- if like this, the stopClick won't be run.

> procedure stopClick;
> finish=1;

> thanks a lot

Other Threads