I just created a unit containing a class ("object") with Procedures and Functions meant to be called from outside.
Ie..
Unit MyUnit;
{$MODE OBJFPC} {$H+}
interface
type
TMyClass = class
Private
procedure CreateKey();
function Do():Boolean;
var Var1:String;
public
procedure Initialize(aPassword:string);
procedure Set(aVar:String)
function Get():String;
end;
MyClass1 = type TMyClass;
implementation
...
And, I found that when I need to use the functions/procedures in another unit..
Ie..
..
MyClass1.Initialize('MyPassword');
..
I get errors like
"Only class methods, class properties and class variables can be accessed (or referenced) in class methods"
The only way I found to correct this is to define
every Procedure, Function (Public or Private) and Variable inside MyClass as a "class"
Ie..
type
TMyClass = class
Private
Class procedure CreateKey();
Class function Do():Boolean;
Class var Var1:String;
public
Class procedure Initialize(aPassword:string);
Class procedure Set(aVar:String)
Class function Get():String;
end;
MyClass1 = type TMyClass;
implementation
...
I searched but could not find why these procedures, functions and variables need to be defined as classes themselves. Documentation on creating units with classes do not mention this requirement. Should I be doing this differently?