If I have option values I do this function bob(required) { var optional = ''; if (arraylen(arguments) EQ 2) optional = arguments[2]; ....... }
I think you will find this common practice if you look trhough a good chunk of the UDFs on cflib.org. Adam H On Wed, 2 Mar 2005 23:20:25 -0600, Jared Rypka-Hauer - CMG, LLC <[EMAIL PROTECTED]> wrote: > This also works: > > test.cfc > ----------------- > <cfcomponent> > <cfscript> > function getCGI(cV) { > try { > return cgi[cV]; > } > catch (any cfScriptError) { > return cgi; > } > } > </cfscript> > </cfcomponent> > > temp.cfm > -------------------- > <cfdump var="#createObject('component','test').getCGI('server_name')#" /> > <cfdump var="#createObject('component','test').getCGI('')#" /> > > The first one outputs "w2ksrv1" which is the server name of my dev box. > > The second one does a cfdump of the CGI struct. > > I was messing around with using various if statements to detect cV, > and the try/catch worked immediately. structKeyExists always > recognized that cV existed, even when it wasn't passed in. len(cV) > threw an error because it tried to access a variable that hadn't been > set. I haven't worked with function definitions in cfscript enough to > be sure exactly the best way to declare a default value for one... > but that snippet ran just fine. > > Laterz, > J > > On Wed, 2 Mar 2005 14:56:18 -0700, Paul <[EMAIL PROTECTED]> wrote: > > This must be easier than I'm making it this afternoon. > > > > All the UDFs from cflib.org are written in cfscript. Is there a way to > > store them in a CFC, say Util.cfc, and then call them from another CFC? > > When I attempt to do so CF can't find the function. I experimented and > > wrapped the cfscript inside a cffunction definition and now CF apparently > > can't see the arguments I'm passing in. > > > > So, how does one call cfscript-based functions from within a CFC? > > > > -paul > > > > http://www.houseoffusion.com/banners/view.cfm?bannerid=48 > > Donations & Support: http://www.houseoffusion.com/tiny.cfm/54 > > > > -- > Continuum Media Group LLC > Burnsville, MN 55337 > http://www.web-relevant.com > http://cfobjective.neo.servequake.com > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:197303 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54