1
Beginners / Re: Initialize Form Variable?
« Last post by cdbc on Today at 11:17:43 am »Hi
I haven't got the foggiest...
But... In fpc and lazarus, if you create a class, all the memberfields are initialized to 0/nil/'' etc. in "InitInstance". If you desire a variable/memberfield to have another value on startup, you can do so in the class' constructor, usually called "Create". In TForm regi, you'd fill in an event-handler, namely "TForm1.FormCreate" like this:Hth
Regards Benny
I haven't got the foggiest...
But... In fpc and lazarus, if you create a class, all the memberfields are initialized to 0/nil/'' etc. in "InitInstance". If you desire a variable/memberfield to have another value on startup, you can do so in the class' constructor, usually called "Create". In TForm regi, you'd fill in an event-handler, namely "TForm1.FormCreate" like this:
- TForm1 = class(TForm)
- ...
- private
- fMemoChanges: integer; // NO '= 0;'
- ...
- end;
- implementation
- TForm1.FormCreate(Sender: TObject);
- begin
- // here fMemoChanges has been initialized to 0 beforehand...
- fMemoChanges:= 4711;
- end;
Regards Benny