yea. just noticed that the variable: 'remaining' should be properly var'd at the top of the function though.
> -----Original Message----- > From: Matt Horn [mailto:[EMAIL PROTECTED]] > Sent: 06 December 2002 16:51 > To: [EMAIL PROTECTED] > Subject: Re: [ cf-dev ] slow friday > > > Have you tested this? > > > At 16:24 06/12/2002 +0000, you wrote: > >Its a slow friday and everything seems to be at bid stage, > so I'm trying to > >find random things to do. > > > >In so doing, I tried to create a new UDF that converts > numbers into roman > >numerals, but does it quicker than the existing UDF in cflib.org: > >RomanFormat() http://www.cflib.org/udf.cfm?ID=475 > > > >here it is, in the unlikely case that any of you should > require it (watch > >out for wrappage): > > > ><cfscript> > >/** > >* Converts a number to Roman numerals. > >* > >* @param numVar Number you want converted to Roman numerals. > >* @return Returns a string. > >* @author Rich Wild ([EMAIL PROTECTED]) > >* @version 1, December 6, 2002 > >*/ > >function numeralise(numVar) { > > var bits_a = listtoarray("M"); > > var bits_b = listtoarray("X,XX,XXX,XL,L,LX,LXX,LXXX,XC"); > > var bits_c = > >listtoarray("I,II,III,IV,V,VI,VII,VIII,IX,X,XI,XII,XIII,XIV,X > V,XVI,XVII,XVII > >I,XIX"); > > > > if (NOT isNumeric(numvar)) { > > return 'NaN'; > > } else if (NOT numvar) { > > return 'Zero'; > > } else { > > var strNum = ""; > > numvar = abs(numvar); > > var thousands = int(numvar/1000); > > if (thousands) { > > strNum = strNum & repeatstring('M', > thousands); > > } > > var remaining = numvar mod 1000; > > if (remaining) { > > var hundreds = int(remaining/100); > > > > if (hundreds) { > > if (hundreds eq 9) { > > strNum = strNum & 'CM'; > > } else { > > strNum = strNum & > repeatString('C', > >hundreds); > > } > > } > > remaining = remaining mod 100; > > > > if (NOT remaining) { > > return strNum; > > } else { > > var tens = int(remaining/10); > > > > if (tens gte 2) { > > strNum = strNum & > bits_b[tens]; > > > > remaining = > remaining mod 10; > > > > if (NOT remaining) { > > return strNum; > > } else { > > strNum = strNum & > >bits_c[remaining]; > > return strNum; > > } > > > > } else { > > strNum = strNum & > bits_c[remaining]; > > return strNum; > > } > > } > > } else { > > return strNum; > > } > > } > >} > ></cfscript> > > > > > > > > > ><cfoutput>#numeralise(1966)#</cfoutput> > > > >------------------------------------------------------- > >Rich Wild > >Senior Web Developer > > > >------------------------------------------------------- > >e-mango Tel: 01202 755 300 > >Gild House Fax: 01202 755 301 > >74 Norwich Avenue West > >Bournemouth Mailto:[EMAIL PROTECTED] > >BH2 6AW, UK http://www.e-mango.com > >------------------------------------------------------- > >This message may contain information which is legally > >privileged and/or confidential. If you are not the > >intended recipient, you are hereby notified that any > >unauthorised disclosure, copying, distribution or use > >of this information is strictly prohibited. Such > >notification notwithstanding, any comments, opinions, > >information or conclusions expressed in this message > >are those of the originator, not of e-mango.com ltd, > >unless otherwise explicitly and independently indicated > >by an authorised representative of e-mango.com ltd. > >------------------------------------------------------- > > > > > >-- > >** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ > >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >For human help, e-mail: [EMAIL PROTECTED] -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED] -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED]
