This method invocation method is allowed only for class method methods.

I keep getting this error. On FGetZoneData , I have:

 var SelectedDept: String; implementation procedure TFGetZoneDept.GetClick1(Sender: TObject); var azone: string; adept: string; bstats, bname, btop, bleft, bnumber, basset: string; machine : TMachine; begin fdb.count := 0; //keeps track of number of machines in zone azone := Combobox1.Text; //gets name of zone adept := TfDB.GetDeptDBName(SelectedDept); //gets name of dept from a function fdeptlayout.ListBox1.Clear; end; 

and TFdB I have a function declared publicly:

 public Function GetDeptDBName(name :string):String; end; 

Any idea why this won't work?

+6
source share
1 answer

You are calling a method in a class (I assume that TfDB is the name of the class) and not on the instance. Only class methods can be called this way. You need to instantiate and then call the method on it:

 var DB: TfDB; begin DB := TfDB.Create(); // create an instance adept := DB.GetDeptDBName(SelectedDept); // call the method 

See E2076 . This form of method invocation is permitted only for class methods in docwiki.

+12
source

All Articles