-
Numbers Expression Replace commas with a space….
Hey folks see below is an expression I have for a counter which works perfectly, However I would like to replace the commas with a space if possible as this is a request for reversioning into a different language can someone point me in the direction of how to do this,
would it be in the commas not requested section…..
Thank you so much.
Regards Chossy.
num = thisComp.layer("Controls").effect("number")("Slider")*100000;
amtOfDec = thisComp.layer("Controls").effect("amt_of_decimals")("Slider");
commas = thisComp.layer("Controls").effect("use_commas")("Checkbox");
//--
num = num + 0;
amtOfDec = amtOfDec + 0;
commas = commas == 1;//--
if(! commas){//commas not requested
num.toFixed( amtOfDec );}else{
//commas requested
//This function takes a positive whole number as a string
//and adds commas to itfunction addCommas( str ){
finalResult = "";
for( i = str.length - 1; i >= 0; i-- ){
finalResult = str.charAt( i ) + finalResult;
if( (str.length - i) % 3 == 0 && i != 0 )
finalResult = "," + finalResult;
}
return finalResult;
}//--
intPart = Math.floor( Math.abs( num ) );
decPart = Math.abs(num) - intPart;
wasNeg = num < 0;
result = "";
if( wasNeg )
result = "–" + result;
intPartString = intPart + "";
decPartString = decPart.toFixed( amtOfDec ) + "";
decPartString = decPartString.substring( 1 );
result = result + addCommas( intPartString ) + decPartString;
result
}The last true family man