If you declare a function in Application.cfm you are declaring it in in the
variables scope of Application.cfm, which would then be available to the
variables scope of pages called in the request.  However, CFC instances,
similar to custom tags, do not have direct access to the variables scope of
the calling page (in pre-6.1 builds there was a bug that made that statement
not quite true, but that's how it was supposed to be).

Thus, to have the function declared in your Application.cfm available to the
component instance you will need to do one of the following:

1) Put the function in a shared scope, such as
request/application/server/session.  That is not recommended, however, as it
breaks encapsulation by making the CFC dependent on the outside environment.

2) Pass the function to the CFC as an argument.  You could either do this
directly by making one of the arguments the function itself, or you could
bundle the functions you want to use "globally" into a struct (or even
another component) and pass the entire struct of functions when
instantiating your component.

3) Build that function into your component as a method.


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of tony
> Sent: Wednesday, August 20, 2003 11:14 AM
> To: [EMAIL PROTECTED]
> Subject: [CFCDev]
>
>
>
> if I have a udf in my application.cfm file, why doesn�t a cfc in
> the same dir inherit the udf function from it? or does it?
> basically i have this code....
>
> and its giving me the error that follows....>
> ==================================================
>
> Error Occurred While Processing Request
> Variable DecToBin is undefined.
>
>
> The error occurred in C:\Inetpub\wwwroot\permissions.cfc: line 16
>
> 14 :                          <!--- step 1 takes the decimal
> value of the feature Bit and using the function from above
> 15 :                          changes it to 0's and 1's in a
> binary string --->
> 16 :                                  <cfset Binary =
> #DecToBin(getBit.featureBit)#>
> 17 :                                  <!--- step 2 & 3 put commas
> in between each numeral, so that the binary string, becomes a
> list, with places that we can manipulate --->
> 18 :                                  <cfset List =
> replace(binary, '1', '1,', 'all')>
>
>
>

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

Reply via email to