Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Before and after events (https://www.delphipraxis.net/144325-before-after-events.html)

sdean 5. Dez 2009 09:41


Before and after events
 
i'm trying to implement a Before and After Event onTime :

how could i do an event before Min Value 'in this case 5 minutes ' ?
Delphi-Quellcode:
Procedure Before(Min:Word);
Var
Tm:TTime;
begin
Min:=5;// 5 Miutes
Tm:=Now;
{
for example :
if before 5 Minutes then
ShowMessage('5 minutes to go ');
}
end;
how could i do an event after Min Value 'in this case 5 minutes ' ?

Delphi-Quellcode:
Procedure After(Min:Word);
Var
Tm:TTime;
begin
Min:=5;// 5 Miutes
Tm:=Now;

{
for example :
if after 5 Minutes then
ShowMessage('5 minutes passed');
}
end;

himitsu 5. Dez 2009 10:50

Re: Before and after events
 
Zitat:

i'm trying to implement a Before and After Event onTime :
Depending on what?

Code:
if before 5 Minutes then
Delphi-Quellcode:
if Tm - (Min / 24 / 60) = ... then
When using a TTimer or equivalent never check for equality!
e.g.
Delphi-Quellcode:
if Abs(Tm - (Min / 24 / 60) - ...) < {interval} then

Delphi-Referenz durchsuchenMin is not a good variable name, especially if it integrates the unit Math.

sdean 5. Dez 2009 10:58

Re: Before and after events
 
Thank you himitsu

All depends on the Current Time :

i use TTimer .

if X minutes to the current time then Before

if X minutes passed from current time then after

i hope i gave a little detail

sdean 5. Dez 2009 16:37

Re: Before and after events
 
I reformed my Question as follows :

how could i do an event before Min Value 'in this case 5 minutes ' ?


Delphi-Quellcode:
Procedure Before(Min:Word);
Var
 Sm, // System Time ; Time to compare To
 Mt: // My Time ; Time to compare with

S:String;
TTime;
begin
S:='10:05:00';
Min:=5; // 5 Miutes
Sm:=Now;         // system time
Mt:=StrToTime(S);//  My Time

Let's suppose the fowlling :
Sm:=10:00:00; // System Time
Mt:=10:05:00; //  My Time
That means it's 5 minutes to rich Mt time '10:05:00'

if before 5 Minutes then
ShowMessage('5 minutes to rich My Time ');

end;

how could i do an event after Min Value 'in this case 5 minutes ' ?

Delphi-Quellcode:
Procedure After(Min:Word);
Var
 Sm, // System Time ; Time to compare To
 Mt: // My Time ; Time to compare with

S:String;
TTime;
begin
S:='10:00:00';
Min:=5; // 5 Miutes
Sm:=Now;         // system time
Mt:=StrToTime(S);//  My Time

Let's suppose the fowlling :
Sm:=10:05:00; // System Time
Mt:=10:00:00; //  My Time
That means it's 5 minutes passed from Sm time '10:05:00'

if after 5 Minutes then
ShowMessage('5 minutes passed from system time ');
}
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:45 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz