Two problems I see in your code.
1) Konv is declared as a function while the OngetText events expects a procedure.
2) It is not a method of an object.
Using your code from your first post here are the modifications.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, db, dbf, FileUtil, Forms, Controls, Graphics, Dialogs,
DBGrids, DbCtrls, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Datasource1: TDatasource;
Dbf1: TDbf;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
Label1: TLabel;
procedure Dbf1AfterOpen(DataSet: TDataSet);
procedure DBGrid1GetCellHint(Sender: TObject; Column: TColumn;
var AText: String);
private
{ private declarations }
public
{ public declarations }
Procedure Convert(Sender:Tfield; var aText:String; DisplayText: Boolean);
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
//type
//Tmethod = procedure() of object;
Procedure Konv(Sender:Tfield; var aText:String; DisplayText: Boolean = true);
begin
//aText:=Trim(Sender.AsString);
aText:=Utf8ToAnsi(Sender.AsString);
end;
procedure TForm1.Dbf1AfterOpen(DataSet: TDataSet);
var i:integer;
aText: String;
// var m:Tmethod;
begin
For i:=0 to Dbf1.FieldCount-1 do
If Dbf1.Fields[i].DataType=ftString then
//label1.caption:=label1.caption+'s';
Dbf1.Fields[i].OnGetText:=@Convert;
end;
end.
Procedure TForm1.Convert(Sender:Tfield; var aText:String; DisplayText: Boolean);
begin
if DisplayText then
aText:=Utf8ToAnsi(Sender.AsString)
else
aText := Sender.AsString;
end;