The variables scope in Application.cfc (any CFC actually) is specific to the CFC instance. It isn't accessible from outside the component.
On Thu, May 22, 2008 at 2:18 PM, Richard White <[EMAIL PROTECTED]> wrote: > hi > > i have copied this example and it all seems fine except for the line i > place within the onRequestStart method. > > if i place the line of code: > > <cfset variables.udfs = application.udfs> > > in the page itself then it works fine when i call a function, however if i > place this line of code in the onRequestStart method instead then it says > udfs is indefined > > is there any reason for this? > > thanks > > > > > >I'd say this was absolutley fine. I'd put the includes in > >OnApplicationStart and then put each udf into the application scope to > >avoid including the files on each request (well I'd actually use > >Model-Glue 3 but this is what I'd do if I was doing what you're > >doing); something like: > > > ><cffunction name="onApplicationStart"> > > ... > > <cfinclude template="theUdfs.cfm"> > > <cfinclude template="theUdfs2.cfm"> > > ... > > > > <cfset application.udfs = StructNew()> > > > > <cfset application.udfs.MyFunction1 = MyFunction1> > > <cfset application.udfs.MyFunction2 = MyFunction2> > > <cfset application.udfs.MyFunction3 = MyFunction3> > > ... > ></cffunction> > > > >Then, to avoid verbosity when calling a udf, I'd add this line in > >OnRequestStart() > > > ><cffunction name="onRequestStart"> > > ... > > <cfset variables.udfs = application.udfs> > > ... > ></cffunction> > > > >This has created a custom 'scope', if you will (its not but hey), > >called 'udfs' - Model-Glue 3 creates one called 'helpers' which might > >be another name you'd like. So now, when you need MyFunction1, you can > >call it cleanly as: > > > ><cfset foo = udfs.MyFunction1(bar)> > > > >That idea is off the top of my head and probably bonkers but it works > >for me ;) Nothing wrong with what you are doing. > > > >Dominic > > > >2008/5/19 Richard White <[EMAIL PROTECTED]>: > >> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;192386516;25150098;k Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:305926 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

