Focal Point
Need easier way to add commas to an ampervar

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4421023742

September 17, 2007, 04:29 PM
cmallain
Need easier way to add commas to an ampervar
I have a dollar amt being passed as an ampervar. Is there an easy way to add commas but keep the variable as amper? I know that ampervars are considered alpha, but is there a way to cheat it into thinking that it's not?


------------------------------------------
last version used: v7.1; truly miss the wonderful things I did with WebFOCUS, HTML, & JavaScript.
September 17, 2007, 04:45 PM
Francis Mariani
-SET &NUM1 = 3493762893;
-SET &NUM1A = FTOA(&NUM1,'(D15)','A30');

-TYPE &NUM1 &NUM1A


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
September 17, 2007, 05:10 PM
cmallain
THANK YOU SO VERY MUCH FRANCIS. Can I trouble you to ask you why this works? I have been doing this language quite a long time and would've never thought to use FTOA.

Thanks,
Carol


------------------------------------------
last version used: v7.1; truly miss the wonderful things I did with WebFOCUS, HTML, & JavaScript.
September 17, 2007, 05:17 PM
cmallain
Also, one other teenie, tiny question? Is there a way to retain the decimals? My field is actually being passed as 15.3.


------------------------------------------
last version used: v7.1; truly miss the wonderful things I did with WebFOCUS, HTML, & JavaScript.
September 17, 2007, 05:32 PM
Francis Mariani
I think the reason it works is that the input to FTOA is a number, and if the amper variable passed to FTOA in DM looks like a number it's treated as a number not as alpha. Simply change D15 to D15.3 to retain the decimal places.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
September 17, 2007, 05:32 PM
Glenda
Just change the input length to reflect the decimals.

-SET &NUM1 = 3493762893.135;
-SET &NUM1A = FTOA(&NUM1,'(D15.3)','A30');
-TYPE &NUM1 &NUM1A


Glenda

In FOCUS Since 1990
Production 8.2 Windows
September 17, 2007, 05:43 PM
cmallain
THANKS!!! I thought of the 15.3 just after I submitted the post and it worked!!! Thanks again!!!


------------------------------------------
last version used: v7.1; truly miss the wonderful things I did with WebFOCUS, HTML, & JavaScript.