Decimal Problem
Hi,
We are registered users of fast report. We have a very specific requirement. The application that we are developing is used in 2 countries. One country has 3 decimals(eg. 1000.000) in its currency while the other has 2 (eg. 1000.00).
We are using a common frf for both countries. What we require is when the report prints in one country, it should come with 3 decimals while it should come with 2 decimal in the other country. All functions on amounts like SUM, AVG etc should also work correctly. We will be using same Application and frf for both countries. In the application however we will know what the numbers of decimals are.
Any suggestions on this are welcome.
We are registered users of fast report. We have a very specific requirement. The application that we are developing is used in 2 countries. One country has 3 decimals(eg. 1000.000) in its currency while the other has 2 (eg. 1000.00).
We are using a common frf for both countries. What we require is when the report prints in one country, it should come with 3 decimals while it should come with 2 decimal in the other country. All functions on amounts like SUM, AVG etc should also work correctly. We will be using same Application and frf for both countries. In the application however we will know what the numbers of decimals are.
Any suggestions on this are welcome.
Comments
You can use a delphi variable or a Tfield to pass FR the decimals value, then in script code in all the bands that you need(details, totals, ...) you must to code some thing like:
if [DECIMALVAR] = 2 then
memoX.memo.text := formatfloat ('#,##0.00', Tablex.'NUMBER')
else
memoX.memo.text := formatfloat ('#,##0.000', Tablex.'NUMBER')
I hope help you.
S.Barco
1.
Don't use construction:
if ([datam.cds."FLOATVAR"] <> null) then // wrong code
use this code:
if not FieldIsNull('datam.cds."FLOATVAR"') then // right code
2. Try to use Memo.DisplayFormat property for float formatting, then
Memo.DisplaFormat := FormatFloat......
I hope that's help you, now I'am going to try too.
S.Barco
I know it's been a while since you posted your question about the DisplayFormat but I had the same question and received an answer that I am pretty sure will work for you as well.
See the 'DisplayFormat at run time' topic posted today (Jan 6, 2004) for the answer.
Kindest regards.
I have the same situation and I solved it on the DB-level. I use FireBird server and there is some stored procedure that will produce the desired output for me based on the selected currency's decimals. There is a currency table where the decimal places are stored for every currency. The procedure only receive the currency code and it does the work. Note that my procedure gives back the values in float format and also in CHAR format and there is no need of formatting inside the FR memos.
Regards:Alex