Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Need help with commas in numbers

New Here ,
Aug 13, 2021 Aug 13, 2021

I am a total novice but making a counter. It is counting from $10,000 up to $1,000,000. I have it counting just like I want, but I need to add commas to the number. What can I add to this code to make commas show up? 

I have this code in the expression 

 

"$"+effect("Slider Control")("Slider").value.toFixed(0)

 

Thank you! 

TOPICS
Expressions
949
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 13, 2021 Aug 13, 2021

Hi marciej79878702,

 

Thanks for writing in.

Here's a similar discussion with a correct answer: https://community.adobe.com/t5/after-effects/putting-a-comma-in-an-after-effects-counter/m-p/1031788... 

Hope it helps.

 

Thanks,

Nishu

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 13, 2021 Aug 13, 2021

try this expression, you should change the value from the expression it self or you can create a slider control if you want 

 

commas = true ;
numDecimals = 0;
dollarSign = true;
beginCount = 100;
endCount = 3000;
dur = 3;

t = time - inPoint;
s = linear(t, 0, dur, beginCount, endCount).toFixed(numDecimals);

prefix = "";
if(s[0] == "-"){
prefix = "-";
s = s.substr(1);
}
if(dollarSign) prefix += text.sourceText;

if(commas){
decimals = "";
if(numDecimals > 0){
decimals = s.substr(-(numDecimals + 1));
s = s.substr(0,s.length -(numDecimals + 1));
}
outStr = s.substr(-s.length,(s.length-1)%3 +1);
for(i = Math.floor((s.length-1)/3); i > 0; i--){
outStr += "," + s.substr(-i*3,3);
}
prefix + outStr + decimals;
}else{
prefix + s;
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 14, 2021 Aug 14, 2021

Dan Ebberts has published a universal counter that does everything you want it to do. 

 

Find it here: Dan Ebberts Universal Counter.

 

That is where OussK's answer came from. Dan is one of, if not the best resources for expressions.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2021 Aug 14, 2021

This works and previews correctly but when I export it, it is not correct and shows just the layer name as still instead of the counting numbers. Have you seen this before? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 14, 2021 Aug 14, 2021

Try to post some screenshots 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 14, 2021 Aug 14, 2021
LATEST

Without any info about your actual render process nobody can tell you much. If you render via AME start by rendering directly from AE instead to prevent issues with expressions not evaluating correctly. Everything else will require more information.

 

Mylenium

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines