UDF = User Defined Functions with <cffunction name=""> or <cfscript> function ...
Check out cflib.org for examples (lots) including CapFirst(string) Returns the string with the first character of each word capitalized. http://www.cflib.org/udf.cfm?ID=9 Nice one RayC. WG > -----Original Message----- > From: Rahmin Pavlovic [mailto:[EMAIL PROTECTED]] > Sent: 31 January 2003 17:00 > To: CF-Talk > Subject: CF: OOP, Custom Tags.. > > > Ok - so I have several standards I use that I'd like to abstract > into a more > global format. Like, to always capitalize the first letter of a > string I use > this method frequently: > > #UCase(Left(LCase(str), 1))##Mid(LCase(str), 2, Len(LCase(str)))# > > I do LCase() the string before capitalizing the first letter, but > this is an > example of something I'd like to have automated, or in some global form. > > So my first question is: can I create my own methods in CF? > > If so that'd be hot lunch on a hot plate. In this example, I'd extend my > string object to include my own Capitalize() method, and all'd be toasty. > > In JS this'd be something along the lines of > > String.prototype.capitalize=function() { > return this.substring(0,1).toUpperCase() + > this.substring(1,this.length).toLowerCase(); > } > > Does any know if there is an OO equivalent in CF? > > So my second question is: would something like this be better accomplished > as a custom tag, and if so, is there a way to include a global library of > stuff like this? Like, if I wanted to have my custom tag available in all > sub-directories, can I point all templates to say: /cflib/Capitalize.cfm ? > > That'd be cool cause then I could just say something like > > <CF_Capitalize STRING="raHMIn"> > > or better yet > > <CF_Capitalize STRING="#str#"> > > I'm just trying to wrap my mind around the scope of this project > and part of > that is abstracting functionality like this. > > TIA for and and all tips n tricks. > > R > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4