Autor Beitrag
Sithlord Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 172



BeitragVerfasst: Fr 06.06.08 22:22 
1. Wie ist diese Zeit definiert? Ist sie zufällig? Für jeden Button unterschiedlich, aber konstant? Oder ist sie einstellbar? Gibt es noch andere Faktoren?

Die Zeit ist für jeden Timer unterschiedlich - und verlängert sich immer wieder ! Nein, andere Faktoren nicht, es ist nur so, das dieser String verändert werden muss, also string1:='10'; und eben der Timer verändert werden muss !




2. Was passiert, wenn die Zeit abgelaufen ist? Kann man diese Aktion auch irgendwie berechnen?

Nein, diese kann man nicht berechnen.
Wenn die Zeit abgelaufen ist, dann werden die oben genannten Funktionen ausgeführt.

Mfg Sithlord

_________________
Heut ist nicht alle Tage, ich hab wieder ein Problem, keine Frage...
Sithlord Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 172



BeitragVerfasst: Sa 28.06.08 21:17 
Weiß hier niemand weiter ?

Ist nähmlich nicht ganz unwichtig, gibt es wirklich keine einfachere Methode ?

_________________
Heut ist nicht alle Tage, ich hab wieder ein Problem, keine Frage...
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Sa 28.06.08 22:22 
Hi,

Geht was genau einfacher? Hast du nochmal ne Kurzversion(3 Sätze so, sollst jetzt nicht alles nochmal schreiben :) )?

'Verlängert sich immer wieder' -> Wenn du diese Verlängerung berechnen willst, kannst du sicher einen Term auf der Basis der 'Interval'-Property des Timers aufstellen, nach der du den neuen Wert berechnest.

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
Sithlord Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 172



BeitragVerfasst: So 29.06.08 20:28 
Ok, mach ich gerne ;-)

Nun, wie schon beschrieben, brauche ich einen Code, welcher mir "Jedes mal beim drücken eines Button" einen Code ausführt. Dieser Code ist aber unterschiedlich.
Weiß da jemand rat ?

Mfg Sithlord

_________________
Heut ist nicht alle Tage, ich hab wieder ein Problem, keine Frage...
FinnO
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: So 29.06.08 20:33 
bei dem desselben buttons auch ne globale Zählervariable?! ^^
Sithlord Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 172



BeitragVerfasst: So 29.06.08 20:53 
Nein, beim ersten mal jetzt z.b.
ausblenden Delphi-Quelltext
1:
label1.caption:='1';					

und beim zweiten mal
ausblenden Delphi-Quelltext
1:
label1.caption:= '4';					


und beim dritten mal
ausblenden Delphi-Quelltext
1:
label1.caption:='20';					

_________________
Heut ist nicht alle Tage, ich hab wieder ein Problem, keine Frage...
FinnO
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: So 29.06.08 22:07 
ja... globale Zählervariable...
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: So 29.06.08 22:16 
Verwende eine sortierte Liste mit zwei Spalten. In der 1.Spalte steht WANN etwas ausgeführt werden soll und in der 2.Spalte steht dann, WAS ausgeführt wird.

Dann nimmst Du einen einzigen Timer, der z.B. 1x pro Sekunde aufgerufen wird. Der schaut einfach nach, ob das oberste element der eben beschriebenen Liste fällig ist, d.h. abgearbeitet werden muss. Wenn ja, wird die Aktion ausgeführt und die Aktion aus der Liste entfernt.

Um neue Aktionen zu definieren, berechnest du den Zeitpunk und fügst diese Information in die Liste ein.

Fertig.

Ach, und wenn du so ein Geheimnis um dein Programm machst, wie meinst Du, wird man dir richtig helfen können?

_________________
Na denn, dann. Bis dann, denn.
hazard999
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 162

Win XP SP2
VS 2010 Ultimate, CC.Net, Unity, Pex, Moles, DevExpress eXpress App
BeitragVerfasst: Mo 30.06.08 09:10 
Nimm einen Timer (genau Einen).

Den stellst du auf die kleinste Zeiteinheit ein die es in deinem Spiel gibt.

