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?????

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 5:44AM
    FR3 does not use fsGlobalUnit anymore. However, you can fix this by adding a
    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
    ;)

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.