How do I declare my variable as a pointer correctly lazarus / 21-General ---------------------------------------------------------------------- ratmalwer · 2021-11-21 17:07 I have some lists. The lists are actually Arrays of Records defined globally. I want to switch between them by setting the variable acivelist to the current list (list1, list2). When I do so (Codesample) I do not get my values filled as expected (see last showmessages in code). How do I declare activelist correctly? 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     unit Unit1;        {$mode objfpc}{$H+}        interface        uses      Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;        type          TBildrecord = record            Filename:string;            nameOnly:string;            MainDir:string;            Mark:string;          end;        TBildarray = array of Tbildrecord;          { TForm1 }          TForm1 = class(TForm)        Button1: TButton;        procedure Button1Click(Sender: TObject);        procedure FormShow(Sender: TObject);      private          public          end;                var      Form1: TForm1;          List1: TbildArray;      List2: TbildArray;      activeList :  TbildArray;        implementation      {$R *.lfm}        { TForm1 }        procedure TForm1.FormShow(Sender: TObject);    begin      setLength(List1,1);      setLength(List2,1);    setLength(activeList,1);    end;        procedure TForm1.Button1Click(Sender: TObject);    var x: integer;    begin             ActiveList := List2;                   x := 1;               setLength(List2,x+1);                   List2[x].Mark := 'somevalue';                   Showmessage('List2: ' + List2[x].Mark +    '  ActiveList: ' + activeList[x].Mark);                   // Returns   List2: somevalue     Activelist: (empty)       !!!!!!!!!!!!!!!            end;        end. ---------------------------------------------------------------------- Bart · 2021-11-21 17:18 Don't use SetLength on ActiveList (in FormShow). You create a new "instance" of it, but you only need it as a pointer. Bart ---------------------------------------------------------------------- ratmalwer · 2021-11-21 17:25 Hi Bart i did so, it works, but with the same effect. Funny enough, when I hit te Button twice, the value is present. How can I get rid of the delay? ---------------------------------------------------------------------- bytebites · 2021-11-21 18:02 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     procedure TForm1.Button1Click(Sender: TObject);    var x: integer;    begin                 x := 1;               setLength(List2,x+1);              ActiveList := List2;                  List2[x].Mark := 'somevalue';                  Showmessage('List2: ' + List2[x].Mark +  '  ActiveList: ' + activeList[x].Mark);                  // Returns List2: somevalue     Activelist: (empty)       !!!!!!!!!!!!!!!       end; ---------------------------------------------------------------------- ratmalwer · 2021-11-21 18:20 Hi bytebites Yes - that does the Job :-) even when I go and change the value afterwards.  Now it is my job to find the right mechanism in the more complex Target-App. Thanks Markus