Dann nimmst du eine Liste.
Wenn der Benutzer einen Button drückt, fügst du ein Element in die Liste ein (wenn es nur einmal vorkommen darf, dann Suchen und nur bei nicht gefunden einfügen).

Im Timer hast du eine Schleife.

Damit durchläufst du die Liste (am besten rückwärts).

Vergleich ob der Timeout vom Listen-Element erreicht ist.

Dann Aktion durchführen.
Element entfernen.

fertig.

PS: MIST. Schon wieder Seite 2 übersehen.

_________________
MOV EAX, Result;MOV BYTE PTR [EAX], $B9;MOV ECX, M.Data;MOV DWORD PTR [EAX+$1], ECX;MOV BYTE PTR [EAX+$5], $5A;MOV BYTE PTR [EAX+$6], $51;MOV BYTE PTR [EAX+$7], $52;MOV BYTE PTR [EAX+$8], $B9;MOV ECX, M.Code;MOV DWORD PTR [EAX+$9], ECX
robo202
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 67

win XP
Delphi 2005
BeitragVerfasst: Mo 30.06.08 10:31 
Dein hauptproblem ist einfach zu lösen du brauchst nicht 1000 Timer
hier ein Beispiel
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure Form1.Timer1Timer(Sender: TObject);
var
i:integer;
begin
If i = 1 then showmessage ('1');
If i = 2 then showmessage ('2');
If i = 3 then showmessage ('3');
If i = 4 then showmessage ('4');
If i = 5 then showmessage ('5');

i := i+1;
huuuuuh
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Mo 30.06.08 10:38 
eher uneffektiv.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure Form1.Timer1Timer(Sender: TObject);
var
 i:integer;
begin
case i of
 begin
  1: showmessage('1');
  ...
 end;
inc(i);
end;
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 30.06.08 10:38 
Also bei dem Code spuckt der Compiler mindestens zwei Warnungen aus, die besagen, dass man da Unsinn gecodet hat. ;-)

_________________
We are, we were and will not be.
hazard999
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 162

Win XP SP2
VS 2010 Ultimate, CC.Net, Unity, Pex, Moles, DevExpress eXpress App
BeitragVerfasst: Mo 30.06.08 10:39 
Schön hingeklopft,

funktioniert nur nicht ;-).

i ist eine lokale Variable.
A kommt mal die Meldung das der Startwert von i nicht definiert ist.
B geht der Wert von i nach dem Durchlauf verloren.


Weiters löst das natürlich nicht das Problem das unterschiedliche Ereignisse unterschiedlich lang dauer um aufzutreten.

_________________
MOV EAX, Result;MOV BYTE PTR [EAX], $B9;MOV ECX, M.Data;MOV DWORD PTR [EAX+$1], ECX;MOV BYTE PTR [EAX+$5], $5A;MOV BYTE PTR [EAX+$6], $51;MOV BYTE PTR [EAX+$7], $52;MOV BYTE PTR [EAX+$8], $B9;MOV ECX, M.Code;MOV DWORD PTR [EAX+$9], ECX
huuuuuh
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Mo 30.06.08 10:41 
wollt doch nur den code von user profile iconrobo202 verbessern. den vorschlag mit ner glbalen zählvariable hab ich schon in der 1. antwort geschrieben
robo202
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 67

win XP
Delphi 2005
BeitragVerfasst: Mo 30.06.08 10:42 
dan schreibe i oben unter var rein und definire sie in form creat als 1 dann müsste es klappen
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 30.06.08 10:46 
Ja, "i" als Bezeichner für eine globale Variable zu nehmen, ist eine ganz fantastische Idee. :mrgreen:

Das mit der globalen Zählvariable kam ja auch schon am Anfang. ;-)

_________________
We are, we were and will not be.
hazard999
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 162

Win XP SP2
VS 2010 Ultimate, CC.Net, Unity, Pex, Moles, DevExpress eXpress App
BeitragVerfasst: Mo 30.06.08 10:51 
Globale Variablen sind eine "fantastische" Idee.

