Forum > General
[Win32] Crash... Any suggestions?
Reenen:
I do not know why my application crashes... Here is the error message:
(http://img.villagephotos.com/p/2005-3/983433/error.jpg)
It crashes when I click a certain menu-item. I am not sure why it is.
It might be because I have subfunctions... ie:
--- Code: ---
Procedure TfrmMain.ImportData;
Type
TRecord = Record
...
end;
var
vars : Array of TRecord;
Function DoStuff; //Sub Function
begin
vars[1]...
end;
begin // Main part of Importdata
DoStuff;
end;
--- End code ---
But it worked for a while, and now it doesn't. I don't know what's happening, and I can't debug it for some reason. Adding a breakpoint does nothing.
-Reenen
Vincent Snijders:
With this little code I can't really tell, what is wrong with your code.
Usually, if you run code in the IDE with the debugger enabled, I will show you the location of the error.
I just tried an event handler for a menu item with a nested function and had no such error.
Reenen:
How does Lazarus implement dynamic Arrays?
Can I just do
--- Code: ---
var arr : array of integer;
begin
arr[0] := 1;
arr[1] := 4;
end;
--- End code ---
Or will this give an error?
Vincent Snijders:
This will give an access violation, because you didn't allocate memory for the array.
Revised example (untested)
--- Code: ---
var arr : array of integer;
begin
SetLength(array, 2); // don't forget this.
arr[0] := 1;
arr[1] := 4;
end;
--- End code ---
You don't need to free the array after using it, the compiler generates code for that.
Reenen:
Which unit should I use to get access to SetLength?
Navigation
[0] Message Index
[#] Next page