The "Owner" of a RAP function
Is there any way of getting a reference to the report that is
compiling/running a RAP function from within it's implementation?
For instance, I have the following RAP function:
{------------------------------------------------------------------------------}
{ TmfGetSomePropertyFunction.ExecuteFunction}
procedure TmfGetSomePropertyFunction.ExecuteFunction(aParams: TraParamList);
var
lsString: string;
lResult: Variant;
begin
GetParamValue(0, lsString);
// Return the property that the user requested
lResult := myDataModule.SomeProperty;
SetParamValue(1, lResult);
end;{ procedure, ExecuteFunction }
myDataModule contains the report which is compiling/running the events
that use the function TmfGetSomePropertyFunction. I actually want to
reference a method/property of this data module (and I can't simply add
it to the uses clause, because there may be multiple instances of this
datamodule running in the application at any one time). If I could get
at a reference for the report component, then I could use the owner
property of this.
Any ideas?
Best Regards,
James Crosswell
Software Engineer
Microforge.net Limited
http://www.microforge.net
compiling/running a RAP function from within it's implementation?
For instance, I have the following RAP function:
{------------------------------------------------------------------------------}
{ TmfGetSomePropertyFunction.ExecuteFunction}
procedure TmfGetSomePropertyFunction.ExecuteFunction(aParams: TraParamList);
var
lsString: string;
lResult: Variant;
begin
GetParamValue(0, lsString);
// Return the property that the user requested
lResult := myDataModule.SomeProperty;
SetParamValue(1, lResult);
end;{ procedure, ExecuteFunction }
myDataModule contains the report which is compiling/running the events
that use the function TmfGetSomePropertyFunction. I actually want to
reference a method/property of this data module (and I can't simply add
it to the uses clause, because there may be multiple instances of this
datamodule running in the application at any one time). If I could get
at a reference for the report component, then I could use the owner
property of this.
Any ideas?
Best Regards,
James Crosswell
Software Engineer
Microforge.net Limited
http://www.microforge.net
This discussion has been closed.
Comments
my solution was to pass the report itself always as first parameter.
HTH,
Chris Ueberall;
Hmmm - well I tried this. I have two applications using this data
module, one is a window application (that I'm using to design the
reports) and which only ever has one instance or the datamodule
containing the report which uses this RAP function. If I preview the
report in this application, then the RAP works fine.
The other application is an ISAPI - which creates an instance of the
data module for each request made for the report, and in this one, the
Report parameter is always nil - so of course I get an error??? No idea
why this would be.
Best Regards,
James Crosswell
Software Engineer
Microforge.net Limited
http://www.microforge.net
PS: The function now reads as follows...
{------------------------------------------------------------------------------}
{ TmfGetUserPropertyFunction.ExecuteFunction}
procedure TmfGetUserPropertyFunction.ExecuteFunction(aParams: TraParamList);
var
lsString: string;
ppReport: TppReport;
lResult: Variant;
begin
GetParamValue(0, ppReport);
GetParamValue(1, lsString);
// Return the property that the user requested
lResult :=
TdmReportForge(ppReport.Owner).CurrentUser.GetFieldValue(lsString);
SetParamValue(2, lResult);
end;{ procedure, ExecuteFunction }
so of course I get an error??? No idea
I tell a lie - I had an error in the code for the ISAPI. The method that
you suggested works perfectly. Thanks Chris!
Best Regards,
James Crosswell
Software Engineer
Microforge.net Limited
http://www.microforge.net