dynamic array question lazarus / 21-General ---------------------------------------------------------------------- k1attila1 · 2022-10-28 04:49 Hi Is it not working in FP ? var   a: array of integer; begin a:=[1,2]; //it is ok a:=a+[3]; // ??? not work https://blog.marcocantu.com/blog/2014_september_dynamic_arrays_delphix e7.html thanks attila ---------------------------------------------------------------------- howardpc · 2022-10-28 05:21 In objfpc mode FPC interprets the [3] in that position as a set, not an array constructor. You have to writeCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Insert(3, a, High(a)); Or you can declare an array b, and writeCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i b := [3];a := Concat(a, b); ---------------------------------------------------------------------- k1attila1 · 2022-10-28 05:27 thanks howardpc i understand , I just wanted to let you know that it doesn't work or works differently than delphi thanks again ---------------------------------------------------------------------- dseligo · 2022-10-28 05:58 Quote from: k1attila1 on October 28, 2022, 07:27:06 amI just wanted to let you know that it doesn't work or works differently than delphi At the top of your unit put this: 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 delphi} And remove: 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} Then it'll work as in Delphi. ---------------------------------------------------------------------- PascalDragon · 2022-10-29 13:37 Quote from: k1attila1 on October 28, 2022, 06:49:50 amIs it not working in FP ? var   a: array of integer; begin a:=[1,2]; //it is ok a:=a+[3]; // ??? not work Array operators are disabled by default in non-Delphi modes, because FPC also allows to overload the +-operator of an array which the built-in operator would replace (because built-in operators take precedence). Thus you need to enable array operators by adding {$modeswitch arrayoperators} after the {$mode objfpc} directive.