Hi
Is there any shorter way to use a comma separator for Indian Number system?
its like ##,##,##,##,###.##. I have written the following code but its quite lengthy...
function comma{
if(length <= 3 ){ n = n}else
if(length == 4 ){ n = substr(n,1,1)","substr(n,2)}else
if(length == 5 ){ n = substr(n,1,2)","substr(n,3)}else
if(length == 6 ){ n = substr(n,1,1)","substr(n,2,2)","substr(n,4)}else
if(length == 7 ){ n = substr(n,1,2)","substr(n,3,2)","substr(n,5)}else
if(length == 8 ){ n = substr(n,1,1)","substr(n,2,2)","substr(n,4,2)","substr(n,6)}else
if(length == 9 ){ n = substr(n,1,2)","substr(n,3,2)","substr(n,5,2)","substr(n,7)}else
if(length == 10){ n = substr(n,1,1)","substr(n,2,2)","substr(n,4,2)","substr(n,6,2)","substr(n,8)}else
if(length == 11){ n = substr(n,1,2)","substr(n,3,2)","substr(n,5,2)","substr(n,7,2)","substr(n,9)}else
if(length == 12){ n = substr(n,1,1)","substr(n,2,2)","substr(n,4,2)","substr(n,6,2)","substr(n,8,2)","substr(n,10)}else
if(length == 13){ n = substr(n,1,2)","substr(n,3,2)","substr(n,5,2)","substr(n,7,2)","substr(n,9,2)","substr(n,11)}else
n=n
return
Thank you.
Is there any shorter way to use a comma separator for Indian Number system?
its like ##,##,##,##,###.##. I have written the following code but its quite lengthy...
function comma{
if(length <= 3 ){ n = n}else
if(length == 4 ){ n = substr(n,1,1)","substr(n,2)}else
if(length == 5 ){ n = substr(n,1,2)","substr(n,3)}else
if(length == 6 ){ n = substr(n,1,1)","substr(n,2,2)","substr(n,4)}else
if(length == 7 ){ n = substr(n,1,2)","substr(n,3,2)","substr(n,5)}else
if(length == 8 ){ n = substr(n,1,1)","substr(n,2,2)","substr(n,4,2)","substr(n,6)}else
if(length == 9 ){ n = substr(n,1,2)","substr(n,3,2)","substr(n,5,2)","substr(n,7)}else
if(length == 10){ n = substr(n,1,1)","substr(n,2,2)","substr(n,4,2)","substr(n,6,2)","substr(n,8)}else
if(length == 11){ n = substr(n,1,2)","substr(n,3,2)","substr(n,5,2)","substr(n,7,2)","substr(n,9)}else
if(length == 12){ n = substr(n,1,1)","substr(n,2,2)","substr(n,4,2)","substr(n,6,2)","substr(n,8,2)","substr(n,10)}else
if(length == 13){ n = substr(n,1,2)","substr(n,3,2)","substr(n,5,2)","substr(n,7,2)","substr(n,9,2)","substr(n,11)}else
n=n
return
Thank you.