This seems like the simplest thing in the world and I'm ready to pull my hair out over it.
I have a unit that looks like this ;
Unit myUnit;
// ...
//normal declarations
//...
Public
//bunch of procedures including
Procedure myProcedure;
const
//bunch of constants
var
//bunch of vars including
myCounter:integer;
Implementation
Uses //(all my uses)
// All of my procedures including
Procedure myProcedure;
try
// load items from file to TListBox - this all works
except
on EReadError do begin
// handle exception
end;
end; //try
myCounter:=0; // <-- ACCESS VIOLATION HERE
while myCounter //...etc
It's a simple assignment of a variable and I have no idea why it is doing this. I've tried declaring the variable local to the unit, to the procedure, globally - no matter where I try to do it I can't assign a value of zero to an integer, declared anywhere, within this procedure without it throwing an access violation. I'm totally stumped.
I'm calling the procedure from inside a button OnClick handler from within the same unit, but no matter where I call it from it throws the exception. The crazy thing is that I do the exact same thing in a dozen other places in units all over the program without problems. Why here? I'm at a total loss.