Autor Beitrag
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Di 30.01.07 02:19 
ich hab ne variable als Byte generiert in der hoffnung das die eben nit größer als 255 wird ;D

tjo nu schau ich im debugger nach weil mein pro scheinbar in ner endlosschleife hing und sagt mir das meine variable 256 ist. normalerweise fängt delphi ja dann wieder bei 0 an
aber ich spekulier ja in meinem programm noch nichma drauf dasses von vorn los geht ;D

ausblenden Delphi-Quelltext
1:
2:
3:
Repeat
  inc(j);
Until j = MeineFunction + 1;


dabei gibt MeineFunction aufgrund von nem klein fehler in dieser machmal den wert 255 zurück, aber das ist ja erstmal egal, das ja normal dann halt wieder auf 0 geht ;D

warum/wie ist das möglich das die variable den wert 256 bekommt?

ich benutz Delphi 3
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 30.01.07 09:11 
Ich tippe auf einen Fehler in der Deklaration. Gibt etwas mehr Code.
ssb-blume
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 375
Erhaltene Danke: 7

XP, W7, W8
Deutschland
BeitragVerfasst: Di 30.01.07 10:53 
Wenn sowohl "j" als auch "MeineFunction" als Byte deklariert wurden, gibt es schon einen Fehler bei
MeineFunction+1, wenn die Variable 256 hat!

Deshalb muss dies abgefangen werden. Man setzt ja auch keinen Nenner auf Null und erwartet,
dass das Ergenis funzt!

_________________
Brain: an apparatus with which we think we think.
Ironwulf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Di 30.01.07 18:17 
aber z.b. bei obiger schleife fäng j dann wieder bei 0 an, den code von der schleife hab ich nimmer, hat mich zu sehr gefr4ustet und hab den weggehaun
Popov
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1655
Erhaltene Danke: 13

WinXP Prof.
Bei Kleinigkeiten D3Pro, bei größeren Sachen D6Pro oder D7
BeitragVerfasst: Di 30.01.07 18:42 
Der Fehler ist definitiv hier:

ausblenden Delphi-Quelltext
1:
2:
3:
Repeat
  inc(j);
Until j = MeineFunction + 1 ;


Wenn (MeineFunction + 1) > 255 ist, dann ist das eine Endlosschleife.

j wir auch nie den Wert 256 haben. Er kann 256 Werte haben, aber nicht den Wert 256. Aber (MeineFunction + 1), wenn MeineFunction = 255, kann 256 ergeben.

Bau dir einfach das in deine Schleife ein:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
Repeat
  inc(j);
  Caption := IntToStr(j);
  if j >= 255 then Sleep(500);

Until j = MeineFunction + 1 ;


Solltest du 256 in der Titelleiste sehen, dann sag bescheid und wir schreiben an Borland.

_________________
Popov
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Di 30.01.07 18:57 
Application.ProcessMessages eventuell noch rein?

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Ironwulf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Di 30.01.07 19:04 
mich hat ja verwundert das j eben 256 groß war
wo sich der fehler in meinem code befindet ist mir schon klar ;D
ich bekomms leider nit nochma hin, hätt ich nur nen screeni gmacht :(