Re: Proper returntype of a cfc
You would need to return it as a struct. then just reference any parts of the struct that contain the data you want. I have one cfc that returns a struct of arrays... Rob On Fri, Jun 12, 2009 at 8:25 PM, Ryan Letulle bayous...@gmail.com wrote: Is it a common/best practice to return multiple variables from a cfc? Like if I wanted perform some processing in a cfc and return several variables. For the most part I have always returned either a query or 1 variable. If so, what would be the best return type for this? Does that make sense? I'd like to do this in the most popular way. I feel like I can really consolidate some code on a certain project. -- Ryan LeTulle ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323468 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Proper returntype of a cfc
That's what I thought but I've been wrong before. :) -- Ryan LeTulle On Fri, Jun 12, 2009 at 7:30 PM, Rob Parkhill robert.parkh...@gmail.comwrote: You would need to return it as a struct. then just reference any parts of the struct that contain the data you want. I have one cfc that returns a struct of arrays... Rob On Fri, Jun 12, 2009 at 8:25 PM, Ryan Letulle bayous...@gmail.com wrote: Is it a common/best practice to return multiple variables from a cfc? Like if I wanted perform some processing in a cfc and return several variables. For the most part I have always returned either a query or 1 variable. If so, what would be the best return type for this? Does that make sense? I'd like to do this in the most popular way. I feel like I can really consolidate some code on a certain project. -- Ryan LeTulle ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323469 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Proper returntype of a cfc
Is it a common/best practice to return multiple variables from a cfc? Like if I wanted perform some processing in a cfc and return several variables. For the most part I have always returned either a query or 1 variable. If so, what would be the best return type for this? Does that make sense? I'd like to do this in the most popular way. I feel like I can really consolidate some code on a certain project. You can't return multiple variables from a function call. You can only return one variable. Of course, that variable can contain other variables, multiple values, recordsets, etc. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more informat ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323470 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Proper returntype of a cfc
Understand, I guess the proper terminology should be multiple values ? -- Ryan LeTulle On Fri, Jun 12, 2009 at 7:35 PM, Dave Watts dwa...@figleaf.com wrote: Is it a common/best practice to return multiple variables from a cfc? Like if I wanted perform some processing in a cfc and return several variables. For the most part I have always returned either a query or 1 variable. If so, what would be the best return type for this? Does that make sense? I'd like to do this in the most popular way. I feel like I can really consolidate some code on a certain project. You can't return multiple variables from a function call. You can only return one variable. Of course, that variable can contain other variables, multiple values, recordsets, etc. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more informat ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323471 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Proper returntype of a cfc
Understand, I guess the proper terminology should be multiple values ? Well then, it seems an odd question to ask. Return whatever data type reflects the best possible output for your function. If that's a query, return a query. If it's an array, return an array. If it's a structure, return a structure. There's nothing wrong with returning any of these, if that's what you want to get back. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323472 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Proper returntype of a cfc
Only odd to you because you are all knowing. For the most part I have always returned either a query or 1 variable. I have never done this before in a cfc. -- Ryan LeTulle On Fri, Jun 12, 2009 at 7:43 PM, Dave Watts dwa...@figleaf.com wrote: Understand, I guess the proper terminology should be multiple values ? Well then, it seems an odd question to ask. Return whatever data type reflects the best possible output for your function. If that's a query, return a query. If it's an array, return an array. If it's a structure, return a structure. There's nothing wrong with returning any of these, if that's what you want to get back. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323473 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Proper returntype of a cfc
BTW I always appreciate the guidance. -- Ryan LeTulle On Fri, Jun 12, 2009 at 7:45 PM, Ryan Letulle bayous...@gmail.com wrote: Only odd to you because you are all knowing. For the most part I have always returned either a query or 1 variable. I have never done this before in a cfc. -- Ryan LeTulle On Fri, Jun 12, 2009 at 7:43 PM, Dave Watts dwa...@figleaf.com wrote: Understand, I guess the proper terminology should be multiple values ? Well then, it seems an odd question to ask. Return whatever data type reflects the best possible output for your function. If that's a query, return a query. If it's an array, return an array. If it's a structure, return a structure. There's nothing wrong with returning any of these, if that's what you want to get back. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323474 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Proper returntype of a cfc
Only odd to you because you are all knowing. I wish! But calling functions in CF is basically the same as calling functions in other languages. You provide a list of inputs, and get a single return value. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323475 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Proper returntype of a cfc
@dave I started using cfcs after reading a Ben Forta article a couple of years ago where he said at least use cfcs for querys and you should never output to the screen from cfcs. For the most part that is what I have used them for. Unfortunately, I never really advanced further than that with cfcs. Otherwise, I get it done without 'em. I want to do better. :) -- Ryan LeTulle On Fri, Jun 12, 2009 at 7:57 PM, Dave Watts dwa...@figleaf.com wrote: Only odd to you because you are all knowing. I wish! But calling functions in CF is basically the same as calling functions in other languages. You provide a list of inputs, and get a single return value. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323476 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Proper returntype of a cfc
Consider returning an object (another CFC), rather than a struct. In some cases a struct works well, but if you return an object you have better documentation as to what it returns, rather than with a struct with unknown keys. You can also setup default values in the CFC. -- Pete Freitag http://foundeo.com/ - ColdFusion Consulting Products http://petefreitag.com/ - My Blog ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323477 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Proper returntype of a cfc
Only odd to you because you are all knowing. For some reason this tickles me pink. Dave, you *are* a walking, talking cf_encyclopedia. G! On Fri, Jun 12, 2009 at 8:45 PM, Ryan Letulle bayous...@gmail.com wrote: Only odd to you because you are all knowing. -- Gerald Guido http://www.myinternetisbroken.com http://www.cfsimple.org/ To invent, you need a good imagination and a pile of junk. -- Thomas A. Edison ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323478 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4