• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

20. User-Defined Functions > 20.5. Script-Based UDFs

Script-Based UDFs

CFScript-based UDFs look a little different than their tag-based siblings. The first thing you should notice is that all script-based UDFs must be written within a cfscript tag block:

<cfscript>
function function_name([arg1][,arg2]...)
{
  CFScript statements
}
</cfscript>

Script-based UDFs begin with the function statement. The name of the function is defined by function_name and follows the same naming conventions as tag based UDFs. Script-based functions can be written to accept zero or more required arguments and any number of optional arguments. Each required argument must be given a name and explicitly declared in the function statement. For example, to declare a function called Mean that accepts a single parameter called Values, you would code it like this:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint