[Solved] - My First Class - Access violation when setting private var lazarus / 21-General ---------------------------------------------------------------------- Wilko500 · 2021-02-10 00:08 My first (failed) attempt at understanding and creating a class having read the Class documentation. My code compiles but on running in Lazarus IDE fails on any attempt to reference a private var, a Sigsegv error, when running without IDE Access Violation error. Please can someone tell me where I am going wrong. My Class 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 unit ClsChartSettings; {$mode objfpc}{$H+} interface Type    TChSet = ClassPrivate    PageHt:    Single;   //Private var to hold Page Height Procedure SetHt(PgHt: Single);  //Private proc to set Page Height Public constructor Create(ChId : String);Property PageH: Single Read PageHt Write SetHt;   //Public property read from private var                                                //Write with proc SetHtEnd; implementationuses    Classes, SysUtils, Dialogs; constructor TChSet.Create(ChId: String);//Initialise class variable beginPageHt:=0;ShowMessage('Class Created ' + ChId);End; Procedure TChSet.SetHt(PgHt: Single);//This proc to set private varBeginPageHt:=PgHt;End; end.  My Test program 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, Forms, Controls, Graphics, Dialogs, StdCtrls,  ClsChartSettings; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    Edit1: TEdit;    Edit2: TEdit;    Edit3: TEdit;    Edit4: TEdit;    Label1: TLabel;    Label2: TLabel;    Label3: TLabel;    Label4: TLabel;    Label5: TLabel;    procedure Button1Click(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);var  x:      TChSet;begin  x.Create('Test');  x.PageH:=297;  ShowMessage(x.PageH.ToString);end; end. ---------------------------------------------------------------------- Blaazen · 2021-02-10 00:15 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 var  x:    TChSet;begin  x:=TChSet.Create('Test'); ---------------------------------------------------------------------- dseligo · 2021-02-10 00:27 And put this at the end: 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 x.Free; ---------------------------------------------------------------------- Wilko500 · 2021-02-10 00:52 Well that was easy.  Thanks.  I should have spotted that but evidently couldn't see for looking . Thanks also for noting the need for x.Free. I was aware but lazy coding while focussed on the error.