There is no built-in feature to make these calculations in ReportBuilder. You will need to make them manually using TppVariable components and their OnCalc events. Use the Timing property to determine when the event fires and the Reset property to determine when the value should be reset.
OK. Got the main RAP Demo to work. I am looking at Calculations Level 1 - Retrieve Field Value.
Value := plStock['Cur_Price'];
Now what I would need to do is Create a dynamic array with one value for each record in the table, sort that array and then calculate the median for that.
I don't see dynamic arrays in the Variable types under the language section so I am assuming this will not be possible.
What I assume I will have to do is create a function in my Delphi code, register it as a user function and pass the data set in.
e.g. function CalculateFieldMedian(ADateSet: TDataset; AFieldName: String): Double;
and call it like so: CalculateFieldMedian(plStock, 'Cur_Price');
1) What is plStock? A TDataset, TppDataPipeline? 2) Can it be passed into a user function as a variable? 3) What are the methods to iterate it's records and extract the field value for each one?
Are you perhaps altering the dataset in your Median routine? If so you need to remember that ReportBuilder is also trying to access this dataset so altering it can cause the report engine to malfunction.
Comments
There is no built-in feature to make these calculations in ReportBuilder.
You will need to make them manually using TppVariable components and their
OnCalc events. Use the Timing property to determine when the event fires
and the Reset property to determine when the value should be reset.
http://www.digital-metaphors.com/rbWiki/Delphi_Code/Calculations/Overview
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
can't get to c:\PDOXUSRS.NET
- Retrieve Field Value.
Value := plStock['Cur_Price'];
Now what I would need to do is Create a dynamic array with one value for
each record in the table, sort that array and then calculate the median
for that.
I don't see dynamic arrays in the Variable types under the language
section so I am assuming this will not be possible.
What I assume I will have to do is create a function in my Delphi code,
register it as a user function and pass the data set in.
e.g. function CalculateFieldMedian(ADateSet: TDataset; AFieldName:
String): Double;
and call it like so: CalculateFieldMedian(plStock, 'Cur_Price');
1) What is plStock? A TDataset, TppDataPipeline?
2) Can it be passed into a user function as a variable?
3) What are the methods to iterate it's records and extract the field
value for each one?
function GetFieldMedian(ADataSet: TDataSet; AFieldName: String): Double;
Using the RAP Demo I create a second variable call it like so:
Value := GetFieldMedian(plStock.DataSource.DataSet, 'Cur_Price');
Trouble is only one row of the DataSet shows on the report. If I don't
call the median function they all show.
Are you perhaps altering the dataset in your Median routine? If so you need
to remember that ReportBuilder is also trying to access this dataset so
altering it can cause the report engine to malfunction.
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com