Matt Liotta Montara Software, Inc. http://www.MontaraSoftware.com
On Jan 7, 2004, at 2:06 PM, Barney Boisvert wrote:
That's impossible, as evaluate fires at runtime, while the function
definitions are processed at compile time (into their own classes). It's
something that's MUCH better done at development time anyway. Any good OO
IDE will do exactly that for you, but unfortunately we don't have an IDE for
CFCs, let alone a good one. However, you can probably duplicate that type
of function with an extension for DW. Have to do some parsing of the DOM to
get a variable list, let the user select which variables to generate for,
and then write a bunch of code at the end of the dom, before the closing
CFCOMPONENT tag.
Cheers, barneyb
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jon Gunnip Sent: Wednesday, January 07, 2004 10:52 AM To: [EMAIL PROTECTED] Subject: [CFCDev] Dynamically creating functions
I've been curious whether it is possible to dynamically create functions in CF with names and return variable names decided at runtime. I took a stab at it once, but I couldn't figure out how to create a function on the fly besides writing the function declaration to a file and then cfincluding it.
Wouldn't it be nice to have something like this for simple getters?:
<cfset Getters = "ID,Name,Age,Height,Weight" >
<cfloop list="#Getters#" index="GetterVar" > <cfset CreateSimpleGetter(GetterVar) > </cfloop>
<cffunction name="CreateSimpleGetter" > <cfargument name="GetterVar" /> <cfset FunctionText = "<cffunction name='get#GetterVar#'><cfreturn Variables[#GetterVar#]></cffunction>" > <cfset Evaluate(FunctionText) > </cffunction>
Does anyone know if it is possilbe to create a function factory like this?
Jon
[EMAIL PROTECTED] 01/07/04 10:21AM >>>
I have a CFC with 26 properties. None are inherited. I find that having 52 methods for getting and setting to be a bit cumbersome to keep in my CFC with the "real" methods. I was thinking of including all my getters and setters from a CF template. Let's say that the my code looks like this:
facility.cfc <cfcomponent hint="I am a facility"> <!--- Include the getters and setters ---> <cfinclude template= "facilitygetset.cfm">
<!--- Start the more complicated stuff ---> <cffunction name="firstrealmethod"> . . . </cffunction> .. .. .. .. </cfcomponent>
Any thoughts on this as a good idea, bad idea, unintended consequences?
------------------------------------------------ Gerry Gurevich, Lockheed Martin [EMAIL PROTECTED] 919-572-7818
---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
