Autor Beitrag
bocky3
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Di 19.04.05 15:20 
hi leutz,
ich brauch ma eure hilfe.
ich habe in problem mit der zeitmessung.
ich hab scho einige ausprobiert:

ausblenden Delphi-Quelltext
1:
2:
3:
anfang := time;
ende := time;
labal2.caption := 'Zeit: ' + floattostrf((ende-anfang) * 24 * 3600);


oder

ausblenden Delphi-Quelltext
1:
2:
Startzeit := Now;
Label2.Caption := DateTimeToStr(Now - Startzeit);


ich hab mir sogar 'ne eigene prozedur gschrieben, aber alles ohne erfolg.
nun hoffe ich auf eute ideen.

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Di 19.04.05 15:23 
Was genau willst du denn machen? :gruebel:
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Di 19.04.05 15:45 
Die Systemzeit ist halt nicht wirklich genau (im Sinne von hoch aufgelöst). Schau mal unter QueryPerformanceCounter nach.
Tilo
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1098
Erhaltene Danke: 13

Win7 geg. WInXP oder sogar Win98
Rad2007
BeitragVerfasst: Di 19.04.05 18:50 
Gib mal etwas mehr Code,. bei dem oben geposteten Code ist die ZEit 0, da sie zu gering ist.

Die Systemzeit kann auf Millisekunden gemessen werden.
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Di 19.04.05 18:54 
Die Zeit in ms:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var Zeit: integer;

Zeit:=GetCurrenttime;
... //Quelltext, wo die Zeit gemessen werden soll
Form1.Label1.Caption:=IntToStr(Zeit-GetCurrentTime)


Wenn du es in Minuten haben willst, musst du die Ausgabezeile entsprechend verändern.
Tobias1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 454

Win 98, XP Prof
D3 Prof, D2005 Prof
BeitragVerfasst: Di 19.04.05 20:10 

_________________
Auch das schlechteste Buch hat seine gute Seite: die letzte. (John Osborne)
bocky3 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Di 19.04.05 20:31 
also ich hab ein rätsel programmiert:
momentan 5 teilrätsel.
insgesamt 6 groupboxes
die zeitmessung soll gestartet werden, wenn der button " zum Spiel" geklickt wird (groupbox6).
sie soll enden wenn der button "weiter" von der ersten groupbox geklickt wird. gleichzeitig soll durch das klicken des buttons in einem label (label37.caption) die zeit angegeben werden, die zur lösung des rätsels gebraucht wurde.
die messung erfolgt zwar in verschiedenen groupboxes, aber die variablen wurden nicht überschrieben.
bocky3 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Di 19.04.05 20:32 
aso, die zeitmessung sollte möglichst unabhängig von der windowszeit sein.
Tobias1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 454

Win 98, XP Prof
D3 Prof, D2005 Prof
BeitragVerfasst: Di 19.04.05 20:53 
Wenn du unabhängig von der Windowszeit sein willst nimm doch ein Timer, der eine Var immer eins weiter zählt.

_________________
Auch das schlechteste Buch hat seine gute Seite: die letzte. (John Osborne)
Tobias1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 454

Win 98, XP Prof
D3 Prof, D2005 Prof
BeitragVerfasst: Di 19.04.05 20:57 
Wie wärs damit
ausblenden Delphi-Quelltext
1:
2:
var
t:Ttime;


Bei Spiel starten
ausblenden Delphi-Quelltext
1:
t:=time;					

Beim Weiter Button
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(timetostr(now-t));
end;


Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.

_________________
Auch das schlechteste Buch hat seine gute Seite: die letzte. (John Osborne)
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Mi 20.04.05 15:24 
Die Variante die ich vorgeschlagen habe ist auch weitestgehend unabhängig von der Windowszeit. Soweit ich weiß macht sich die Windows-Abhängigkeit erst nach 49,7 Tagen Computerlaufzeit bemerkbar (ich glaub nicht das ein normaler PC das auch aushält, ohne einmal abzuschmieren).
bocky3 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Mi 20.04.05 16:15 
danke erst ma für eure schnelle und kompetente hilfe. :D
beides funktioniert gut.
@ Heiko
in was wird mit die zeit ausgegeben?
in ca 3 sekunden bekomme ich nen wert von 1333867.
bocky3 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Mi 20.04.05 16:25 
noch ein prob die prozedur zählt runter?!
ich weiß zwar nich wieso aber sie tut das.
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Mi 20.04.05 17:16 
sry, ich hab den fehler gefunden

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var Zeit: integer;

Zeit:=GetCurrenttime;
... //Quelltext, wo die Zeit gemessen werden soll
Form1.Label1.Caption:=IntToStr(GetCurrentTime-Zeit)


