Autor Beitrag
[r2d2]
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 109

WinXP
D5 Enterprise
BeitragVerfasst: Do 09.12.04 23:00 
Hallo Alle zusammen
Ich programmiere gerade ein ziemlich komplexes Spiel. Jetzt ist mir aufgefallen, dass sich der Wert einer ganz bestimmten Variablen immer dann ändert, wenn ich eine neue Variable erstelle. Ich kann mir das nur so erklären, dass ich irgendwo im Programm-Code die Länge eines Arrays überschreite. Diese Stelle kann ich aber unmöglich manuell finden. Gibt es eine Möglichkeit, sich Überschreitungen von arrays anzeigen zu lassen?
Wenn so eine Überschreitung direkt im Quellcode steht, dann wird das ja angezeigt. Beispiel:
bla sei ein integer-array der länge 2
bla[3] := 1; Folgende Übertretung wird aber nicht erkannt: for i:=3 to 3 do bla[i] := 1;

An dieser Stelle möchte ich auch gleich noch eine Frage los werden: Kann ich dem Debugger sagen, dass er bei access violations bitte sagen soll, welche Zeile im Quellcode sie verursacht hat?

Danke im Vorraus
Klaus
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Do 09.12.04 23:14 
Während das Programm läuft, gehst du in der Delphi-IDE unter Suchen\Laufzeitfehler ... rein. Dort gibst du die Code-Adresse der AV (die erste derr beiden in der Meldung) an und drückst ENTER. Danach springt er entweder ins CPU-Fenster oder im Quelltext an die richtige Stelle.

In wie weit das unter den Pers-Eds verfügbar ist, kann ich nicht sagen, mein D4S hatte das aber glaube auch schon.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Do 09.12.04 23:31 
Es geht auch einfacher... einfach in den Projekt-Optionen bei Compiler -> Runtime Errors -> Range checking aktivieren. Solltest du jetzt mal die Arraygrenzen überschreiten wird eine Exception ausgelöst..!

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
[r2d2] Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 109

WinXP
D5 Enterprise
BeitragVerfasst: Do 16.12.04 17:10 
Danke, hat beides super geklappt, hatte wirklich über ein array hinaus geschrieben.
Die Sache mit den Access Violations ist zwar ein bisschen umständlich, aber immer noch besser als garnichts.