SIGN IN
::
SPONSORS
::
ABOUT US
::
CONTACT US
FORUMS
LIBRARY
PODCASTS
BLOGS
MAGAZINE
SERVICES
NEWSLETTERS
NEWS
STORE
EVENTS
ADOBE AFTER EFFECTS:
Forum
AE Basics
AE Expressions
Tutorials
Articles
Podcasts
Motion Graphics
Training
Cinema 4D
Re: Numbers to text...
Cow Forums
:
Adobe After Effects Expressions
VIEW POSTS
•
ADD A NEW POST
•
SEARCH
•
CHANGE FORUM
Return to Posts Index
•
Read Entire Thread
•
Reply To This Post
Re: Numbers to text...
by
Dan Ebberts
on May 8, 2008 at 8:53:49 pm
Don't say I never did anything for you. :-)
inputString = thisComp.layer("numbers").text.sourceText;
lessThanTwenty = ["zero","one","two","three","four",
"five","six","seven","eight","nine",
"ten","eleven","twelve","thirteen","fourteen",
"fifteen","sixteen","seventeen","eighteen","nineteen"];
tens = ["zero","ten","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];
groups = ["", "thousand", "million", "billion", "trillion"];
function processThreeDigits(theString, theSuffix){
s = "";
if (theString.length > 2 && parseInt(theString[0]) > 0){
s = " " + lessThanTwenty[parseInt(theString[0])] + " hundred";
}
remainder = parseInt(theString%100,10);
if (remainder > 19){
s = s + " " + tens[Math.floor(remainder/10)];
ones = remainder%10;
if (ones > 0){
s = s + " " + lessThanTwenty[ones];
}
}else if (remainder > 0){
s = s + " " + lessThanTwenty[remainder];
}
if (s.length > 0) return s + " " + theSuffix;
return s;
}
outputString = "";
tempString = inputString;
groupIdx = 0;
while (tempString.length > 0){
outputString = processThreeDigits(tempString.substr(-3),groups[groupIdx]) + outputString;
tempString = tempString.substr(0,tempString.length-3);
groupIdx++;
}
outputString
Dan
Return to Posts Index
•
Read Entire Thread
•
Reply To This Post
Current Message Thread:
Numbers to text...
by Paul Maguire on May 8, 2008 at 3:06:44 pm
Re: Numbers to text...
by Dan Ebberts on May 8, 2008 at 8:53:49 pm
Re: Numbers to text...
by Paul Maguire on May 9, 2008 at 9:50:53 am
Related Threads:
Numbers & Text
|
Text linked to scale property - Scaling by whole numbers
|
Countdown circle: "Numbers" connected with Text/path: anoying decimals
|
text>numbers>date in CAPITALS?
|
Numbers or text expression with a ,
|
increasing numbers in text
Note:
If you are a registered user and you
do not
see your name and email in the two respective fields above, you may reset your account cookies by clicking
here
. Your post
will not be accepted
if the name and email provided above are not currently registered in our database.
Name
E-Mail Address
Subject
E-Mail me when someone responds
Just This Message
Entire Thread
None
Message
Note:
The following characters are HTML command characters, and may cause parts of your post to disappear, if not used correctly: < > &. To include any portion of the post in your response, highlight the desired text and hit the "Q" key. For more on how to post,
click here
.
Add your message signature
Note:
By clicking "Post Direct" button above, you are agreeing to the Creative Cow's
Code of Conduct
.
FORUMS
•
LIBRARY
•
PODCASTS
•
BLOGS
•
MAGAZINE
•
SERVICES
•
NEWSLETTERS
•
NEWS
•
STORE
•
EVENTS
©
CreativeCOW.net
All rights are reserved.
[
Top
]