Access Violation when passing Objects lazarus / 21-General ---------------------------------------------------------------------- Weitentaaal · 2022-01-27 12:46 Hello, so i got this Strange error like shown below: If u take a look at the two images attached u can see that i just call a procedure, and when it gets called i get an access violation. Thats the Object, which gets passed to the procedure->(which seems to be fine) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TEst1 = = {   = {     _vptr$ = {       0xa6580c,        0x1}},    FMAXQUANTITY = 1,   FISCHECKED = false,   FGROUP = 0,   FQUANTITY = 0,   FISSELFDEF = false,   FID = 49,   FNAME = 'Ansaug-/Ausblashaube ALU',   FZUSATZPARAM = 0,   FNEEDID = '0',   FPREIS = 0}  the Exception is not even in my code it gets fired in this line Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i begin  does any1 know how to fix this ? Edit: i have the Same function which ensures that items are deleted, which works perfectly fine ---------------------------------------------------------------------- Zvoni · 2022-01-27 13:05 The only difference i see is your Line 9 to your Watchwindow: "0x1" vs "0x0" ---------------------------------------------------------------------- Weitentaaal · 2022-01-27 13:17 All the Data displayed above (Which describes the Object) was taken when hovering over the Object "TEst1". So this should be the same as in the wachwindow. Is the Problem here ? Edit: Just tested this Function in different Places of my Code.. always the same. Tested with a fresh created Object, with nil and with an object that was holding real data. ---------------------------------------------------------------------- Weitentaaal · 2022-01-27 13:27 Just checked the assembler, even if i don't know how to use it, and saw that the "end;" line gets executed before the "begin" line. (See attachment). Could thi be the reason for the AV ? ---------------------------------------------------------------------- Weitentaaal · 2022-01-27 14:40 Found the mistke i did: i got an Array of integer (GroupID: Array of Integer;), which was filled by following procedure: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TBauteil.ZubGetGroup(GroupID: Integer): TIntegerArray;var   i, j: Integer;begin   j:= 0;   for i := 0 to ZubList.Count do begin      if ZubList.Items[i].Group = GroupID then begin         Result[j]:= ZubList.Items[i].ID;         j:= j + 1;      end;   end;end;  My Array was "Array of Integer" the Result of the Function was "TIntegerArray". They are not the same because TIntegerArray is not a Dynamic array. why won't i get a Syntax error there ? and why did the Exception occur in the begining on the "begin" line ? do i have wrong settings for that or is that intended? Thanks for your work ! ---------------------------------------------------------------------- Thaddy · 2022-01-27 14:55 Quote from: Weitentaaal on January 27, 2022, 03:40:22 pmMy Array was "Array of Integer" the Result of the Function was "TIntegerArray". They are not the same because TIntegerArray is not a Dynamic array. Well, that depends: many programmers redefine TIntegerArray as array of integer. But FPC has support for this in the types unit: TIntegerDynArray which is declared as Array of integer. So if you need the latter, simply add types and use TIntegerDynArray as result type. Because TIntegerArray redeclaration might confuse. ---------------------------------------------------------------------- Weitentaaal · 2022-01-27 15:01 Hey thanks for the clarification. i know how to use it now But i still don't know why the error was shown at this certain line ? it was so confusing and took me like forever to find where the mistake was made. ---------------------------------------------------------------------- Thaddy · 2022-01-27 15:09 Oh, I forgot one more easy option, w/o the types unit: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$mode objfpc}type TMyIntegerArray = specialize TArray; // defined in system as array of TIn newer versions of fpc TArrray is declared in system. And let that now be the option I use most.... With no particular reason, I am just fond of generics, I guess. It has no code penalty over the other options. ---------------------------------------------------------------------- Weitentaaal · 2022-01-27 15:36 Thank you thaddy... appreciated !