TOPIC: Display function results in a Report
#993
Display function results in a Report 2 Years, 12 Months ago
How do you display a string returned from a function in a report?

Code:


#(Text, mileagereport()),



I get the message can't convert object to number


Heres my report

Code:


#(Params
header: #( Text data:"Journeys" justify: "center"') #(Hline)
title: "Journeys",
name: 'Journeys'
summarize_by: "totalmiles"
QueryFormat
{
Query: "unpayedjourneys"
Total: ("totalmiles"')
Output:
#(Row journeydate, from, to, totalmiles , journeyreason)
After: (_output totalmiles: (Total total_totalmiles))
}
#(Hline),
#(Text, mileagereport()),
#(Hline),
#(Text, "Name:"'),
#(Hline),
#(Text, "Signed: "'),
#(Hline),
#(Text, "Date Refunded: "'),
#(Hline)
)



This is the only brick wall I've hit so far.
 
 
#995
Re:Display function results in a Report 2 Years, 12 Months ago
The problem is that #(...) is a "constant" - it can only contain literal values, not function calls or other expressions.

To contain non-literal values you use Object(...) but this itself is an expression and so cannot be contained in the constant #(Params ...)

One option is to convert #(Params ...) to Object('Params' ...) but then you have to wrap it in function () { ... } in order to put it in a library (because library records can only be constants).

A better option is to make your own format. This is easier than it sounds. Replace #(Text mileagereport()) with #(Mileagereport) and then define MileagereportFormat as:

Code:

TextFormat
    {
    New()
        {
        super(Mileagereport())
        }
    }



WARNING: I have not tested this.
 
 
andrew
 
#996
Re:Display function results in a Report 2 Years, 12 Months ago
Yes that was spot on.

Cheers