AddClass Method
I'm trying to Add a Class called TesgReportsList which is a DataSet and ClientDataSet that I built.
This is what I'm doing:
procedure TdtmRelatorios.DataModuleCreate(Sender: TObject);
var
GlobalScriptObj : TfsScript;
esgReportList : TfsClassVariable;
begin
inherited;
esgReportList := GlobalScriptObj.AddClass(TesgReportsList, 'TsgEntidade');
esgReportList.AddProperty('RecordCount', 'Integer', GetProp, nil);
esgReportList.AddMethod('procedure Append', CallMethod);
end;
function TdtmRelatorios.GetProp(Instance: TObject; ClassType: TClass;
const PropName: String): Variant;
begin
Result := 0;
if ClassType = TesgReportsList then
begin
if PropName = 'RECORDCOUNT' then
Result := TesgReportsList(Instance).RecordCount;
end
end;
function TdtmRelatorios.CallMethod(Instance: TObject; ClassType: TClass;
const MethodName: String; var Params: Variant): Variant;
var
_TesgReportsList : TesgReportsList;
begin
Result := 0;
if ClassType = TesgReportsList then
begin
_TesgReportsList := TesgReportsList(Instance);
if MethodName = 'Append' then
_TesgReportsList.Append
end
end;
Then whenever I try to use the TesgReportsList at my Fast-Reports Script it keeps showing me a "EAccess Violation" exception!!
What am I doing wrong?????
This is what I'm doing:
procedure TdtmRelatorios.DataModuleCreate(Sender: TObject);
var
GlobalScriptObj : TfsScript;
esgReportList : TfsClassVariable;
begin
inherited;
esgReportList := GlobalScriptObj.AddClass(TesgReportsList, 'TsgEntidade');
esgReportList.AddProperty('RecordCount', 'Integer', GetProp, nil);
esgReportList.AddMethod('procedure Append', CallMethod);
end;
function TdtmRelatorios.GetProp(Instance: TObject; ClassType: TClass;
const PropName: String): Variant;
begin
Result := 0;
if ClassType = TesgReportsList then
begin
if PropName = 'RECORDCOUNT' then
Result := TesgReportsList(Instance).RecordCount;
end
end;
function TdtmRelatorios.CallMethod(Instance: TObject; ClassType: TClass;
const MethodName: String; var Params: Variant): Variant;
var
_TesgReportsList : TesgReportsList;
begin
Result := 0;
if ClassType = TesgReportsList then
begin
_TesgReportsList := TesgReportsList(Instance);
if MethodName = 'Append' then
_TesgReportsList.Append
end
end;
Then whenever I try to use the TesgReportsList at my Fast-Reports Script it keeps showing me a "EAccess Violation" exception!!
What am I doing wrong?????
Comments
code:
frxReport1.Script.Parent := fsGlobalUnit
or register a function by TfrxReport.AddFunction method.
Just look in
\Extra\New DB engine\Template\frxXXXRTTI.pas
there is sample code how to do it in the new way