Delphi-PRAXiS
Seite 1 von 2  1 2      

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

DeddyH 19. Dez 2007 17:25

Re: Timer programmieren
 
In diesem Thread wurden Dir schon einige Lösungsansätze präsentiert.

himitsu 19. Dez 2007 17:35

Re: Timer programmieren
 
dieses wird nur angezeigt wenn alle 6 richtig sind
Delphi-Quellcode:
if richtige = 6 then showmessage ('Sie haben Gewonnen');
und dieses nur wen alle 6 falsch sind.
Delphi-Quellcode:
if falsche = 6 then showmessage ('Sie haben leider verloren');
bei 1 bis 5 Falschen/Richtigen wird nichts angezeigt :stupid:

DeddyH 19. Dez 2007 17:36

Re: Timer programmieren
 
Stimmt, wurde aber auch schon erwähnt, glaube ich ;)

ScrollbarKopf 19. Dez 2007 17:55

Re: Timer programmieren
 
himitsu das bringt sich aber nix er soll ja anzeigen wenn man 1-5 falsche hat das man verloren hat

DeddyH 19. Dez 2007 18:01

Re: Timer programmieren
 
Das ist in Deinem Source aber nicht so.

ScrollbarKopf 19. Dez 2007 18:04

Re: Timer programmieren
 
doch ahb ich doch geschrieben
Delphi-Quellcode:
it Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Edit10: TEdit;
    Edit11: TEdit;
    Edit12: TEdit;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
   a,b,c,d,e,f :integer;
   richtige: integer;
   falsche: integer;
implementation

{$R *.dfm}

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

Die Muhkuh 19. Dez 2007 18:04

Re: Timer programmieren
 
Anstatt auf Gleichheit kannst auch Größer als prüfen. ;-)

Und hör auf, jedesmal Deinen Source zu posten...

ScrollbarKopf 19. Dez 2007 18:09

Re: Timer programmieren
 
Ich weiß ent was ihr alle meint ich sage doch das er sagt wenn alle 6 richtig sind soll er sagen gewoonnnen und wenn nur eins falsch ist soll er sagen das man verloren aht

DeddyH 19. Dez 2007 18:10

Re: Timer programmieren
 
Delphi-Quellcode:
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')
else showmessage ('Sie haben leider verloren');
Ist kürzer und richtiger.

Zitat:

Zitat von Die Muhkuh
Und hör auf, jedesmal Deinen Source zu posten...

Jo, da wäre ich auch für.

ScrollbarKopf 19. Dez 2007 18:16

Re: Timer programmieren
 
Hat geklabt mit der verkürzten version danke und das mit den source werd ich mir merken :-D

himitsu 19. Dez 2007 18:19

Re: Timer programmieren
 
das falsche = 6 aus deinem Code zeigte die Falsch-Meldung nur bei genau 6 falschen Zahlen an :zwinker:

Das in #12 ist dein Code (nur die Vergleichabfragen)
In Beitrag #7 und auch nochmal eines davon in der #19 macht es richtigz

ScrollbarKopf 19. Dez 2007 18:23

Re: Timer programmieren
 
OK danke eine Frage ncoh wei kann man sein delphi programm verpacken so das man nur iene datei braucht um es zu öffnen also wenn amn jemanden das programm geben will der kein delphi hat

Die Muhkuh 19. Dez 2007 18:23

Re: Timer programmieren
 
Ihm die Exe-Datei schicken? :lol:

DeddyH 19. Dez 2007 18:24

Re: Timer programmieren
 
Beim Kompilieren kommt ne *.exe raus, die musst Du weitergeben.

ScrollbarKopf 19. Dez 2007 18:25

Re: Timer programmieren
 
bracuht man nur die exe datei ja und ne 2 frage kann man das symbol dieser datei ändern wenn ja wo bekommt symbole her

Die Muhkuh 19. Dez 2007 18:26

Re: Timer programmieren
 
Schneller Detlef, schneller :mrgreen:

Ja, kann man in den Projektoptionen ändern.
Wo man die her bekommt: http://www.delphipraxis.net/internal...t.php?t=102268

DeddyH 19. Dez 2007 18:27

Re: Timer programmieren
 
In den Projektoptionen kannst Du ein neues Icon vergeben. Das kannst Du mit dem Bildeditor etc. selbst erstellen.

@Manuel :P

ScrollbarKopf 19. Dez 2007 18:28

Re: Timer programmieren
 
Danke Dörte
Heiße Marc und net Detlef

ScrollbarKopf 19. Dez 2007 18:28

Re: Timer programmieren
 
Danke Manuel

Die Muhkuh 19. Dez 2007 18:29

Re: Timer programmieren
 
Zitat:

Zitat von ScrollbarKopf
Danke Dörte
Heiße Marc und net Detlef

Ich hab auch gar nicht Dich gemeint, sondern den Detlef (DeddyH). ;-)

ScrollbarKopf 19. Dez 2007 18:43

Re: Timer programmieren
 
Ok sorry Inere Gedanken Des san immer die ausreden :-)

DeddyH 19. Dez 2007 18:44

Re: Timer programmieren
 
Ich hab kein Wort verstanden :gruebel:

Die Muhkuh 19. Dez 2007 18:45

Re: Timer programmieren
 
Zitat:

Zitat von DeddyH
Ich hab kein Wort verstanden :gruebel:

Da bist Du nicht der einzige. Hab ja vorhin schon mal geschrieben, dass er auf seine Rechtschreibung achten soll...

ScrollbarKopf 19. Dez 2007 18:48

Re: Timer programmieren
 
bast schon egal jetzt.
Ok habe symbole und wie kann ich das Symbol jetzt ändern von dem Programm

Die Muhkuh 19. Dez 2007 18:50

Re: Timer programmieren
 
Zitat:

Zitat von Die Muhkuh
Ja, kann man in den Projektoptionen ändern.

Zitat:

Zitat von DeddyH
In den Projektoptionen kannst Du ein neues Icon vergeben. Das kannst Du mit dem Bildeditor etc. selbst erstellen.

btw. neue Frage, neuer Thread
Und das Problem findet sich auch in der Forensuche

DeddyH 19. Dez 2007 18:51

Re: Timer programmieren
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hier

ScrollbarKopf 19. Dez 2007 19:07

Re: Timer programmieren
 
wie komme ich zu den projektoptionen finde das net

DeddyH 19. Dez 2007 19:08

Re: Timer programmieren
 
Projekt -> Optionen im Hauptmenü (zumindest unter Delphi 7).

ScrollbarKopf 19. Dez 2007 19:12

Re: Timer programmieren
 
Habs gfunden sieht bei turbo delphi total anders aus

DeddyH 19. Dez 2007 19:13

Re: Timer programmieren
 
Ich kann ja nicht wissen, dass Du TD benutzt.


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:30 Uhr.
Seite 1 von 2  1 2      

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