Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DELAY equivalent in Delphi

129 views
Skip to first unread message

Nivaldo Fernandes

unread,
May 12, 1995, 3:00:00 AM5/12/95
to
Hi:

Does any one know how to implement an equivalent to the DELAY procedure
in Borland Pascal? The TTimer won't do since it does not pause
code execution and using DecodeTime to calculate time intervals is very
difficult due to the cyclic nature of time (0-59 min, o-59 sec, ectc.).

I would appreciate suggestions...Thanks in advance.


les...@hk.super.net

unread,
May 14, 1995, 3:00:00 AM5/14/95
to

I have used a Timer component and the followings to solve the problem:

1) add a boolean variable TimOk to your form
2) add a Timer component to your form

procedure Form1.TimeDelay(Delay: Integer);
begin
TimeOK := False;
Timer1.Enabled := False;
Timer1.Interval := Delay;
Timer1.Enabled := True;
repeat
Application.ProcessMessages;
until TimeOK;
end;

then in your Timer's timer event, write:

Form1.Timer1Timer(Sender: TObject);
begin
TimeOK := True;
end;

then when you need to delay in your program, just call TimeDelay with how
long you wish to delay as it's parameter.

Best Rgds, _
I
I__esLie_.


Dr. W. Gross

unread,
May 16, 1995, 3:00:00 AM5/16/95
to
In article <3p5ppl$f...@tst.hk.super.net>, <les...@hk.super.net> wrote:
>In <3ovr9s$t...@ari.net>, Nivaldo Fernandes <n.fer...@conservation.org> writes:
>>Hi:
>>
>>Does any one know how to implement an equivalent to the DELAY procedure
>>in Borland Pascal?

[stuff deleted]

Hallo,

what about this (rather obscene) way to delay:

USES ...., SysUtils, ...;

CONST Second=1.0/(24.0*3600.0);

Any := 5; {any figure you want}
StartTime := Now;
repeat Application.ProcessMessages until ((Now-StartTime)>Any*Second);

Tschuess Wolfgang

--
--------------------------------------------------------------------------
Dr. W. Gross, Abt. f. Exp. Chirurgie, Uniklinik Heidelberg, Germany
Wolfgan...@exchi.uni-heidelberg.de

Al Lipscomb

unread,
May 17, 1995, 3:00:00 AM5/17/95
to
Dr. W. Gross (ex...@sun0.urz.uni-heidelberg.de) wrote:

: In article <3p5ppl$f...@tst.hk.super.net>, <les...@hk.super.net> wrote:
: >In <3ovr9s$t...@ari.net>, Nivaldo Fernandes <n.fer...@conservation.org> writes:
: >>Hi:
: >>
: >>Does any one know how to implement an equivalent to the DELAY procedure
: >>in Borland Pascal?


You could set a timer, and when it goes off it could continue the
process.....
--
Al Lipscomb | 1-800-HIT-HOME | Systems Programmer
a...@intnet.net | Help not Hassle. | All opinions are
St. Pete, FL | Youth Development Int. | my own.


Suresh Dharmalingam

unread,
Jun 12, 1995, 3:00:00 AM6/12/95
to
ex...@sun0.urz.uni-heidelberg.de (Dr. W. Gross) wrote:
>what about this (rather obscene) way to delay:
> USES ...., SysUtils, ...;
> CONST Second=1.0/(24.0*3600.0);
> Any := 5; {any figure you want}
> StartTime := Now;
> repeat Application.ProcessMessages until ((Now-StartTime)>Any*Second);

Nice, but you forgot to taken into account the Stroke of Midnight
(86400 seconds).

That is (depending on implementation):

if Now - StartTime < 0 do

or

if StartTime + Any > 86400 do


-- Suresh


0 new messages