Delphi-PRAXiS
Seite 1 von 5  1 23     Letzte »    

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Timer programmieren (https://www.delphipraxis.net/105306-timer-programmieren.html)

ScrollbarKopf 19. Dez 2007 16:12


Timer programmieren
 
:roll:
Ähm Hallo Leute geht um folgendes habe an den Letzten tagen an einer art lotto gearbeitet jetzt möchte ich gerne einen timer programmieren der alle 48 stunden den gewiiner sagt das er gewonnen aht und den verlierern das sie verloren haben wenn man auf den button ziehung drückt soll er die zahlen aufnehmen sagen ok und wenn die zeit aus ist sagen ob man gewoonen hat hier mein Code.
Delphi-Quellcode:

until (a<>b) and (a<>c) and (a<>d) and (a<>e) and (a<>f)
and  (b<>a) and (b<>c) and (b<>d) and (b<>e) and (b<>f)
and  (c<>a) and (c<>b) and (c<>d) and (c<>d) and (c<>f)
and  (d<>a) and (d<>b) and (d<>c) and (d<>e) and (d<>f)
and  (e<>a) and (e<>b) and (e<>c) and (e<>d) and (e<>f)
and  (f<>a) and (f<>b) and (f<>c) and (f<>d) and (f<>e);

edit1.Text := inttostr (a+1);
edit2.Text := inttostr (b+1);
edit3.Text := inttostr (c+1);
edit4.Text := inttostr (d+1);
edit5.Text := inttostr (e+1);
edit6.Text := inttostr (f+1);

richtige :=0;
if StrToInt( edit1.text) = StrToInt( edit7.text) then inc (richtige);
if StrToInt( Edit2.text) = StrToInt( Edit8.text) then inc (richtige);
if StrToInt( Edit3.text) = StrToInt( Edit9.text) then inc (richtige);
if StrToInt( Edit4.text) = StrToInt( Edit10.text) then inc (richtige);
if StrToInt( Edit5.text) = StrToInt( Edit11.text) then inc (richtige);
if StrToInt( Edit6.text) = StrToInt( Edit12.text) then inc (richtige);

if richtige = 6 then showmessage ('Sie haben Gewonnen');

falsche :=0;
if StrToInt( Edit1.text) <> StrToInt( Edit7.text) then inc (falsche);
if StrToInt( Edit2.text) <> StrToInt( Edit8.text) then inc (falsche);
if StrToInt( Edit3.text) <> StrToInt( Edit9.text) then inc (falsche);
if StrToInt( Edit4.text) <> StrToInt( Edit10.text) then inc (falsche);
if StrToInt( Edit5.text) <> StrToInt( Edit11.text) then inc (falsche);
if StrToInt( Edit6.text) <> StrToInt( Edit12.text) then inc (falsche);

if falsche =6 then showmessage ('Sie haben leider verloren');

end;

mkinzler 19. Dez 2007 16:14

Re: Timer programmieren
 
Am Besten als geplanten Task in Windows anlegen

gmc616 19. Dez 2007 16:15

Re: Timer programmieren
 
Gut. Dann viel Erfolg. :thumb:

Oder hast etwa ne Frage?? Konnte nämlich keine finden :gruebel:

ScrollbarKopf 19. Dez 2007 16:29

Re: Timer programmieren
 
ja habe ne frage habe null ahnung wie ich das machen soll mit dem timer

mkinzler 19. Dez 2007 16:31

Re: Timer programmieren
 
Ein Timer über 48 stunden ist nicht optimal. Sorge dafür das dein Programm in diesem Intervall gestartet wird: "Geplanter Task"

Nuclear-Ping 19. Dez 2007 16:34

Re: Timer programmieren
 
... oder du nimmst 'ne Variable des Typs TDateTime, speicherst mit Now den Zeitpunkt der letzten Ausführung darin und in einem Timer (der vlt. auf 10sek oder so steht) prüfst du die Variable mit Now gegen. Wenn (Variable + 2) >= Now sind 48h vergangen.

Delphi-Quellcode:
until (a<>b) and (a<>c) and (a<>d) and (a<>e) and (a<>f)
and  (b<>a) and (b<>c) and (b<>d) and (b<>e) and (b<>f)
and  (c<>a) and (c<>b) and (c<>d) and (c<>d) and (c<>f)
and  (d<>a) and (d<>b) and (d<>c) and (d<>e) and (d<>f)
and  (e<>a) and (e<>b) and (e<>c) and (e<>d) and (e<>f)
and  (f<>a) and (f<>b) and (f<>c) and (f<>d) and (f<>e);
*schauder* :mrgreen:

... Dafür hat man dir hier auch schon bessere Lösungen vorgeschlagen.

himitsu 19. Dez 2007 16:52

Re: Timer programmieren
 
wegen der 48 Stunden:
Timer ist blöd, weil dann müßte man den Rechner ja die ganzen 48 Stunden an lassen :shock:

Da klingt die Idee von mkinzler schon besser.


10 Sekunden? ... nja, bei 2 Tagen Laufzeit reicht doch auch 60 Sekunden ... auf die Sekunde kommt es doch bestimmt nicht an.


jupp schauder und doppelgemoppelt :stupid:
Delphi-Quellcode:
until (a<>b) and (a<>c) and (a<>d) and (a<>e) and (a<>f)
and  (b<>a) and (b<>c) and (b<>d) and (b<>e) and (b<>f)
and  (c<>a) and (c<>b) and (c<>d) and (c<>d) and (c<>f)
and  (d<>a) and (d<>b) and (d<>c) and (d<>e) and (d<>f)
and  (e<>a) and (e<>b) and (e<>c) and (e<>d) and (e<>f)
and  (f<>a) and (f<>b) and (f<>c) and (f<>d) and (f<>e);
da wird einiges mehrfach ausgewertet.
(a<>b) = (b<>a)
das Rote ist doppelt:
Code:
[color=gray]... hier fehlt wohl was[/color]
until (a<>b) and (a<>c) and (a<>d) and (a<>e) and (a<>f)
and  [color=red](b<>a)[/color] and (b<>c) and (b<>d) and (b<>e) and (b<>f)
and  [color=red](c<>a) and (c<>b)[/color] and (c<>d) and (c<>d) and (c<>f)
and  [color=red](d<>a) and (d<>b) and (d<>c)[/color] and (d<>e) and (d<>f)
and  [color=red](e<>a) and (e<>b) and (e<>c) and (e<>d)[/color] and (e<>f)
and  [color=red](f<>a) and (f<>b) and (f<>c) and (f<>d) and (f<>e)[/color];
man hat also nur verloren, wenn man alle 6 falsch hat?
Delphi-Quellcode:
falsche :=0;
if StrToInt( Edit1.text) <> StrToInt( Edit7.text) then inc (falsche);
if StrToInt( Edit2.text) <> StrToInt( Edit8.text) then inc (falsche);
if StrToInt( Edit3.text) <> StrToInt( Edit9.text) then inc (falsche);
if StrToInt( Edit4.text) <> StrToInt( Edit10.text) then inc (falsche);
if StrToInt( Edit5.text) <> StrToInt( Edit11.text) then inc (falsche);
if StrToInt( Edit6.text) <> StrToInt( Edit12.text) then inc (falsche);

if falsche =6 then showmessage ('Sie haben leider verloren');
wie wäre es z.B. so?
Delphi-Quellcode:
falsche :=0;
if StrToInt( Edit1.text) <> StrToInt( Edit7.text) then inc (falsche);
if StrToInt( Edit2.text) <> StrToInt( Edit8.text) then inc (falsche);
if StrToInt( Edit3.text) <> StrToInt( Edit9.text) then inc (falsche);
if StrToInt( Edit4.text) <> StrToInt( Edit10.text) then inc (falsche);
if StrToInt( Edit5.text) <> StrToInt( Edit11.text) then inc (falsche);
if StrToInt( Edit6.text) <> StrToInt( Edit12.text) then inc (falsche);

if falsche > 0 then showmessage ('Sie haben leider verloren');
Delphi-Quellcode:
falsche := 6 - richtige;
if falsche > 0 then showmessage ('Sie haben leider verloren');
Delphi-Quellcode:
if richtige < 6 then showmessage ('Sie haben leider verloren');
oder gleich zusammen
Delphi-Quellcode:
if richtige = 6 then showmessage ('Sie haben Gewonnen')
else showmessage ('Sie haben leider verloren');
oder ohne Zählvariable:
Delphi-Quellcode:
if (StrToInt(Edit1.text) = StrToInt(Edit7.text))
  and (StrToInt(Edit2.text) = StrToInt(Edit8.text))
  and (StrToInt(Edit3.text) = StrToInt(Edit9.text))
  and (StrToInt(Edit4.text) = StrToInt(Edit10.text))
  and (StrToInt(Edit5.text) = StrToInt(Edit11.text))
  and (StrToInt(Edit6.text) = StrToInt(Edit12.text)) then
begin
  showmessage ('Sie haben Gewonnen');
end else begin
  showmessage ('Sie haben leider verloren');
end;

ScrollbarKopf 19. Dez 2007 17:06

Re: Timer programmieren
 
himitsu danke für die ideen wegen dem doppelt schreiben ich werde es weg löschen das überflüßige mit deinen beispiel meinst du das man ur verloren hat wenn man alle falsch hat und das wenn man 3 falsch hat mit 3 punkten gewonnen hat oder

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
randomize;
repeat
  a:= random (46);
  b:= random (46);
  c:= random (46);
  d:= random (46);
  e:= random (46);
  f:= random (46);

until(a<>b) and (a<>c) and (a<>d) and (a<>e)
 and (a<>f) and (b<>c) and (b<>d) and (b<>e)
 and (b<>f) and (c<>d) and (c<>e) and (c<>f)
 and (d<>e) and (d<>f) and (e<>f);

edit1.Text := inttostr (a+1);
edit2.Text := inttostr (b+1);
edit3.Text := inttostr (c+1);
edit4.Text := inttostr (d+1);
edit5.Text := inttostr (e+1);
edit6.Text := inttostr (f+1);

richtige :=0;
if StrToInt( edit1.text) = StrToInt( edit7.text) then inc (richtige);
if StrToInt( Edit2.text) = StrToInt( Edit8.text) then inc (richtige);
if StrToInt( Edit3.text) = StrToInt( Edit9.text) then inc (richtige);
if StrToInt( Edit4.text) = StrToInt( Edit10.text) then inc (richtige);
if StrToInt( Edit5.text) = StrToInt( Edit11.text) then inc (richtige);
if StrToInt( Edit6.text) = StrToInt( Edit12.text) then inc (richtige);

if richtige = 6 then showmessage ('Sie haben Gewonnen');

falsche :=0;
if StrToInt( Edit1.text) <> StrToInt( Edit7.text) then inc (falsche);
if StrToInt( Edit2.text) <> StrToInt( Edit8.text) then inc (falsche);
if StrToInt( Edit3.text) <> StrToInt( Edit9.text) then inc (falsche);
if StrToInt( Edit4.text) <> StrToInt( Edit10.text) then inc (falsche);
if StrToInt( Edit5.text) <> StrToInt( Edit11.text) then inc (falsche);
if StrToInt( Edit6.text) <> StrToInt( Edit12.text) then inc (falsche);

if falsche =6 then showmessage ('Sie haben leider verloren');

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
edit1.clear;
edit2.clear;
edit3.clear;
edit4.clear;
edit5.clear;
edit6.clear;
edit7.clear;
edit8.clear;
edit9.clear;
edit10.clear;
edit11.clear;
edit12.clear;
end;

end.

vlees91 19. Dez 2007 17:10

Re: Timer programmieren
 
OT: ich hatte dir doch eine so schoene Funktion gemacht, fuer das errechnen von 6 unique Zufallszahlen... :cry: Ich bin beledigit, dass du die nicht verwendest :cry:

ScrollbarKopf 19. Dez 2007 17:12

Re: Timer programmieren
 
Kannst die Funktion bitte noaml schreiben kann sein das ich das nciht mitbekommen ahbe


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:57 Uhr.
Seite 1 von 5  1 23     Letzte »    

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