Alternate version, more language specific, should be error-free and
exception free.

function convertPhonePad(str) {
alphaList="a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z";
numeralList="2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9";

return replaceList(str,alphaList,numeralList);
}


On Dec 4, 2007 12:28 PM, Jerry Johnson <[EMAIL PROTECTED]> wrote:
> Ain't good. Crude. No error handling. No exception handling. But gives
> you a starting place, maybe.
>
> <cfscript>
> function convertPhonePad(str) {
> alphaList="a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z";
> numeralList="2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9";
> numString="";
> for (i=1;i LTE len(str);i=i+1){
>         
> numString=numString&listGetAt(numeralList,listFindNoCase(alphaList,mid(str,i,1)));
> }
>
> return numString;
> }
> </cfscript>
>
> <cfoutput>#convertPhonePad("johnson")#</cfoutput>
>
>
> On Dec 4, 2007 11:04 AM, Deepak Gupta <[EMAIL PROTECTED]> wrote:
> > Hi
> >
> > Can anyone tell me or  point me to a Macro or coldfusion code to convert 
> > letters to numbers on phone keypad. For example
> >
> > ABDG will be 2234
> >
> > And this way I have a lot of Names in database and I have to pick first 4 
> > letters from the name and convert them into 4 digit codes from phone keypad.
> >
> > Thanks
> > D
> >
> > 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get involved in the latest ColdFusion discussions, product
development sharing, and articles on the Adobe Labs wiki.
http://labs/adobe.com/wiki/index.php/ColdFusion_8

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:294175
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to