this is my code of unit1, contain form, place a label1,edit1,button1
it thrown sigsevg error at line "if not (txt=avalue) then"
if comment it then other sigsevg error occur at line 403b00
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
valueeventhandler =procedure (newvalue:string) of object;
type varb=class(tobject)
procedure setvalue(avalue:string);
function getvalue:string;
private
txt:string;
valchange:valueeventhandler;
public
property value:string read getvalue write setvalue;
property valuechange:valueeventhandler read valchange write valchange;
end ;
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
procedure FormCreate(Sender: TObject);
procedure varbchange(txt:string) ;//of object;
private
{ private declarations }
public
{ public declarations }
myvar:varb;
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
myvar.value:='is first value and assign manual to label,then add value change event';
label1.Caption:=myvar.value;
myvar.valuechange:=@varbchange;
end;
procedure tform1.varbchange(txt:string);
begin
label1.caption:=myvar.value;
end;
procedure varb.setvalue(avalue:string);
begin
if not (txt=avalue) then//<-------------------------------error at this line
begin
txt:=avalue;
if assigned(valuechange) then
valuechange(avalue);
end;
end;
function varb.getvalue:string;
begin
result:=txt;
end;
end.
please help