Convert a value to a string

Moderators: Disciple, zlovatt

Post Reply
byronnash
Posts: 321
Joined: July 7th, 2004, 2:30 pm
Location: Charlotte, NC
Contact:

I have an expression slider that generates a number up to 3 digits long. I need to separate each number for each place(hundreds, tens, ones). I tried using the toString() method to convert it to a string and then use slice() or something like that to pull out each specific number from the string. It doesn't seem to be converting the number to a readable string. It seems to return "[Object Property]". How can I accomplish this with expressions? Maybe there is another way I can approach it?
byronnash
Posts: 321
Joined: July 7th, 2004, 2:30 pm
Location: Charlotte, NC
Contact:

So this is what I have working right now. It seems like a whole lot of code to pull the numbers out. I have this expression on a text layer's "source text" value for debugging right now.

Code: Select all

val = thisComp.layer("Null 1").effect("Number")("Slider");
one = (Math.floor(val / 100));

if (val>100){
	two = Math.floor(val / 10)-10;
}else{
	two = Math.floor(val / 10);
}

if (val>100){
subV = 	Math.floor(val / 10)*10;
three =  val - subV;
}else{
subV = 	Math.floor(val / 10)*10;
three  = val - subV;
}

endS =  one + "   1st Digit \r" + two + "   2nd Digit \r" + three + "   3rd Digit \r"; 
endS
Post Reply