Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects numbers counting up in parenthesis (expression)

  • numbers counting up in parenthesis (expression)

    Posted by Jacques Levet on March 7, 2012 at 6:06 pm

    Hello everybody
    i m currently using an expression to have a percentage count up to a specific number. I ve got that part figured out, but i would like the percentage amount to be in between parenthesis like this : (5.07%)
    here is the expression i m using. If anyone knows how i can alter it to fit my needs, that would be great.
    Thanks in advance

    numDecimals = 2;
    commas = true;
    dollarSign = true;
    beginCount = 0
    endCount = 5.03
    dur = 4;

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

    suffix = “”;
    if (s[0] == “-“){
    prefix = “-“;
    s = s.substr(1);
    }
    if(dollarSign) suffix += “%”;

    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);
    }
    outStr + decimals + suffix ;
    }else{
    s + suffix;
    }

    Jacques Levet replied 5 years, 10 months ago 3 Members · 3 Replies
  • 3 Replies
  • David Ghast

    March 7, 2012 at 11:00 pm

    Well if no one can decipher that…arent expressions just java or something? You could try to ask over at devshed.

  • John Cuevas

    March 8, 2012 at 12:15 am

    numDecimals = 2;
    commas = true;
    dollarSign = true;
    beginCount = 0
    endCount = 5.03
    dur = 4;

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

    suffix = “”;
    if (s[0] == “-“){
    prefix = “-“;
    s = s.substr(1);
    }
    if(dollarSign) suffix += “%)”;

    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);
    }
    “(” + outStr + decimals + suffix ;
    }else{
    “(” + s + suffix;
    }

    Johnny Cuevas, Editor
    Thinkck.com

    “I have not failed 700 times. I have succeeded in proving that those 700 ways will not work. When I have eliminated the ways that will not work, I will find the way that will work.”
    —THOMAS EDISON on inventing the light bulb.

  • Jacques Levet

    July 7, 2020 at 2:29 am

    Thank you!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy