A few comments here:

*Typically i make my init function public so I can call it directly.
This lets me do this in code:

<cfset mycfc = createObject("component","mycfc").init(arg1, arg2, arg3)>

You need to make your method do a <cfreturn this> for it to work right.

*Your init function didn't have an argument to it. Therefore, it is
kinda pointless. You can replace all of that code with just:

<cfset variables.dsn = "....">

However, your best bet is to make the init function take an argument
so you can customize the DSN on the fly. You can still use the line
above (with a real value instead of three dots of course ;) so that
the CFC has a default DSN at least.

*And yes, if you want a variable to availavble to all methods of a
CFC, use the Variables scope.



On Tue, 28 Dec 2004 11:39:22 -0500, Jeff Small <[EMAIL PROTECTED]> wrote:
> <cfset init()>
> 
> <cffunction name="init" access="private" output="false" returntype="string"
> displayname="Initializes my object and creates the datasource variable">
>     <cfset variables.DSN = "myDataSourceName">
>     <cfreturn variables.DSN>
> </cffunction>
> 
> I know I could make it so that you have to pass the datasource variable name
> in to the function, but I figured, I can always just change it in one place
> in my CFC, and it's good to go...right?
> 
> That should suit my needs, right? If I want a variable that's available to
> all the functions in my CFC...right? Am I thinking the "right way"?
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Silver Sponsor - New Atlanta
http://www.newatlanta.com

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:188868
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

Reply via email to