Autor Beitrag
LuGo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: So 07.02.10 12:34 
Hallo,

ich hab mal wieder eine Frage zum Thema Zeit:
Ich versuche ein Programm zu entwickeln, das eine zufällige Zeit herunterzählt und dann einen Block ausführt. Zur kleinen Erläuterung, es soll ein Programm sein, das die Strecke und Geschwindigekeit kennt und dann die Fahrtzeit daraus rechnet und dann herunterzählt. Kann mir jemand den Quellcode sagen und ihn dann erklären. Irgendwie hilft mir das alles nicht weiter, was ich hier und anders gefunden habe.

MfG

LuGo
platzwart
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1054
Erhaltene Danke: 78

Win 7, Ubuntu 9.10
Delphi 2007 Pro, C++, Qt
BeitragVerfasst: So 07.02.10 13:44 
Schau dir mal den Timer an. Den kannst du auf eine beliebige Zeit setzen (Inrtval) und dann starten (Enabled). Sobald die Zeit abgelaufen ist, wird der Code ausgeführt, den du dem OnTimer-Ereignis zugeordnet hast.

_________________
Wissenschaft schafft Wissenschaft, denn Wissenschaft ist Wissenschaft, die mit Wissen und Schaffen Wissen schafft. (myself)
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: So 07.02.10 14:53 
Hier mal ein kleines bsp. mit Timer vieleicht kannst du damit was anfangen
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
var
  Form1: TForm1;
  Zeit:TDateTime;
implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Zeit:= StrtoTime('00:01:01');
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
if Zeit < StrtoTime('00:00:01'then
  Caption:='Zeit abgelaufen'
  else
    begin
      Zeit:=Zeit - 1 / SecsPerDay;
      Caption:=TimeToStr(Zeit);
    end;
end;

end.
LuGo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: So 07.02.10 18:10 
Soweit habe ich das verstanden, danke, ich habe nur eine Frage zu der Zeile:
ausblenden Delphi-Quelltext
1:
Zeit:= StrtoTime('00:01:01');					

Kann ich anstelle des Werts 01:01 auch eine Variable einsetzen?

MfG

LuGo
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: So 07.02.10 18:17 
Klar, wenn sie vom Typ String ist schon. Die hochkomma bedeuten ja eigentlich nix anderes als das es n String ist, nur halt n konstanter string, statt einem variablen.

außerdem musst du aufpassen das deine variable dann auch die richtige formatierung hat, sonst schmeißt dir das Programm ne Exception um die Ohren.

lg elundril

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.