View comments | RSS feed

cfreturn

Description

Returns result values from a component method. Contains an expression returned as result of the function.

Return value

An expression; the result of the function from which this tag is called.

Category

Extensibility tags

Syntax

<cfreturn 
  expr>

See also

cfargument, cfcomponent, cffunction, cfinvoke, cfinvokeargument, cfobject, cfproperty

History

New in ColdFusion MX: This tag is new.

Attributes

Attribute Req/Opt Default Description
expr
Required

Function result; value of any type

Usage

This tag is equivalent to a return statement within a cfscript tag. It accepts one return variable argument. To return more than one value, populate a structure with name-value-pairs, and return the structure with this tag.

To access the result value from this tag, you use the variable scope that is the value of the cfinvoke tag returnVariable attribute.

You can code a maximum of one cfreturn tag within a function.

For example code, see the Building and Using ColdFusion Components chapter of Developing ColdFusion MX Applications with CFML.

Example

<cfcomponent>
  <cffunction name="getEmp">
     <cfquery name="empQuery" datasource="ExampleApps" >
       SELECT FIRSTNAME, LASTNAME, EMAIL
       FROM tblEmployees
     </cfquery>
     <cfreturn empQuery>
  </cffunction>
  <cffunction name="getDept">
    <cfquery name="deptQuery" datasource="ExampleApps" >
       SELECT *
       FROM tblDepartments
     </cfquery>
     <cfreturn deptQuery>
  </cffunction>
</cfcomponent>

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6

Comments are no longer accepted for ColdFusion MX. ColdFusion 8 is the current version.

Comments


jcarberry said on Apr 22, 2003 at 5:53 PM :
when i code a UDF using CFML and CFRETURN, string values returned end up having a leading blank character that is apparently not an ASCII space (perhaps a ASCII 20 instead of 32). Therefore, the space cannot be TRIM() trimmed. Very frustrating, but perhaps I am doing something wrong.
hotwater said on Jul 28, 2003 at 6:13 PM :
The documentation says you can code a maximum of one cfreturn per function, but that isn't true. You can have more than one.
Cameron595 said on Nov 5, 2003 at 9:44 AM :
<cffunction name="XXXXXXX" returntype="string" output="false">

Setting the output to false fixes the spacing problem. I'm not quite sure why, but it works.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6/CFML_Reference/Tags-pt227.htm