[b][red]This message was edited by UGuardian at 2005-4-3 18:33:44[/red][/b][hr]
The program I'm working on at the moment always trips a runtime error.
When run via Delphi's run menu, the error is an access violation (and naturally the code is shown).
The weird part is, this exact code compiled correctly and ran without any errors in another program I did a few weeks ago. I cut & pasted the code, so a typo is very unlikely.
Here's the class that's causing the problem:
TOrb = class(TObject)
X, Y : Integer;
function IsHere(M,N : Integer) : boolean;
X := Random(20);
Y := Random(20);
function TOrb.IsHere(M,N : Integer) : boolean;
if X = M then
if Y = N then
IsHere := True else IsHere := False;
Whenever X or Y is accessed (read or writen) it trips the error. Even in the TOrb.Create code.
What could be causing this weird behavior?
After comparing the source of this program and the one I did a while back I spotted an error in the code. It was not in the TOrb class -- it was in the Form's Create method.
Probably moving too fast I'd incorrectly created TOrbs, and since it was a null refence it crashed like it was supposed to.
I just wish Delphi was more accurate as to which line of code the error's on. The error was no where near where it said it was.