Wozu OO wenns strukturiert auch geht... *kopfschüttel*

_________________
MOV EAX, Result;MOV BYTE PTR [EAX], $B9;MOV ECX, M.Data;MOV DWORD PTR [EAX+$1], ECX;MOV BYTE PTR [EAX+$5], $5A;MOV BYTE PTR [EAX+$6], $51;MOV BYTE PTR [EAX+$7], $52;MOV BYTE PTR [EAX+$8], $B9;MOV ECX, M.Code;MOV DWORD PTR [EAX+$9], ECX
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Mo 30.06.08 13:09 
Hi,

user profile iconhazard999 hat folgendes geschrieben:
Globale Variablen sind eine "fantastische" Idee.
imho gibt es drei akzeptable Varianten. Zwei davon benötigen eine Feldvariable im Form-Objekt.

Eine Variable global, wie die Formvariable, gelöst in der Unit zu deklarieren, ist imho einfach nur unsauber. Es kann dann das Form-Objekt nicht mehrfach erzeugt werden(was zwar trotzdem selten vorkommt, Klassen sind allerdings eigentlich nicht dazu gedacht, auf eine Instanz limitiert zu werden).

Okay.. Variante eins: mehrere getrennte Prozeduren, die dann jeweils am Ende der jeweiligen Prozedur dem Timer die nächste Prozedur als Ereignis zuweisen. Finde ich unübersichtlich.

Variante2: Eine Case-Abfrage mit Feldvariable und Inc.

Mein Favourit ist Variante3: Ein Array mit Feldvariable und Inc. Entweder Array of Procedure für bessere Übersicht, welche Prozeduren ausgelöst werden oder Array of String, wenn es wirklich um sowas wie ShowMesage mit unterschiedlichen Argumenten geht. Halte ich für das übersichtlichste, da eine lange Case-Abfrage doch nochmal mehr Platz verbraucht.

Bliebe noch zu klären, ob die Prozeduren linear in einer Reihe aufgerufen werden oder auch völlig durchmixt. Wenn sie durchmixt auftreten können eine sortierte Liste: Sortiert nach Aktivierungszeit und dann den Timer immer auf die Kürzeste Zeit stellen und das oberste Element der Liste auslösen.

Zitat:
Wozu OO wenns strukturiert auch geht... *kopfschüttel*

Was meinst du genau mit OO? ObjektOrientiert? NullNull wie keine Struktur?

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
hazard999
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 162

Win XP SP2
VS 2010 Ultimate, CC.Net, Unity, Pex, Moles, DevExpress eXpress App
BeitragVerfasst: Mo 30.06.08 13:16 
Ja, Objektorientiert. OO ist eine gängige Abkürzung.

Kommt von object orientation. Im Englischen sind ja 2 Wörter.

Variante 3 ist zu favorisieren, genau meine Meinung.
Array of Procedure ist natürlich eine der schönsten Lösungen.

Der korrekte objektorientierte Ansatz wäre ein factory pattern.

_________________
MOV EAX, Result;MOV BYTE PTR [EAX], $B9;MOV ECX, M.Data;MOV DWORD PTR [EAX+$1], ECX;MOV BYTE PTR [EAX+$5], $5A;MOV BYTE PTR [EAX+$6], $51;MOV BYTE PTR [EAX+$7], $52;MOV BYTE PTR [EAX+$8], $B9;MOV ECX, M.Code;MOV DWORD PTR [EAX+$9], ECX
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Mo 30.06.08 15:05 
user profile iconhazard999 hat folgendes geschrieben:
Wozu OO wenns strukturiert auch geht... *kopfschüttel*

user profile iconhazard999 hat folgendes geschrieben:
Ja, Objektorientiert. OO ist eine gängige Abkürzung.

:arrow: "Wozu Objektorientiert, wenn es auch strukturiert geht"

Was ist denn strukturiertes Programmieren? Das ist doch ziemlich deckungsgleich mit einer Objektorientierten Programmierung, oder? Ich denke, eine Feldvariable in der Formularklasse ist strukturiert genug.