Concatenation with formatting

0

I have an expression for a variable where we are concatenating a string, a double datatype parameter (entered at runtime), another string, another double datatype parameter, and a final string.  The expression is shown below:

        "(+/- " + $P{LCF} + (" Fut ~ +/- ") + $P{LCO} + " Opt)"

I would like the two parameters formatted as currency, no matter what the user enters.  So they may enter 3, or 1.5, or .4, and they should be formatted as $3.00, $1.50, $0.40 ($.40 would be acceptable).

Any recommendations?

Thank you,

M. Snyder

marlin_snyder's picture
Joined: Jan 31 2013 - 4:37pm
Last seen: 1 month 6 days ago

4 Answers:

0

Could the answer be as easy as this:

 "(+/- $" + $P{LCF} + (" Fut ~ +/- $") + $P{LCO} + " Opt)"

 

David

despec's picture
144
Joined: Jan 26 2010 - 11:45am
Last seen: 6 years 1 week ago

That kindof works David, in fact, that's how I have it set up now. The problem is that the Parameters allow for all kinds of entry, for instance, the user could enter 3, or 1.5 (for $3.00 and $1.50 respectively) and if they do that, the resulting string shows as "(+/- $3.0 Fut ~ +/- $1.5 Opt)". I can also append the second 0 at the end of the Parameter, but then if they do enter 3.00 and 1.50, or something like 1.05 it would not show correctly.

In the meantime though, thank you for the information, and we can use it until we find another solution.

marlin_snyder - 6 years 6 months ago
0

Hello, 

You can do the following: 

For each double parameter you have, create another parameter (string type). For example, if you have $P{LCF}, create a $P{LCFstring} parameter. In the parameter "Default Value" attribute set the following: new DecimalFormat ("$0.00").format($P{LCF})

Then, set the expression (+/- " + $P{LCFstring} + (" Fut ~ +/- ") + $P{LCOstring} + " Opt)

Don't know if it is the best solution but it should work.

Hope this helps. 

Regards.

Aitor

augarte's picture
531
Joined: Jan 27 2010 - 7:20am
Last seen: 1 year 4 months ago

Thank you Aitor,

This method does work (although in the ("$0.00") I did have to escape the $, so ("\$0.00")).

It accomplishes what I was trying to do dynamically, and overcomes the roadblocks I was hitting...

Sincerely,

M. Snyder

marlin_snyder - 6 years 6 months ago
0

You can also try with format mask option.

ajinkya_c's picture
976
Joined: Aug 29 2012 - 6:13am
Last seen: 2 years 5 months ago
0

Hi, Can u tell me anybody 

How to give indian currency in ad hoc view(Ex: 12,13,147.00)

 

nageshit2011's picture
Joined: Jul 22 2013 - 3:04am
Last seen: 4 years 4 months ago
Feedback
randomness