Whatever message this page gives is out now! Go check it out!
<cfset Request.MyFunc = Variables.MyFunc>| Scope | Considerations |
Application | Makes the function available across all invocations of the application. Access to UDFs in Application scope is multithreaded and you can execute multiple copies of the UDF at one time. |
Request | Makes the function available for the life of the current HTTP request, including in all custom tags and nested custom tags. This scope is useful if a function is used in a page and in the custom tags it calls, or in nested custom tags. |
Server | Makes the function available to all pages on a single server. In most cases, this scope is not a good choice because in clustered systems, it only makes the function available on a single server, and all code that uses the function must be inside a cflock block. |
Session | Makes the function available to all pages during the current user session. This scope has no significant advantages over the Application scope. |
{ Function definition goes here }
Request.MyFunc1 = MyFunc1<cfinclude template="myfuncs.cfm">Request.MyFunc1(Value1, Value2)<cfscript>
function binop(operation, operand1, operand2)
{ return (operation(operand1, operand2)); }
function sum(addend1, addend2)
{ return addend1 + addend2;}
x = binop(sum, 3, 5);
writeoutput(x);
</cfscript>query attribute, such as a cfloop tag, any function argument that is a query column name passes a single element of the column, not the entire column. Therefore, the function must manipulate a single query element. For example, the following code defines a function to combine a single first name and last name to make a full name. It queries the cfdocexamples database to get the first and last names of all employees, and then it uses a cfoutput tag to loop through the query and call the function on each row in the query.