RE: UDF in Component?

2004-05-07 Thread Raymond Camden
You can place a UDF in the component, but it will be treated like a method.
Tell me - how are you calling the function?
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: UDF in Component?

2004-05-07 Thread Ian Skinner
I would guess you would need to take the code from the UDF and make it a method of the Component.Should be fairly straight forward, but I've never tried it.
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: UDF in Component?

2004-05-07 Thread Burns, John D
My code looks like this (simplified version):

cfcomponent
	cffunction name=addEmail access=remote returntype=string
		cfargument name=emailAddress required=yes
type=string default=

		cfscript
		function IsEmail(str)
		{
	 //supports new top level tlds
		if
(REFindNoCase(^['_a-z0-9-]+(\.['_a-z0-9-]+)[EMAIL PROTECTED](\.[a-z0-9-]+)
\.(([a-]{2,3})|(aero|coop|info|museum|name))$,str)) return TRUE;
			else return FALSE;
		}
		/cfscript

		cfif IsEmail(arguments.emailAddress)

			cftry
 cfquery...
 /cfquery
			 cfcatch/cfcatch
			/cftry
		/cfif

		cfreturn returnVar
	/cffunction
/cfcomponent

Is that incorrect?Let me know.

John Burns

-Original Message-
From: Raymond Camden [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 07, 2004 9:21 AM
To: CF-Talk
Subject: RE: UDF in Component?

You can place a UDF in the component, but it will be treated like a
method.
Tell me - how are you calling the function?
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: UDF in Component?

2004-05-07 Thread Raymond Camden
Oh - no - that's wrong. :) You can't define a UDF in a UDF, or method in a
method, or etc.

Simply move the cfscript block outside the cffunction declaration.
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: UDF in Component?

2004-05-07 Thread Burns, John D
Ray,

Thanks for the info.That fixed it. :-)

John 

-Original Message-
From: Raymond Camden [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 07, 2004 9:50 AM
To: CF-Talk
Subject: RE: UDF in Component?

Oh - no - that's wrong. :) You can't define a UDF in a UDF, or method in
a method, or etc.

Simply move the cfscript block outside the cffunction declaration.
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: UDF in Component?

2004-05-07 Thread Paul Kenney
You can, however, cfinclude the isEmail udf within the component method
and it is only visible within that method.

Paul Kenney
[EMAIL PROTECTED]
916-212-4359

 -Original Message-
 From: Burns, John D [mailto:[EMAIL PROTECTED]
 Sent: Friday, May 07, 2004 7:32 AM
 To: CF-Talk
 Subject: RE: UDF in Component?


 Ray,

 Thanks for the info.That fixed it. :-)

 John

 -Original Message-
 From: Raymond Camden [mailto:[EMAIL PROTECTED]
 Sent: Friday, May 07, 2004 9:50 AM
 To: CF-Talk
 Subject: RE: UDF in Component?

 Oh - no - that's wrong. :) You can't define a UDF in a UDF,
 or method in
 a method, or etc.

 Simply move the cfscript block outside the cffunction declaration.






 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: UDF in Component?

2004-05-07 Thread Barney Boisvert
Can I strongly recommend against that?Using CFINCLUDE inside a CFC method
copies all local variables from that method to the VARIABLES scope (the
instanace scope) of the CFC, thoroughly thrashing any encapsulation you had.

Cheers,
barneyb

 -Original Message-
 From: Paul Kenney [mailto:[EMAIL PROTECTED] 
 Sent: Friday, May 07, 2004 2:28 PM
 To: CF-Talk
 Subject: RE: UDF in Component?
 
 You can, however, cfinclude the isEmail udf within the 
 component method
 and it is only visible within that method.
 
 Paul Kenney
 [EMAIL PROTECTED]
 916-212-4359
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: UDF in Component?

2004-05-07 Thread Paul Kenney
Oh yeah, I glanced at that thread quickly but didn't really read it... I
guess I'll do that now.Nevermind my recommendation.Just do what they
said ;)

Thanks.

Paul Kenney
[EMAIL PROTECTED]
916-212-4359

 -Original Message-
 From: Barney Boisvert [mailto:[EMAIL PROTECTED]
 Sent: Friday, May 07, 2004 2:37 PM
 To: CF-Talk
 Subject: RE: UDF in Component?


 Can I strongly recommend against that?Using CFINCLUDE
 inside a CFC method
 copies all local variables from that method to the VARIABLES
 scope (the
 instanace scope) of the CFC, thoroughly thrashing any
 encapsulation you had.

 Cheers,
 barneyb

  -Original Message-
  From: Paul Kenney [mailto:[EMAIL PROTECTED]
  Sent: Friday, May 07, 2004 2:28 PM
  To: CF-Talk
  Subject: RE: UDF in Component?
 
  You can, however, cfinclude the isEmail udf within the
  component method
  and it is only visible within that method.
 
  Paul Kenney
  [EMAIL PROTECTED]
  916-212-4359



 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]