Die Ausgabe erfolgt in ms. Mich wundert nur warum bei dem Fehler eine positive Zahl rauskommen konnte :gruebel: , oder hast du das Minuszeichen vergessen? Eigentlich müsste durch den fehlerhaften Teil immer eine negative Zeit rauskommen, bisauf du hast ein anderes, mir unbekanntes, Betriebssystem, welches schon vorher weiß wie lange du am PC bist, und daurch runter zählt :wink: .
bocky3 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Mi 20.04.05 20:48 
das kann ich dir sagen.
miene groupboxes waren verjkehrt angeordnet.^^
also die prozedur zur zeitmessung startete in der letzten groupbox.
hab noch ma alles überarbeitet.

trotzdem hab ich ein noch ein prob:
die variable zeit wird nich initialisiert.
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Do 21.04.05 05:33 
Kannst du mal dein ganzes Project hier reinstellen, damit ich es mal durchguggen kann, wo der Fehler ist?
Hilfreich wäre dann nur bei welchem Ereignis die Zeitmessung beginnen soll, und bei welchem enden.
bocky3 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Do 21.04.05 05:50 
ausblenden volle Höhe 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:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
procedure TForm1.Button1Click(Sender: TObject);
var zeit              :   integer;
begin

  zeit := GetCurrenttime;   //start der zeitmessung
  groupbox2.Show;
  groupbox1.Hide;
  groupbox3.Hide;
  groupbox4.Hide;
  groupbox5.Hide;
  groupbox6.Hide;
  groupbox7.Hide;
  

end;


procedure TForm1.Button2Click(Sender: TObject);
begin
if edit1.Text = 'gedicht'
 then
  begin
    groupbox3.Show;
    groupbox1.Hide;
    groupbox2.Hide;
    groupbox4.Hide;
    groupbox5.Hide;
    groupbox6.Hide;
    groupbox7.Hide;
  end
 else edit1.text := '';


  
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
if edit2.Text = 'friedhof'
 then
  begin
   groupbox4.Show;
   groupbox1.Hide;
   groupbox2.Hide;
   groupbox3.Hide;
   groupbox5.Hide;
   groupbox6.Hide;
   groupbox7.Hide;
  end
 else edit2.text := '';
Image1.Picture.LoadFromFile('bilder\x.bmp');

  
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
if edit3.Text = 'bär'
 then
  begin
   groupbox5.Show;
   groupbox1.Hide;
   groupbox2.Hide;
   groupbox3.Hide;
   groupbox4.Hide;
   groupbox6.Hide;
   groupbox7.Hide;
  end
 else edit3.text := '';

end;

procedure TForm1.Button5Click(Sender: TObject);
begin
if edit4.Text = 'schlange'
 then
  begin
   groupbox6.Show;
   groupbox1.Hide;
   groupbox2.Hide;
   groupbox3.Hide;
   groupbox4.Hide;
   groupbox5.Hide;
   groupbox7.Hide;
  end
 else edit4.text := '';

  
end;

procedure TForm1.Button6Click(Sender: TObject);
var zeit                            :      integer;
begin
Form1.Label33.Caption:=IntToStr(GetCurrentTime-Zeit);
if edit5.Text = 'hund'
 then
  begin
   Form1.Label33.Caption:=IntToStr(GetCurrentTime-Zeit); //hier soll die zeit ausgegeben werden
   groupbox1.Hide;
   groupbox2.Hide;
   groupbox3.Hide;
   groupbox4.Hide;
   groupbox5.hide;
   groupbox6.Hide;
   groupbox7.Hide;
  end
 else edit5.text := '';

  
end;

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

procedure TForm1.Speicher1Click(Sender: TObject);
var List: TStringList;
begin
 List:=TStringList.Create;
 List.Add(Edit1.Text);
 List.Add(Edit2.Text);
 List.Add(Edit3.Text);
 List.Add(Edit4.Text);
 List.Add(Edit5.Text);
 List.SaveToFile('bilder\save.text');
 List.Free;

end;

procedure TForm1.Laden1Click(Sender: TObject);
var List: TStringList;
begin
 List:=TStringList.Create;
 List.LoadFromFile('bilder\save.text');
 Edit1.Text:=List[0];
 Edit2.Text:=List[1];
 Edit3.Text:=List[2];
 Edit4.Text:=List[3];
 Edit5.Text:=List[4];
 List.Free;

end;


Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Do 21.04.05 05:58 
Den Fehler habe ich auf Anhieb gefunden. Er leigt in der 2. Zeile des geposteten Quelltextes. Die Variable Zeit musst du global definieren, und nicht lokal :wink: , da sonst die anderen Prozeduren die Zeit_Variable nicht kennen können. Wenn du die also global gemacht hast, kannst du die Stop-Funktion einbauen.
bocky3 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Do 21.04.05 20:44 
manchma sieht man den wald vor näumen nich... :roll:
danke^^