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; Creating reports with the ColdFusion MX 7 reporting in Creating Reports for Printing in ColdFusion MX Developer's Guide

History

ColdFusion MX: Added this tag.

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 Building and Using ColdFusion Components in ColdFusion MX Developer's Guide.

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 MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | KnowledgeBase | Bug Reporting

Version 7

Comments


Yvanthar said on Nov 23, 2006 at 1:35 PM :
"You can code a maximum of one cfreturn tag within a function."

This would appear to be false...

 

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

Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00000326.htm