Better support for records and properties lazarus / 64-FPC development ---------------------------------------------------------------------- domasz · 2024-04-05 20:24 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 type TPix = recordR,G,B,A: Byte;end; property Pixel[X,Y: Integer]: TPix read GetPixel write SetPixel; default; Now I can do: 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 R := MyBitmap[x,y].R; but I can't: 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 MyBitmap[x,y].R := R; Would be nice to be able to do that. Also these 2 compile but don't work: 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 with MyBitmap[x,y] do R := 255; MyBitmap[x,y].R += 20; ---------------------------------------------------------------------- ASerge · 2024-04-06 01:31 Quote from: domasz on April 05, 2024, 10:24:40 pmWould be nice to be able to do that. Assuming that this code works, what does it output? 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}{$LONGSTRINGS ON}{$APPTYPE CONSOLE} type  TRec = record    X: Integer;  end; function GetRec: TRec;begin  Result.X := 1;end; var  R: TRec = (X: 2);begin  GetRec.X := 3;  Writeln(GetRec.X);  Readln;end. This is the reason why the compiler does not allow you to do this. ---------------------------------------------------------------------- domasz · 2024-04-06 04:40 I see your point but in this case it could just discard the result (nothing to write value back to) while in my case there is something to write value back to. ---------------------------------------------------------------------- ASerge · 2024-04-06 05:16 Quote from: domasz on April 06, 2024, 06:40:35 amI see your point but in this case it could just discard the result (nothing to write value back to) while in my case there is something to write value back to. The same. Properties with the read method work like a regular function. To avoid side effects for functions that return a "complex" type, the compiler creates a temporary variable. Therefore, the following operations will be applicable to it. In early versions of Delphi, this was allowed, but the developers wondered why the result was rejected. Then just banned it. For this to work, a pointer must be returned, in particular an object of the class. ---------------------------------------------------------------------- cdbc · 2024-04-06 05:25 Hi Wouldn't it be possible to return a "PPix" and then {$modeswitch autoderef on}, if you don't like the ^-hat-business... Regards Benny ---------------------------------------------------------------------- domasz · 2024-04-06 09:44 Thank you, ASerge and Benny!