Skip to main content
Participant
February 6, 2023
Question

Help combining 2 expressions – number counter with point controll + font change

  • February 6, 2023
  • 1 reply
  • 345 views

Hi,

I'm trying to combine these two expressions, one cancels out the other...

can anybody please help me out?

 

// 1st expression for changing the font
var fontArray=[
"BerninaSansOffc-Regular",
"DTFlowTextV1.011-Regular"
]
v=Math.round(thisComp.layer("Null 19").effect("Font CTRL")("Slider"))
style.setFont(fontArray[v]);


// 2nd expression counter for numbers greater than 1 mil. with point control
num = (thisComp.layer("Null 19").effect(1)(1)[0]).toFixed(2);
function addCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",");
}
addCommas(num)

 

This topic has been closed for replies.

1 reply

Dan Ebberts
Community Expert
Community Expert
February 6, 2023

I haven't tested this, but you should be able to rearrange it slightly, like this:

num = (thisComp.layer("Null 19").effect(1)(1)[0]).toFixed(2);
function addCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",");
}
txt = addCommas(num);

var fontArray=[
"BerninaSansOffc-Regular",
"DTFlowTextV1.011-Regular"
]
v=Math.round(thisComp.layer("Null 19").effect("Font CTRL")("Slider"))
style.setFont(fontArray[v]).setText(txt);
Participant
February 7, 2023

thank you so much @Dan Ebberts  that works perfect!