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

Need Help to Add Comma in expression

New Here ,
Feb 14, 2023 Feb 14, 2023

Copy link to clipboard

Copied

Hi all...I am using an old template and have no exprience in writing expressions. I just want to know how to and a comma to the output. Here is the script...

 

numDecimals = 0; beginCount = 50; endCount =105515; dur =0.7; t = time - inPoint; s = linear (t, 0, dur, beginCount, endCount).toFixed(numDecimals); prefix = ""; if (s[0] == "-"){ prefix = "-"; 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; }

 

Any help would be great.

 

TOPICS
Expressions

Views

344

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Feb 14, 2023 Feb 14, 2023

Try this version:

numDecimals = 0;
commas = true;
dollarSign = false;
beginCount = 50;
endCount = 105515;
dur = 0.7;

t = time - inPoint;
s = linear (t, 0, dur, beginCount, endCount).toFixed(numDecimals);
 
prefix = "";
if (s[0] == "-"){
  prefix = "-";
  s = s.substr(1);
}
if(dollarSign) prefix += "$";
 
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
...

Votes

Translate

Translate
Community Expert ,
Feb 14, 2023 Feb 14, 2023

Copy link to clipboard

Copied

Try this version:

numDecimals = 0;
commas = true;
dollarSign = false;
beginCount = 50;
endCount = 105515;
dur = 0.7;

t = time - inPoint;
s = linear (t, 0, dur, beginCount, endCount).toFixed(numDecimals);
 
prefix = "";
if (s[0] == "-"){
  prefix = "-";
  s = s.substr(1);
}
if(dollarSign) prefix += "$";
 
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;
}

Votes

Translate

Translate

Report

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 ,
Feb 14, 2023 Feb 14, 2023

Copy link to clipboard

Copied

LATEST

Thank you such much. Designing, yes. Coding, nope.

Votes

Translate

Translate

Report

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