Oops... I made a mess of it the first time around... (blushing)
on mouseUp
put ("one","two","three","four","five","six","seven","eight","nine") into
singles
put
("eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen")
into mixed
put
("ten","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety")
into tens
put the number of chars of fld 1 into charcount
switch charcount
case 1
if char 1 of fld 1 = 0 then
put "Zero" into theTextNumber
else
put item (char charcount of fld 1) of singles into theTextNumber
end if
break
case 2
if char 1 of fld 1 = 1 AND char 2 of fld 1 = 0 then
put "Ten" into theTextNumber
exit switch
end if
if char 1 of fld 1 = 1 AND char 2 of fld 1 > 0 then
put item (char 2 of fld 1) of mixed into theTextNumber
exit switch
end if
if char 1 of fld 1 > 1 AND char 2 of fld 1 = 0 then
put item (char 1 of fld 1) of tens into theTextNumber
exit switch
end if
if char 1 of fld 1 > 1 AND char 2 of fld 1 > 0 then
put item (char 1 of fld 1) of tens && item (char 2 of fld 1) of
singles into theTextNumber
exit switch
end if
break
case 3
if char 2 of fld 1 = 0 AND char 3 of fld 1 = 0 then
put item (char 1 of fld 1) of singles && "hundred" into
theTextNumber
exit switch
end if
if char 2 of fld 1 = 0 AND char 3 of fld 1 > 0 then
put item (char 1 of fld 1) of singles && "hundred and" && item
(char 3 of fld 1) of singles into theTextNumber
exit switch
end if
if char 2 of fld 1 > 0 AND char 3 of fld 1 = 0 then
put item (char 1 of fld 1) of singles && "hundred and" && item
(char 2 of fld 1) of tens && item (char 3 of fld 1) of singles into
theTextNumber
exit switch
end if
if char 2 of fld 1 > 0 AND char 3 of fld 1 > 1 then
put item (char 1 of fld 1) of singles && "hundred and" && item
(char 2 of fld 1) of tens && item (char 3 of fld 1) of singles into
theTextNumber
exit switch
end if
if char 2 of fld 1 > 0 AND char 3 of fld 1 > 0 then
put item (char 1 of fld 1) of singles && "hundred and" && item
(char 3 of fld 1) of mixed into theTextNumber
exit switch
end if
break
end switch
put theTextNumber into fld 2
end mouseUp
That should go up to 999...
> Date: Wed, 8 Dec 2010 17:30:23 -0500
> Subject: Number to text
> From: [email protected]
> To: [email protected]
>
> Hi any Idea on how to go about calculating numbers to text eg. 100, One
> Hundred, ?
> Thanks, Hershel
> _______________________________________________
> use-livecode mailing list
> [email protected]
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode