MACROMEDIA COLDFUSION MX 61-CFML Reference

Cfml reference
Hide thumbs Also See for COLDFUSION MX 61-CFML:
Table of Contents

Advertisement

Quick Links

CFML Reference

Advertisement

Table of Contents
loading

Summary of Contents for MACROMEDIA COLDFUSION MX 61-CFML

  • Page 1 CFML Reference...
  • Page 2 If you access a third-party website mentioned in this guide, then you do so at your own risk. Macromedia provides these links only as a convenience, and the inclusion of the link does not imply that Macromedia endorses or accepts any responsibility for the content on those third-party sites.
  • Page 3: Table Of Contents

    INTRODUCTION About Macromedia ColdFusion MX documentation ..... . 17 Documentation set ..........17 Viewing online documentation.
  • Page 4 CGI environment variables ......... . 29 Testing for CGI variables .
  • Page 5 cfexecute ............106 cfexit .
  • Page 6 cfloop: looping over a query ........236 cfloop: looping over a list or file .
  • Page 7 cftreeitem ............349 cftry .
  • Page 8 Asc ............395 ASin .
  • Page 9 Decrypt ............462 DeleteClientVariable .
  • Page 10 Insert............522 Int .
  • Page 11 ListValueCount ..........590 ListValueCountNoCase .
  • Page 12 Reverse ............668 Right .
  • Page 13 XmlFormat ........... . . 741 XmlNew .
  • Page 14 CHAPTER 5: ColdFusion Java CFX Reference ......769 Overview class libraries ..........770 CustomTag interface .
  • Page 15 setField ............796 wddxSerialize .
  • Page 16 Contents...
  • Page 17: Introduction

    CFML Reference is your primary ColdFusion Markup Language (CFML) reference. Use this book to learn about CFML tags and functions, ColdFusion expressions, and using JavaScript objects for WDDX in Macromedia ColdFusion MX. It also provides detailed references for Java and C++ CFX interfaces.
  • Page 18: Viewing Online Documentation

    Viewing online documentation All ColdFusion MX documentation is available online in HTML and Adobe Acrobat Portable Document Format (PDF) files. Go to the documentation home page for ColdFusion MX on the Macromedia website: www.macromedia.com. Introduction...
  • Page 19: Chapter 1: Reserved Words And Variables

    CHAPTER 1 Reserved Words and Variables This chapter provides information on ColdFusion reserved words and lists scope variables. Contents Reserved words ............20 Scope-specific built-in variables .
  • Page 20: Reserved Words In Forms

    Reserved words The following list indicates words you must not use for ColdFusion variables, user-defined function names, or custom tag names. While some of these words can be used safely in some situations, you can prevent errors by avoiding them entirely. •...
  • Page 21 COLUMN COMMIT CONNECT CONNECTION CONSTRAINT CONSTRAINTS CONTINUE CONVERT CORRESPON COUNT DING CREATE CROSS CURRENT CURRENT_DATE CURRENT_TIME CURRENT_TIME CURRENT_USER CURSOR DATE STAMP DEALLOCATE DECIMAL DECLARE DEFAULT DEFERRABLE DEFERRED DELETE DESC DESCRIBE DESCRIPTOR DIAGNOSTICS DISCONNECT DISTINCT DOMAIN DOUBLE DROP ELSE END-EXEC ESCAPE EXCEPT EXCEPTION EXEC...
  • Page 22 TIME TIMESTAMP TIMEZONE_ TIMEZONE_ HOUR MINUTE TRAILING TRANSACTION TRANSLATE TRANSLATION TRIM TRUE UNION UNIQUE UNKNOWN UPDATE UPPER USAGE USER USING VALUE VALUES VARCHAR VARYING VIEW WHEN WHENEVER WHERE WITH WORK WRITE YEAR ZONE Chapter 1: Reserved Words and Variables...
  • Page 23: Scope-Specific Built-In Variables

    Scope-specific built-in variables ColdFusion returns variables, such as those returned in a operation. A cfdirectory cfftp variable is usually referenced by scoping it according to its type: naming it according to the code context in which it is available; for example, Session.varname, or Application.varname. For more information on ColdFusion scopes, see Chapter 3, “Using ColdFusion Variables,”...
  • Page 24: Custom Tag Variables

    To ensure that modifications to shared data occur in the intended sequence, use the tag. cflock For more information, see on page 221. cflock The predefined application and session variables are as follows: Application.ApplicationName Session.CFID Session.CFToken Session.URLToken Custom tag variables A ColdFusion custom tag returns the following variables: ThisTag.ExecutionMode ThisTag.HasEndTag...
  • Page 25: Coldfusion Query Variables

    cfhttp cfindex cfldap cfmail cfpop cfquery cfregistry cfsearch cfstoredproc ColdFusion query variables A ColdFusion tag that returns a query object supports the following variables, where queryname is the value of the attribute: name queryname.CurrentRow queryname.RecordCount queryname.ColumnList CFCATCH variables Within a block, the active exception properties can be accessed as the following cfcatch variables:...
  • Page 26: Cffile Action=Upload Variables

    Error.HTTPReferer Error.Template Error.QueryString The following error variables are available if ". type="validation Error.ValidationHeader Error.InvalidFields Error.ValidationFooter variable that applies to exception type can be accessed within the Error scope, as cfcatch follows: Error.Type Error.Message Error.Detail Error.ErrNumber Error.NativeErrorCode Error.SQLState Error.LockName Error.LockOperation Error.MissingFileName Error.TagContext Error.ErrorCode Error.ExtendedInfo...
  • Page 27: Cfftp Query Object Columns

    CFFTP.ErrorCode CFFTP.ErrorText CFFTP ReturnValue variable Some file and directory operations provide a return value, in the variable cfftp CFFTP.ReturnValue. Its value is determined by the results of the attribute. When you action specify any of the following actions, returns a value: cfftp GetCurrentDir GetCurrentURL...
  • Page 28: Cfquery And Cfstoredproc Variables

    queryname.CC queryname.To queryname.CurrentRow queryname.RecordCount queryname.ColumnList queryname.Attachments queryname.AttachmentFiles CFQUERY and CFSTOREDPROC variables tag returns information about the query in this variable: cfquery CFQUERY.ExecutionTime tag uses the query name to scope the following data about the query: cfquery queryname.CurrentRow queryname.RecordCount queryname.ColumnList tag returns the following variables: cfstoredproc CFSTOREDPROC.ExecutionTime CFSTOREDPROC.StatusCode...
  • Page 29: Standard Cgi Variables

    Standard CGI variables This section lists the CGI 1.1 variables that some web servers create when a CGI script is called. The CGI variables that are available for your use vary with the web server and configuration. Some of the following variables may not be available. Request CGI.AUTH_TYPE CGI.CONTENT_LENGTH...
  • Page 30: Cgi Server Variables

    Testing for CGI variables Because some browsers do not support some CGI variables, ColdFusion always returns True when it tests for the existence of a CGI variable, regardless of whether the browser supports the variable. To determine if the CGI variable is available, test for an empty string, as shown in the following example: <cfif CGI.varname IS NOT "">...
  • Page 31: Cgi Client Variables

    O = "VeriSign, Inc.", OU = VeriSign Trust Network, OU = "www.verisign.com/repository/RPA Incorp. by Ref.,LIAB.LTD(c)98", OU = Persona Not Validated, OU = Digital ID Class 1 - Microsoft, CN = Matthew Lund, E = mlund@macromedia.com CERT_ISSUER Information about the authority that provided the client certificate. For example: O = "VeriSign, Inc.", OU = VeriSign Trust Network, OU =...
  • Page 32 Chapter 1: Reserved Words and Variables...
  • Page 33: Chapter 2: Coldfusion Tags

    CHAPTER 2 ColdFusion Tags ColdFusion Markup Language (CFML) includes a set of tags that you use in ColdFusion pages to interact with data sources, manipulate data, and display output. CFML tag syntax is similar to HTML element syntax. This chapter contains categorized and alphabetical lists of the tags followed by the detailed tag descriptions.
  • Page 34 Tag summary The following table briefly describes CFML tags: CFML tag Category Description cfabort Flow-control tags Stops the processing of a ColdFusion page at the tag location Forms tags Embeds Java applets in a cfapplet cfform Application framework Defines an application name; activates client cfapplication tags variables;...
  • Page 35 CFML tag Category Description cferror Exception handling tags, Displays custom HTML error pages when errors Application framework occur tags cfexecute Flow-control tags, Executes developer-specified process on server Extensibility tags computer Flow-control tags Aborts processing of executing CFML tag cfexit File management tags Performs typical file-handling tasks from within cffile ColdFusion application...
  • Page 36 CFML tag Category Description cfinvokeargument Extensibility tags Passes a parameter to a component method or a web service Forms tags, Provides access to LDAP directory servers cfldap Internet Protocol tags cflocation Flow-control tags Controls execution of a page Application framework Ensures data integrity and synchronizes cflock tags...
  • Page 37 CFML tag Category Description cfquery Database manipulation Passes SQL statements to a database tags Database manipulation Checks data type of a query parameter cfqueryparam tags cfregistry Other tags, Reads, writes, and deletes keys and values in a Variable manipulation Windows system registry tags cfreport Exception handling tags...
  • Page 38 CFML tag Category Description cftreeitem Forms tags Populates a tree control element in a form; used with cftree Exception handling tags, Catches exceptions in ColdFusion pages cftry Flow-control tags cfupdate Database manipulation Updates rows in a database data source tags Extensibility tags Serializes and de-serializes CFML data cfwddx...
  • Page 39: Tags By Function

    Tags by function The following tables list Tags by their function or purpose. Application framework tags ........... 39 Database manipulation tags .
  • Page 40: Exception Handling Tags

    Exception handling tags cfcatch cfrethrow cftry cferror cfthrow Extensibility tags cfchart cffunction cfobject cfchartdata cfindex cfproperty cfchartseries cfinvoke cfreport cfcollection cfinvokeargument cfreturn cfcomponent cflogin cfsearch cfexecute cfloginuser cfwddx cfftp cflogout cfxml File management tags cfdirectory cffile cfftp Flow-control tags cfabort cfexecute cfrethrow cfbreak...
  • Page 41: Internet Protocol Tags

    Internet Protocol tags cfftp cfldap cfmailpart cfhttp cfmail cfpop cfhttpparam cfmailparam Page processing tags cfcache cfheader cfsetting cfcontent cfhtmlhead cfsilent cfflush cfinclude Variable manipulation tags cfcookie cfregistry cfset cfdump cfsavecontent cfsetting cfparam cfschedule Other tags cflog cfregistry Tags by function...
  • Page 42: Tag Changes Since Coldfusion 5

    Tag changes since ColdFusion 5 The following tables list Tags, attributes, and values that have changed since ColdFusion 5.0 and indicate the specific release in which the change was made. New tags, attributes, and values ..........42 Deprecated tags, attributes, and values .
  • Page 43 Added in this ColdFusion Attribute or value release ColdFusion MX cfimport ColdFusion MX cfinvoke cfinvokeargument ColdFusion MX cflogin ColdFusion MX ColdFusion MX cfloginuser ColdFusion MX cflogout cfmail attribute ColdFusion MX spoolEnable attribute ColdFusion MX 6.1 charset attribute ColdFusion MX 6.1 failto attribute ColdFusion MX 6.1...
  • Page 44: Deprecated Tags, Attributes, And Values

    Deprecated tags, attributes, and values The following tags, attributes, and attribute values are deprecated. Do not use them in ColdFusion applications. They might not work, and might cause an error, in releases later than ColdFusion MX. Deprecated as of this ColdFusion Attribute or value release attribute...
  • Page 45 Deprecated as of this ColdFusion Attribute or value release attribute ColdFusion MX cfquery connectString attribute ColdFusion MX dbName attribute ColdFusion MX dbServer The following attribute values: ColdFusion MX dbType • (The value is valid.) dynamic query • ODBC • Oracle73 •...
  • Page 46: Obsolete Tags, Attributes, And Values

    Obsolete tags, attributes, and values The following tags, attributes, and attribute values are obsolete. Do not use them in ColdFusion applications. They do not work, and might cause an error, in releases later than ColdFusion 5. Obsolete as of this ColdFusion Attribute or value release ColdFusion MX...
  • Page 47: Cfabort

    cfabort Description Stops the processing of a ColdFusion page at the tag location. ColdFusion returns everything that was processed before the tag. The tag is often used with conditional logic to stop processing a page when a condition occurs. Category Flow-control tags Syntax <cfabort...
  • Page 48 <!--- reset the variable and show the use of cfabort ---> <cfset myVariable = 3> <!--- now, perform a loop that increments this value ---> <cfloop from = "1" to = "4" index = "Counter"> <!--- on the second time through the loop, cfabort ---> <cfif Counter is 2>...
  • Page 49: Cfapplet

    cfapplet Description This tag references a registered custom Java applet. To register a Java applet, in the ColdFusion Administrator, click Extensions > Java Applets. Using this tag within a tag is optional. If you use it within , and the cfform cfform method...
  • Page 50 Attribute Req/Opt Default Description align Optional Alignment: • Left • Right • Bottom • Top • TextTop • Middle • AbsMiddle • Baseline • AbsBottom notSupported Optional Text to display if a page that contains a Java applet-based Description cfform control is opened by a browser that does not support Java or has Java support disabled.
  • Page 51: Cfapplication

    cfapplication Description Defines the scope of a ColdFusion application; enables and disables storage of Client variables; specifies the Client variable storage mechanism; enables Session variables; and sets Application variable timeouts. Category Application framework tags Syntax <cfapplication name = "application_name" loginStorage = "cookie" or "session" clientManagement = "Yes"...
  • Page 52 Attribute Req/Opt Default Description clientStorage Optional registry How client variables are stored: • datasource_name: in ODBC or native data source. You must create storage repository in the Administrator. • registry: in the system registry. • cookie: on client computer in a cookie. Scalable.
  • Page 53 If you use this tag to activate the Application and Client scopes, ColdFusion saves the application name as a key, whose maximum length is 64 characters. If an application name is longer than this, the client store fails during database processing. The CFTOKEN variable is 8 bytes in length.
  • Page 54: Cfargument

    cfargument Description Creates a parameter definition within a component definition. Defines a function argument. Used within a tag. cffunction Category Extensibility tags Syntax <cfargument name="string" type="data type" required="Yes or No" default="default value" displayname="descriptive name" hint="extended description" > See also cfcomponent, cffunction, cfinvoke, cfinvokeargument, cfobject, cfproperty, cfreturn Attributes Attribute...
  • Page 55 Attribute Req/Opt Default Description required Optional Whether the parameter is required to execute the component method. • yes (the parameter is not required if you specify a default attribute.) • no default Optional If no argument is passed, specifies a default argument value. displayname Optional name Meaningful only for CFC method parameters.
  • Page 56: Cfassociate

    cfassociate Description Allows subtag data to be saved with a base tag. Applies only to custom tags. Category Application framework tags Syntax <cfassociate baseTag = "base_tag_name" dataCollection = "collection_name"> See also cfapplication, cferror, cflock, cfmodule Attributes Attribute Req/Opt Default Description baseTag Required Base tag name...
  • Page 57: Cfauthenticate

    cfauthenticate Description This tag is obsolete. Use the newer security tools; see “Authentication functions” on page 367 Chapter 16, “Securing Applications,” in Developing ColdFusion MX Applications. History ColdFusion MX: this tag is obsolete. It does not work in ColdFusion MX and later releases. cfauthenticate...
  • Page 58: Cfbreak

    cfbreak Description Used within a tag. Breaks out of a loop. cfloop Category Flow-control tags Syntax <cfbreak> See also cfabort, cfexecute, cfif, cflocation, cfloop, cfswitch, cfthrow, cftry Example <!--- This shows the use of cfbreak to exit a loop when a condition is met ---> <!--- select courses;...
  • Page 59: Cfcache

    cfcache Description Stores a copy of a page on the server and/or client computer, to improve page rendering performance. To do this, the tag creates temporary files that contain the static HTML returned from a ColdFusion page. Use this tag if it is not necessary to get dynamic content each time a user accesses a page. You can use this tag for simple URLs and for URLs that contain URL parameters.
  • Page 60 Attributes Attribute Req/Opt Default Description action Optional cache • cache: server-side and client-side caching. • flush: refresh cached page(s). • clientcache: browser-side caching only. To cache a personalized page, use this option. • servercache: server-side caching only. Not recommended. • optimal: same as "cache". directory Optional cf_root/cache Absolute path of cache directory.
  • Page 61 (Macromedia recommends that you do not use server-side only caching. Macromedia recommends that you use combination caching.)
  • Page 62: Cfcase

    cfcase Description Used only inside the tag body. Contains code to execute when the expression specified cfswitch in the tag has one or more specific values. cfswitch Category Flow-control tags Syntax <cfcase value = "value or delimited set of values" delimiters = "delimiter characters"...
  • Page 63 </cfcase> <cfcase value="9;8" delimiters=";"> <cfset grade="B"> </cfcase> <cfcase value="7;6" delimiters=";"> <cfset grade="C"> </cfcase> <cfcase value="5;4;" delimiters=";"> <cfset grade="D"> </cfcase> <cfdefaultcase> <cfset grade="F"> </cfdefaultcase> </cfswitch> <cfoutput> Your grade is #grade# </cfoutput> cfcase...
  • Page 64: Cfcatch

    cfcatch Description Used inside a tag. Together, they catch and process exceptions in ColdFusion pages. cftry Exceptions are events that disrupt the normal flow of instructions in a ColdFusion page, such as failed database operations, missing include files, and developer-specified events. Category Exception handling tags Syntax...
  • Page 65 Attributes Attribute Req/Opt Default Description type Optional • application: catches application exceptions • database: catches database exceptions • template: catches ColdFusion page exceptions • security: catches security exceptions • object: catches object exceptions • missingInclude: catches missing include file exceptions •...
  • Page 66 , and tags throw an exception of cfinclude cfmodule cferror type = "template" An exception that is thrown within a block cannot be handled by the block that cfcatch cftry immediately encloses the tag. However, you can rethrow the currently active exception cfcatch with the tag.
  • Page 67 Advanced Exception types You can specify the following advanced exception types in the attribute: type ColdFusion advanced exception type COM.Allaire.ColdFusion.CFEXECUTE.OutputError COM.Allaire.ColdFusion.CFEXECUTE.Timeout COM.Allaire.ColdFusion.FileException COM.Allaire.ColdFusion.HTTPAccepted COM.Allaire.ColdFusion.HTTPAuthFailure COM.Allaire.ColdFusion.HTTPBadGateway COM.Allaire.ColdFusion.HTTPBadRequest COM.Allaire.ColdFusion.HTTPCFHTTPRequestEntityTooLarge COM.Allaire.ColdFusion.HTTPCGIValueNotPassed COM.Allaire.ColdFusion.HTTPConflict COM.Allaire.ColdFusion.HTTPContentLengthRequired COM.Allaire.ColdFusion.HTTPContinue COM.Allaire.ColdFusion.HTTPCookieValueNotPassed COM.Allaire.ColdFusion.HTTPCreated COM.Allaire.ColdFusion.HTTPFailure COM.Allaire.ColdFusion.HTTPFileInvalidPath COM.Allaire.ColdFusion.HTTPFileNotFound COM.Allaire.ColdFusion.HTTPFileNotPassed COM.Allaire.ColdFusion.HTTPFileNotRenderable COM.Allaire.ColdFusion.HTTPForbidden COM.Allaire.ColdFusion.HTTPGatewayTimeout COM.Allaire.ColdFusion.HTTPGone COM.Allaire.ColdFusion.HTTPMethodNotAllowed COM.Allaire.ColdFusion.HTTPMovedPermanently...
  • Page 68 ColdFusion advanced exception type COM.Allaire.ColdFusion.HTTPNotModified COM.Allaire.ColdFusion.HTTPPartialContent COM.Allaire.ColdFusion.HTTPPaymentRequired COM.Allaire.ColdFusion.HTTPPreconditionFailed COM.Allaire.ColdFusion.HTTPProxyAuthenticationRequired COM.Allaire.ColdFusion.HTTPRequestURITooLarge COM.Allaire.ColdFusion.HTTPResetContent COM.Allaire.ColdFusion.HTTPSeeOther COM.Allaire.ColdFusion.HTTPServerError COM.Allaire.ColdFusion.HTTPServiceUnavailable COM.Allaire.ColdFusion.HTTPSwitchingProtocols COM.Allaire.ColdFusion.HTTPUnsupportedMediaType COM.Allaire.ColdFusion.HTTPUrlValueNotPassed COM.Allaire.ColdFusion.HTTPUseProxy COM.Allaire.ColdFusion.HTTPVersionNotSupported COM.Allaire.ColdFusion.POPAuthFailure COM.Allaire.ColdFusion.POPConnectionFailure COM.Allaire.ColdFusion.POPDeleteError COM.Allaire.ColdFusion.Request.Timeout COM.Allaire.ColdFusion.SERVLETJRunError COMCOM.Allaire.ColdFusion.HTTPConnectionTimeout Example <!--- cftry example, using TagContext to display the tag stack. ---> <h3>cftry Example</h3> <!--- open a cftry block ---> <cftry>...
  • Page 69 <p>The contents of the tag stack are:</p> <cfloop index = i from = 1 to = #ArrayLen(CFCATCH.TAGCONTEXT)#> <cfset sCurrent = #CFCATCH.TAGCONTEXT[i]#> <br>#i# #sCurrent["ID"]# (#sCurrent["LINE"]#,#sCurrent["COLUMN"]#) #sCurrent["TEMPLATE"]# </cfloop> </cfoutput> </cfcatch> </cftry> cfcatch...
  • Page 70: Cfchart

    cfchart Description Generates and displays a chart. Category Data output tags, Extensibility tags Syntax <cfchart format = "flash, jpg, png" chartHeight = "integer number of pixels" chartWidth = "integer number of pixels" scaleFrom = "integer minimum value" scaleTo = "integer maximum value" showXGridlines = "yes"...
  • Page 71 Attributes Attribute Req/Opt Default Description format flash File format in which to save graph. • flash • jpg • png chartHeight Chart height; integer number of pixels chartWidth Chart width; integer number of pixels scaleFrom Determined by Y-axis minimum value; integer. data scaleTo Determined by...
  • Page 72 Attribute Req/Opt Default Description fontSize Font size; integer fontBold • yes • no fontItalic • Yes • No labelFormat number Format for Y-axis labels. • number • currency • percent • date xAxisTitle text; X-axis title yAxisTitle text; Y-axis title xAxisType category •...
  • Page 73 Attribute Req/Opt Default Description tipStyle mouseOver Determines the action that opens a popup window to display information about the current chart element. • mouseDown: displays if the user positions the cursor at the element and clicks the mouse down. Applies only to Flash format graph file.
  • Page 74 Data is passed to the tag in the following ways: cfchartseries • As a query • As data points, using the cfchartdata For the attribute value " ", the following rules apply: font ArialUnicodeMS • On Windows: to permit Flash charts ( ) to render double-byte character set, type = "flash"...
  • Page 75: Cfchartdata

    cfchartdata Description Used with the tags. This tag defines chart data points. Its data is cfchart cfchartseries submitted to the tag. cfchartseries Category Data output tags, Extensibility tags Syntax <cfchartdata item = "text" value = "number"> See also cfchart, cfchartseries History ColdFusion MX: Added this tag.
  • Page 76: Cfchartseries

    cfchartseries Description Used with the tag. This tag defines the style in which chart data displays: bar, line, pie, cfchart and so on. Category Data output tags, Extensibility tags Syntax <cfchartseries type="type" query="queryName" itemColumn="queryColumn" valueColumn="queryColumn" seriesLabel="Label Text" seriesColor="Hex value or Web color" paintStyle="plain, raise, shade, light"...
  • Page 77 Attribute Req/Opt Default Description seriesLabel Optional Text of data series label seriesColor Optional Color of the main element (such as the bars) of a chart. For a pie chart, the color of the first slice. Hex value or supported named color; see name list in Usage section.
  • Page 78: Cfcol

    cfcol Description Defines table column header, width, alignment, and text. Used within a tag. cftable Category Data output tags Syntax <cfcol header = "column_header_text" width = "number_indicating_width_of_column" align = "Left" or "Right" or "Center" text = "column_text"> See also cfcontent, cfoutput, cftable History ColdFusion MX: Added the ability to construct dynamic...
  • Page 79 FROM Employees </cfquery> <html> <body> <h3>cfcol Example</h3> <!--- Uses the HTMLTable attribute to display cftable as an HTML table, rather than PRE formatted information ---> <cftable query = "GetEmployees" startRow = "1" colSpacing = "3" HTMLTable colheaders> <!--- each cfcol tag sets the width of a column in the table, the header information and the text/CFML for the cell --->...
  • Page 80: Cfcollection

    cfcollection Description Creates, registers, and administers Verity search engine collections. A collection that is created with the tag is internal. A collection created any other cfcollection way is external. A collection that is registered with ColdFusion using the tag or registered with the cfcollection K2 Server by editing the k2server.ini file is registered.
  • Page 81 Attributes Attribute Req/Opt Default Description action Required; see list • create: registers the collection with ColdFusion. Usage section - If the collection is present: creates a map to it - If the collection is not present: creates it • repair: fixes data corruption in a collection. •...
  • Page 82 Before you attempt to delete or purge a collection that is also opened by the K2Server, you must stop the K2Server. If you do not, some files may be open, and ColdFusion might not complete the action. action returns the following information in a result set that contains one row per list collection: Column...
  • Page 83 With the European Verity Locales language pack installed, the attribute of this tag language supports the following options: bokmal french norweg danish german portug dutch italian portuguese english nynorsk spanish finnish norwegian swedish With the Asian Verity Locales language pack installed, the attribute of this tag supports language the following options:...
  • Page 84 </cfcase> <cfcase value="Optimize"> <cfcollection action="OPTIMIZE" collection="#FORM.CollectionName#"> <h3>Collection optimized.</h3> </cfcase> <cfcase value="Delete"> <cfcollection action="DELETE" collection="#FORM.CollectionName#"> <h3>Collection deleted.</h3> </cfcase> </cfswitch> <cfelse> <h3>Please enter a name for your collection</h3> </cfif> </cfif> <!-------------------------------------------------------------------- Form to specify the collection name and action ---------------------------------------------------------------------> <form action="#CGI.SCRIPT_NAME" method="POST" > <select name="CollectionAction">...
  • Page 85: Cfcomponent

    cfcomponent Description Creates and defines a component object; encloses functionality that you build in CFML and enclose within tags. This tag contains one or more tags that define cffunction cffunction methods. Code within the body of this tag, other than tags, is executed when the cffunction component is instantiated.
  • Page 86 Attributes Attribute Req/Opt Default Description extends Optional Name of parent component from which to inherit methods and properties. output Optional Component Specifies whether constructor code in the component can body generate HTML output; does not affect output in the body displayable tags in the component.
  • Page 87: Cfcontent

    cfcontent Description Does either or both of the following: • Sets the MIME content encoding header for the current page • Sends the contents of a file from the server as the page output Note: This tag executes only if it is enabled in the ColdFusion Administrator. For more information, see Configuring and Administering ColdFusion MX.
  • Page 88 Attributes Attribute Req/Opt Default Description type Optional The MIME content type of the page, optionally followed by a semicolon and the character encoding. By default, ColdFusion sends pages as text/html content type in the UTF-8 character encoding. The content type determines how the browser or client interprets the page contents.
  • Page 89 Usage To set the character encoding (character set) of generated output, use code such as the following: <cfcontent type="text/html; charset=ISO-8859-1"> When ColdFusion processes an HTTP request, it determines the character encoding of the data returned in the HTTP response. By default, ColdFusion returns character data using the Unicode UTF-8 format (regardless of the value of an HTML tag in the page).
  • Page 90 <html> <body> <h3>cfcontent Example 2</h3> <p>This example shows how reset attribute changes output for text.</p> <p>reset = "Yes ": 123 <cfcontent type = "text/html" reset = "Yes ">456</p> <p>This example shows how reset attribute changes output for text.</p> <p>reset = "No ": 123 <cfcontent type = "text/html"...
  • Page 91: Cfcookie

    cfcookie Description Defines web browser cookie variables, including expiration and security options. Category Forms tags, Variable manipulation tags Syntax <cfcookie name = "cookie_name" value = "text" expires = "period" secure = "Yes" or "No" path = "url" domain = ".domain"> See also cfdump, cfparam, cfregistry, cfsavecontent, cfschedule, cfset...
  • Page 92 Attribute Req/Opt Default Description path Optional URL, within a domain, to which the cookie applies; typically a directory. Only pages in this path can use the cookie. By default, all pages on the server that set the cookie can access the cookie. path = "/services/login"...
  • Page 93 <!--- if the URL variable delcookie exists, set cookie expiration date to NOW ---> <cfif IsDefined("url.delcookie") is True> <cfcookie name = "TimeVisited" value = "#Now()#" expires = "NOW"> <cfelse> <!--- Otherwise, loop through list of visitors; stop when you match the string aol.com in a visitor’s e-mail address --->...
  • Page 94: Cfdefaultcase

    cfdefaultcase Description Used only inside the tag body. Contains code to execute when the expression specified cfswitch in the tag does not match a of the value specified by a tag. cfswitch cfcase Category Flow-control tags Syntax <cfdefaultcase> See also cfcase, cfswitch History...
  • Page 95: Cfdirectory

    cfdirectory Description Manages interactions with directories. Category File management tags Syntax <cfdirectory action = "directory action" directory = "directory name" name = "query name" filter = "list filter" mode = "permission" sort = "sort specification" newDirectory = "new directory name"> See also cffile History...
  • Page 96 Attribute Req/Opt Default Description mode Optional Used with . Permissions. Applies action = "create" only to UNIX and Linux. Octal values of chmod command. Assigned to owner, group, and other, respectively. For example: • 644: Assigns read/write permission to owner; read permission to group and other •...
  • Page 97 Note: If the cfdirectory tag does not appear to work, for example, if a list operation returns an empty result set, make sure that you have correct permissions to access the directory. For example, if you run ColdFusion as a service on Windows, it operates by default as System, and cannot access directories on a remote system or mapped drive;...
  • Page 98: Cfdump

    cfdump Description Outputs the elements, variables and values of most kinds of ColdFusion objects. Useful for debugging. You can display the contents of simple and complex variables, objects, components, user-defined functions, and other elements. Category Debugging tags, Variable manipulation tags Syntax <cfdump var = "#variable#"...
  • Page 99 If a table cell is empty, this tag displays "[empty string]". Example This example shows how to use this tag to display a URL variable. URL variables contain parameters that are passed in a URL string in a page request. <cfdump var="#URL#">...
  • Page 100: Cfelse

    cfelse Description Used as the last control block in a tag block to handle any case not identified by the cfif cfif tag or a tag. cfelseif Category Flow-control tags Syntax <cfif expression> HTML and CFML tags <cfelseif expression> HTML and CFML tags <cfelse>...
  • Page 101: Cfelseif

    cfelseif Description Used as a control block in a tag block to handle any case not identified by the tag or a cfif cfif tag. cfelseif Category Flow-control tags Syntax <cfif expression> HTML and CFML tags <cfelseif expression> HTML and CFML tags <cfelse>...
  • Page 102: Cferror

    cferror Description Displays a custom HTML page when an error occurs. This lets you maintain a consistent look and feel among an application’s functional and error pages. Category Exception handling tags, Extensibility tags, Application framework tags Syntax <cferror type = "a type" template = "template_path"...
  • Page 103 Usage Use this tag to provide custom error messages for pages in an application. You generally embed this tag in the Application.cfm file. For more information, see Chapter 14, “Handling Errors,” Developing ColdFusion MX Applications. To ensure that error pages display successfully, avoid using the tag to encode pages that cfencode include the...
  • Page 104 Page type Error variable Description Request and error.diagnostics Detailed error diagnostics from ColdFusion MX. Exception error.mailTo E-mail address (same as value in cferror.MailTo error.dateTime Date and time when error occurred. error.browser Browser that was running when error occurred. error.remoteAddress IP address of remote client. error.HTTPReferer Page from which client accessed link to page where error occurred.
  • Page 105 <h2>We’re sorry -- An Error Occurred</h2> <p> If you continue to have this problem, please contact #error.mailTo# with the following information:</p> <p> <ul> <li><b>Your Location:</b> #error.remoteAddress# <li><b>Your Browser:</b> #error.browser# <li><b>Date and Time the Error Occurred:</b> #error.dateTime# <li><b>Page You Came From:</b> #error.HTTPReferer# <li><b>Message Content</b>: <p>#error.diagnostics#</p>...
  • Page 106: Cfexecute

    cfexecute Description Executes a ColdFusion developer-specified process on a server computer. Category Extensibility tags, Flow-control tags Syntax <cfexecute name = " ApplicationName " arguments = "CommandLine Arguments" outputFile = "Output file name" variable = "variable name" timeout = "Timeout interval"> </cfexecute>...
  • Page 107 Attribute Req/Opt Default Description variable Optional Variable in which to put program output. If no outputfile is specified, output is displayed on page variable attribute from which it was called. timeout Optional Length of time, in seconds, that ColdFusion waits for output from the spawned program.
  • Page 108: Cfexit

    cfexit Description This tag aborts processing of the currently executing CFML custom tag, exits the page within the currently executing CFML custom tag, or re-executes a section of code within the currently executing CFML custom tag. Category Debugging tags, Flow-control tags Syntax <cfexit method = "method">...
  • Page 109 <p>cfexit is used primarily to perform a conditional stop of processing inside a custom tag. cfexit returns control to the page that called that custom tag, or in the case of a tag called by another tag, to the calling tag. <!--- cfexit can be used within a CFML custom tag, as follows: --->...
  • Page 110: Cffile

    cffile Description Manages interactions with server files. The following sections describe the actions of the tag: cffile • on page 113 cffile action = "append" • on page 115 cffile action = "copy" • on page 116 cffile action = "delete" •...
  • Page 111 • Changed directory path requirements for the attribute: a directory path that you destination specify in the attribute does not require a trailing slash. destination • Deprecated the value of the attribute. system attributes • Deprecated the value of the attribute.
  • Page 112 <textarea name="the_text" cols="40" rows="5"> <cfif readText is not ""> <cfoutput>#readText#</cfoutput> </cfif></textarea> <!--- select from the actions depending on whether the file exists ---> <select name="action"> <cfif fileExists is "no"> <option value="new">Make new file </cfif> <cfif fileExists is "yes"> <option value="add">Add to existing file <option value="delete">Delete file <option value="read">Read existing file </cfif>...
  • Page 113: Cffile Action = "Append

    cffile action = "append" Description Appends text to a text file on the server. Syntax <cffile action = "append" file = "full_path_name" output = "string" addNewLine = "Yes" or "No" attributes = "file_attributes_list" mode = "mode" charset = "charset_option" > See also cfdirectory History...
  • Page 114 Attribute Req/Opt Default Description attributes Optional Applies to Windows. A comma-delimited list of attributes to set on the file. If omitted, the file's attributes are maintained. Each value must be specified explicitly. For example, if you specify , all other attributes are attributes = "readOnly"...
  • Page 115: Cffile Action = "Copy

    cffile action = "copy" Description Copies a file from one directory to another on the server. Syntax <cffile action = "copy" source = "full_path_name" destination = "full_path_name" mode = "mode" attributes = "file_attributes_list"> See also cfdirectory History See the History section of the main tag page.
  • Page 116: Cffile Action = "Delete

    cffile action = "delete" Description Deletes a file on the server. Syntax <cffile action = "delete" file = "full_path_name"> See also cfdirectory Attributes Attribute Req/Opt Default Description action Required Type of file manipulation that the tag performs. file Required Pathname of the file to delete. If not an absolute path (starting a with a drive letter and a colon, or a forward or backward slash), it is relative to the ColdFusion temporary directory, which is returned by the...
  • Page 117: Cffile Action = "Move

    cffile action = "move" Description Moves a file from one location to another on the server. Syntax <cffile action = "move" source = "full_path_name" destination = "full_path_name" mode = "mode" attributes = "file_attributes_list" charset = "charset_option"> See also cfdirectory History See the History section of the main tag page.
  • Page 118 Attribute Req/Opt Default Description attributes Optional Applies to Windows. A comma-delimited list of attributes to set on the file. If omitted, the file's attributes are maintained. Each value must be specified explicitly. For example, if you specify , all other attributes are attributes = "readOnly"...
  • Page 119: Cffile Action = "Read

    cffile action = "read" Description Reads a text file on the server. The file is read into a dynamic, local variable that you can use in the page. For example: • Read a text file; insert the file’s contents into a database •...
  • Page 120 Usage The following example creates a variable named Message for the contents of the file message.txt: <cffile action = "read" file = "c:\web\message.txt" variable = "Message"> The variable can be used in the page. For example, you could display the contents of the Message message.txt file in the final web page as follows: <cfoutput>#Message#</cfoutput>...
  • Page 121: Cffile Action = "Readbinary

    cffile action = "readBinary" Description Reads a binary file (such as an executable or image file) on the serve, into a binary object parameter that you can use in the page. To send it through a web protocol (such as HTTP or SMTP) or store it in a database, first convert it to Base64 using the function.
  • Page 122: Cffile Action = "Rename

    cffile action = "rename" Description Renames or moves a file on the server. Syntax <cffile action = "rename" source = "full_path_name" destination = "path_name" mode = "mode" attributes = "file_attributes_list"> See also cfdirectory History See the History section of the main tag page.
  • Page 123 <cffile action = "rename" source = "c:\files\memo\keymemo.doc" destination = "c:\files\memo\oldmemo.doc"> cffile...
  • Page 124: Cffile Action = "Upload

    cffile action = "upload" Description Copies a file to a directory on the server. Syntax <cffile action = "upload" fileField = "formfield" destination = "full_path_name" nameConflict = "behavior" accept = "mime_type/file_type" mode = "permission" attributes = "file_attribute_or_list"> See also cfdirectory History See the History section of the main tag page.
  • Page 125 Attribute Req/Opt Default Description mode Optional Applies only to UNIX and Linux. Permissions. Octal values of chmod command. Assigned to owner, group, and other, respectively. For example: • 644: Assigns read/write permission to owner; read permission to group and other •...
  • Page 126 Parameter Description fileWasSaved Whether ColdFusion saves a file (Yes or No) oldFileSize Size of a file that was overwritten in the file upload operation serverDirectory Directory of the file saved on the server serverFile Filename of the file saved on the server serverFileExt Extension of the uploaded file on the server (without a period) serverFileName...
  • Page 127: Cffile Action = "Write

    cffile action = "write" Description Writes a text file on the server, based on dynamic content. You can create static HTML files from the content, or log actions in a text file. Syntax <cffile action = "write" file = "full_path_name" output = "content"...
  • Page 128 Attribute Req/Opt Default Description attributes Optional Applies to Windows. A comma-delimited list of attributes to set on the file. If omitted, the file's attributes are maintained. Each value must be specified explicitly. For example, if you specify , all other attributes are attributes = "readOnly"...
  • Page 129 <cffile action = "append" destination = "/home/tomj/testing.txt" mode = 666 output = "Is this a test?"> This example uploads a file and gives it the permissions owner/group/other = read/write/execute): cffile action = "upload" fileField = "fieldname" destination = "/tmp/program.exe" mode = 777> cffile...
  • Page 130: Cfflush

    cfflush Description Flushes currently available data to the client. Category Data output tags, Page processing tags Syntax <cfflush interval = "integer number of bytes"> See also cfcache, cfheader, cfinclude, cfsetting, cfsilent Attributes Attribute Req/Opt Default Description interval Optional Integer. Flushes output each time this number of bytes becomes available.
  • Page 131 <p>It will take us a little while to calculate your ten magic numbers. It takes a lot of work to find numbers that truly fit your personality. So relax for a minute or so while we do the hard work for you.</p> <H2>We are sure you will agree it was worth the short wait!</H2>...
  • Page 132: Cfform

    cfform Description Builds a form with CFML custom control tags; these provide more functionality than standard HTML form input elements. Category Forms tags Syntax <cfform name = "name" action = "form_action" preserveData = "Yes" or "No" onSubmit = "javascript" target = "window_name" encType = "type"...
  • Page 133 Attribute Req/Opt Default Description preserveData Optional When the cfform action attribute posts back to the same page as the form, this determines whether to override the control values with the submitted values. • false: values specified in the control tag attributes are used •...
  • Page 134 Usage This tag requires an end tag. Some custom control tags that you can use within this tag require the client to download a Java applet; they might execute slightly more slowly than using an HTML form element to get the same information.
  • Page 135 • HTML tags that can ordinarily be put within the HTML tag. For example, you can use form the HTML tag to create a submit button in a , without the other features of input cfform cfinput <cfform> <input type = "Submit" value = " update... "> </cfform>...
  • Page 136 </tr> <tr> <td> <h4>This example shows the use of the cfslider tag.</h4> <p>Rate your approval of this example from 1 to 10 by sliding control. <p>1 <cfslider name = "sampleSlider" label = "Sample Slider" range = "1,10" message = "Please enter a value from 1 to 10" scale = "1"...
  • Page 137: Cfftp

    cfftp Description Lets users implement File Transfer Protocol (FTP) operations. Category File management tags, Internet Protocol tags Syntax The tag syntax depends on the attribute value. See the following sections: action • “cfftp: Opening and closing FTP server connections” on page 138 •...
  • Page 138: Cfftp: Opening And Closing Ftp Server Connections

    cfftp: Opening and closing FTP server connections Description To establish a connection with an FTP server, you use the action with a open connection attribute. Syntax <cfftp action = "action" username = "name" password = "password" server = "server" timeout = "timeout in seconds" port = "port"...
  • Page 139 Attribute Req/Opt Default Description stopOnError Optional • Yes: halts processing, displays an appropriate error. • No: populates these variables: - cfftp.succeeded – Yes or No. - cfftp.errorCode – Error number. See the IETF Network Working Group RFC 959: File Transfer Protocol (FTP) www.ietf.org/rfc/rfc0959.txt.
  • Page 140 stopOnError = "Yes" name = "ListFiles" directory = "/" connection = "my_query"> <cfoutput query = "ListFiles"> #name#<br> </cfoutput> <p>Close the connection: <cfftp action = "close" connection = "My_query" stopOnError = "Yes"> <p>Did it succeed? <cfoutput>#cfftp.succeeded#</cfoutput> Chapter 2: ColdFusion Tags...
  • Page 141: Cfftp: Connection: File And Directory Operations

    cfftp: Connection: File and directory operations Description Use this form of the tag to perform file and directory operations with cfftp cfftp Syntax <cfftp action = "action" username = "name" password = "password" name = "query_name" server = "server" ASCIIExtensionList = "extensions" transferMode = "mode"...
  • Page 142 Attribute Req/Opt Default Description ASCIIExtension Optional txt;htm;html; Delimited list of file extensions that force ASCII List cfm;cfml; transfer mode, if transferMode = "auto" shtm;shtml; css;asp;asa transferMode Optional Auto • ASCII FTP transfer mode • Binary FTP transfer mode • Auto FTP transfer mode failIfExists Optional •...
  • Page 143 variable provides the return value for these actions: cfftp.returnValue • getCurrentDir • getCurrentURL • existsDir • existsFile • exists For more information, see Developing ColdFusion MX Applications. Caution: Object (file and directory) names are case-sensitive. Action (cfftp.ReturnValue variable) The results of an action determine the value of the variable.
  • Page 144 action = "close" stopOnError = "Yes"> <p>Did it succeed? <cfoutput>#cfftp.succeeded#</cfoutput> Chapter 2: ColdFusion Tags...
  • Page 145: Cfftp Action = "Listdir

    cfftp action = "listDir" Description To access the columns in a query object, use this tag with = " action listDir" Usage When you use this action, you must specify a value for the attribute. This value holds the name results of the action in a query object.
  • Page 146: Cffunction

    cffunction Description Defines a function that you can call in CFML. Required to defined ColdFusion component methods. Category Extensibility tags Syntax <cffunction name = "methodName" returnType = "dataType" roles = "securityRoles" access = "methodAccess" output = "yes" or "no" displayName = "name" Hint = "hint text">...
  • Page 147 Attribute Req/Opt Default Description roles Optional "" (empty) A comma-delimited list of ColdFusion security roles that can invoke the method. Only users who are logged in with the specified roles can execute the function. If this attribute is omitted, all users can invoke the method. access Optional public...
  • Page 148 access="remote" returnType="query" hint="This query returns all records in the employee database. It can drill-down or narrow the search, based on optional input parameters."> For information on using the tag for ColdFusion components, see Chapter 11, cffunction “Building and Using ColdFusion Components,” in Developing ColdFusion MX Applications.
  • Page 149: Cfgraph

    cfgraph Description This tag is deprecated. Use the , and tags instead. cfchart cfchartdata cfchartseries Displays data graphically. History ColdFusion MX: Deprecated this tag. It works differently than it did in ColdFusion 5, and it might not work in later releases. The incompatibilities between the ColdFusion MX implementation and earlier implementations of this tag are as follows: cfgraph tag attribute...
  • Page 150 cfgraph tag attribute ColdFusion MX functionality Showvaluelabel • yes: displays values on mouse-click; • no: suppresses value displays • rollover: displays values on mouse-over. Valuelocation Ignored URL of page to open if any item in the graph is clicked. The following variables may be used within the URL; they are substituted with real values before the URL is accessed: •...
  • Page 151: Cfgraphdata

    cfgraphdata Description This tag is deprecated. Use the , and tags instead. cfchart cfchartdata cfchartseries Displays a data point in a graph. Used within the tag. cfgraph History ColdFusion MX: Deprecated this tag. It works differently than in ColdFusion 5 and might not work in later releases.
  • Page 152: Cfgrid

    cfgrid Description Used within the tag. Puts a grid control (a table of data) in a ColdFusion form. To specify cfform grid columns and row data, use the tags, or use the cfgridcolumn cfgridrow query attribute, with or without tags. cfgridcolumn Category Forms tags...
  • Page 153 deleteButton = "text" sortAscendingButton = "text" sortDescendingButton = "text"> </cfgrid> See also cfgridcolumn, cfgridrow, cfgridupdate, cfapplet, cfform, cfinput, cfselect, cfslider, cftextinput, cftree, cftreeitem History ColdFusion MX: Changed the attribute: ColdFusion does not use the rowHeaderWidth attribute. You can omit it. rowHeaderWidth Attributes Attribute...
  • Page 154 Attribute Req/Opt Default Description sort Optional The sort button performs simple text sort on column. User can sort columns by clicking column head or by clicking sort buttons. Not valid with selectmode=browse • Yes: sort buttons display on grid control •...
  • Page 155 Attribute Req/Opt Default Description rowHeight Optional Minimum row height, in pixels, of grid control. Used with cfgridcolumn type = "Image" defines space for graphics to display in row. rowHeaders Optional • Yes: displays a column of numeric row labels in grid control •...
  • Page 156: How Data Is Returned From Cfgrid

    Attribute Req/Opt Default Description selectMode Optional Browse Selection mode for items in grid control. • Edit: user can edit grid data. Selecting a cell opens the editor for the cell type. • Single: user selections are limited to selected cell. •...
  • Page 157 Simple selection data (SelectMode = Single, Column, or Row) The data that form variables return to the 's action page contains information about cfform which cells the user selected. In general, ColdFusion makes this data available in the action page, as ColdFusion variables in the Form scope, with the naming convention form.#GridName#.#ColumnName# Each...
  • Page 158: Using The Href Attribute

    Clicking the submit button while editing a grid cell occasionally causes the cell changes to be lost. To ensure that changes are submitted properly, Macromedia recommends that after user updates data in a cell, they click another cell before submitting the form.
  • Page 159 <cfgridupdate grid = "FirstGrid" dataSource = "cfsnippets" tableName = "CourseList" keyOnly = "Yes"> </cfif> <!--- query the database to fill up the grid ---> <cfquery name = "GetCourses" dataSource = "cfsnippets"> SELECT Course_ID, Dept_ID, CorNumber, CorName, CorLevel, CorDesc FROM CourseList ORDER by Dept_ID ASC, CorNumber ASC </cfquery>...
  • Page 160 </html> Chapter 2: ColdFusion Tags...
  • Page 161: Cfgridcolumn

    cfgridcolumn Description Used with the tag in a . Use this tag to specify column data in a control. cfgrid cfform cfgrid The font and alignment attributes used in override global font or alignment cfgridcolumn settings defined in cfgrid Category Forms tags Syntax <cfgridcolumn...
  • Page 162 Attribute Req/Opt Default Description width Optional; Column head Column width, in pixels. width Description font Optional As specified Font of data in column. cfgrid fontSize Optional As specified Size of text in column. cfgrid italic Optional As specified • Yes: displays grid control text in italics cfgrid •...
  • Page 163 Attribute Req/Opt Default Description select Optional • Yes: user can select the column in grid control. • No: user cannot edit column, regardless of cfgrid values. If insert delete cfgrid selectMode , this value is ignored. "Row" "Browse" display Optional •...
  • Page 164 Attribute Req/Opt Default Description values Optional Formats cells in column as drop-down list boxes; specify items in drop-down list. Example: values = "arthur, scott, charles, 1-20, mabel" valuesDisplay Optional Maps elements in values attribute to string to display in drop-down list. Delimited strings and/or numeric range(s).
  • Page 165 numberFormat mask characters You can use the following attribute mask characters, which correspond to those in numberFormat function, to format output in U.S. numeric and currency styles. For more NumberFormat information, see on page 631. (This tag does not support international number NumberFormat formatting.) Character Meaning...
  • Page 166: Cfgridrow

    cfgridrow Description Lets you define a cfgrid that does not use a query as source for row data. If a query attribute is specified in cfgrid, the cfgridrow tags are ignored. Category Forms tags Syntax <cfgridrow data = "col1, col2, ..."> See also cfgrid, cfgridcolumn, cfgridupdate, cfapplet, cfform, cfinput, cfselect, cfslider, cftextinput,...
  • Page 167 <cfif isdefined("form.gridentered") is true> <cfgridupdate grid="FirstGrid" datasource="cfsnippets" tablename="CourseList" keyonly="Yes"> </cfif> <!--- query the database to fill up the grid ---> <cfquery name="GetCourses" datasource="cfsnippets"> select Course_ID, Dept_ID, CorNumber, CorName, CorLevel, CorDesc FROM CourseList ORDER by Dept_ID ASC, CorNumber ASC </cfquery> <html> <head>...
  • Page 168 <p>This grid shows how the same grid can be built using cfgridrow with cfloop (i.e., defining query external to cfgrid, rather than within cfgrid).</p> <!--- cfgridcolumn is used to define container columns. cfgridrow is used to define the data put into those containers ---> <cfgrid name="SecondGrid"...
  • Page 169: Cfgridupdate

    cfgridupdate Description Used within a tag. Updates data sources directly from edited grid data. This tag provides cfgrid a direct interface with your data source. This tag applies row actions first, then row actions, then row actions. If it delete insert update encounters an error, it stops processing rows.
  • Page 170 Attribute Req/Opt Default Description tableQualifier Optional Table qualifier, if supported. Purpose: • SQL Server and Oracle driver: name of database that contains table • Intersolv dBASE driver: directory of DBF files keyOnly Applies to the update action: • Yes: the WHERE criteria are limited to the key values •...
  • Page 171: Cfheader

    cfheader Description Generates custom HTTP response headers to return to the client. Category Data output tags, Page processing tags Syntax <cfheader name = "header_name" value = "header_value" charset="charset"> <cfheader statusCode = "status_code" statusText = "status_text"> See also cfcache, cfflush, cfhtmlhead, cfinclude, cfsetting, cfsilent, cfcontent History ColdFusion MX 6.1: Changed behavior for the...
  • Page 172 Attribute Req/Opt Default Description statusCode Required if Number. HTTP status code name specified statusText Optional Explains status code Usage If you use this tag after the tag on a page, an error is thrown. cfflush Example <h3>cfheader Example</h3> <p>cfheader generates custom HTTP response headers to return to the client. <p>This example forces browser client to purge its cache of requested file.
  • Page 173: Cfhtmlhead

    cfhtmlhead Description Writes text to the section of a generated HTML page. It is useful for embedding JavaScript head code, or putting other HTML tags, such as , or in an HTML page meta link title base header. Category Page processing tags Syntax <cfhtmlhead text = "text">...
  • Page 174: Cfhttp

    cfhttp Description Generates an HTTP request and handles the response from the server. Category Forms tags, Internet Protocol tags Syntax <cfhttp url = "server_URL" port = "port_number" method = "method_name" proxyServer = "hostname" proxyPort = "port_number" proxyUser = "username" proxyPassword = "password" username = "username"...
  • Page 175 ColdFusion MX: • Added the attributes. charset firstrowasheaders • Changed Secure Sockets Layer (SSL) support: ColdFusion uses the Sun JSSE library, which supports 128-bit encryption, to support SSL. Attributes The following attributes control the HTTP transaction and can be used for all HTTP methods: Attribute Req/Opt Default Description...
  • Page 176 Attribute Req/Opt Default Description proxyUser User name to provide to the proxy server. proxyPassword Opt Password to provide to the proxy server. username A username. May be required by server. password A password. May be required by server userAgent Cold Text to put in the user agent request header.
  • Page 177 Attribute Req/Opt Default Description throwOnError • Yes if the server returns an error response code, throws an exception that can be caught using the cftry or ColdFusion error pages. cfcatch • No does not throw an exception if an error response is returned.
  • Page 178 The following attribute is used with the PUT method to determine how to send data specified with httpparam type="formField" Attribute Req/Opt Default Description multipart Optional Tells ColdFusion to send all data specified by cfhttpparam tags as multipart form data, with a (Sends as type="formField"...
  • Page 179 The following attributes tell ColdFusion to convert the HTTP response body into a ColdFusion query object. They can be used with the GET and POST methods only: Attribute Req/Opt Default Description name Tells ColdFusion to create a query object with the given name from the returned HTTP response body.
  • Page 180 The HTTP protocol is the backbone of the World Wide Web and is used for every web transaction. Because the tag can generate most types of requests, it provides significant cfhttp flexibility. Possible uses include: • Interacting with dynamic web sites and services that are not available as web services. (Use the tag to access SOAP web services.) cfinvoke •...
  • Page 181 NTLM or Digest Authentication with proxy servers. If a cfhttp proxy server requires authentication, it must allow Basic Authentication. Example <!--- This example displays the information provided by the Macromedia Designer & Developer Center XML feed, cfhttp...
  • Page 182 See http://www.macromedia.com/desdev/articles/xml_resource_feed.html for more information on this feed ---> <!--- Set the URL address ---> <cfset urlAddress="http://www.macromedia.com/desdev/resources/macromedia_resources .xml"> <!--- Use the CFHTTP tag to get the file content represented by urladdress Note that />, not an end tag. terminates this tag --->...
  • Page 183: Cfhttpparam

    cfhttpparam Description Allowed inside tag bodies only. Required for POST operations. Optional for all cfhttp cfhttp others. Specifies parameters to build an HTTP request. Category Forms tags, Internet Protocol tags Syntax <cfhttpparam type = "transaction type" name = "data name" value = "data value"...
  • Page 184 Attributes Attribute Req/Opt Default Description type Required Information type: • Header: The parameter specifies an HTTP header. ColdFusion does not URL encode the header. • CGI: Specifies an HTTP header. ColdFusion URL encodes the header by default. • Body: Specifies the body of the HTTP request. ColdFusion does not URL encode the body contents.
  • Page 185 • attribute cannot be used with additional attributes, or with body type body type file attributes. formField type • attributes cannot be used with the tag TRACE method. body type cfhttp • attribute is only meaningful with the tag POST and PUT methods. file type cfhttp •...
  • Page 186 <br>CGI variable: #CGI.cgi_test#<br> <br>Note that the CGI variable is URL encoded. </cfoutput> Chapter 2: ColdFusion Tags...
  • Page 187: Cfif

    cfif Description Creates simple and compound conditional statements in CFML. Tests an expression, variable, function return value, or string. Used, optionally, with the tags. cfelse cfelseif Category Flow-control tags Syntax <cfif expression> HTML and CFML tags <cfelseif expression> HTML and CFML tags <cfelse>...
  • Page 188 <cfif Trim(City) is "San Diego"> <br><b>Name/Address:</b>#Name#, #Address1#, #City#, #State# <br><b>Contact:</b> #Contact# <br> </cfif> </cfoutput> <hr> <p>If we would like more than one condition to be the case, we can ask for a list of the centers in San Diego <b>OR</b> Santa Ana. If the center does not follow this condition, we can use CFELSE to show only the names and cities of the other centers.
  • Page 189: Cfimpersonate

    cfimpersonate Description This tag is obsolete. Use the newer security tools; see “Authentication functions” on page 367 Chapter 16, “Securing Applications,” in Developing ColdFusion MX Applications. History ColdFusion MX: This tag is obsolete. It does not work in ColdFusion MX and later releases. cfimpersonate...
  • Page 190: Cfimport

    cfimport Description You can use the tag to import either of the following: cfimport • All ColdFusion pages in a directory, as a tag custom tag library. • A Java Server Page (JSP) tag library. A JSP tag library is a packaged set of tag handlers that conform to the JSP 1.1 tag extension API.
  • Page 191 JSP tags have fixed attributes; however, if the tag supports runtime attribute expressions, most tag libraries support the use of the syntax #expressions# To reference a JSP tag in a CFML page, use the syntax . Set the prefix value in <prefix:tagname>...
  • Page 192: Cfinclude

    cfinclude Description Embeds references to ColdFusion pages in CFML. You can embed tags recursively. cfinclude For another way to encapsulate CFML, see on page 250. (A ColdFusion page was cfmodule formerly sometimes called a ColdFusion template or a template.) Category Flow-control tags, Page processing tags...
  • Page 193: Cfindex

    cfindex Description Populates a Verity search engine collection with an index of documents on a file system or of ColdFusion query result sets. A collection must exist before it can be populated. A collection can be indexed in the following ways: •...
  • Page 194 Attributes Attribute Req/Opt Default Description collection Required • Name of a collection that is registered by ColdFusion; for example, "personnel" • Name and absolute path of a collection that is not registered by ColdFusion; for example: "e:\collections\personnel" action Depends on •...
  • Page 195 Attribute Req/Opt Default Description query Required if Query against which collection is generated type = ; see "custom" Usage section recurse Optional • Yes: if , directories below the path type = "path" specified in key are included in indexing operation •...
  • Page 196 For information on the file types you can use with the Verity search engine, see Article 22492, ColdFusion Server (versions 4.5 and higher): Supported File Types for Verity, on the Macromedia ColdFusion Support Center, at www.macromedia.com/support/coldfusion/. Example <!--- for ACTION=UPDATE ----------------------------------------------->...
  • Page 197 urlpath="http://localhost/cfdocs/snippets" custom1="custom1" custom2="custom2" recurse="no" extensions=".htm, .html, .cfm, .cfml" > <!--- for ACTION=UPDATE, #4 (TYPE=PATH) (extensions are files with no extension) ----> <cfindex collection="snippets" action="update" type="path" key="c:\inetpub\wwwroot\cfdocs\snippets" urlpath="http://localhost/cfdocs/snippets" custom1="custom1" custom2="custom2" recurse="no" extensions="*." > <!--- for ACTION=UPDATE, #5 (TYPE=PATH) (extensions are files with any extension) ----> <cfindex collection="snippets"...
  • Page 198 query="book"> <!--- for ACTION=REFRESH-----------------------------------------------> <!--- ACTION=REFRESH, #1 (TYPE=FILE) ----> <cflock name="verity" timeout="60"> <cfindex collection="snippets" action="Refresh" type="file" key="c:\inetpub\wwwroot\cfdocs\snippets\abs.cfm" urlpath="http://localhost/" custom1="custom1" custom2="custom2" > </cflock> <!--- ACTION=REFRESH, #2 (TYPE=PATH) ----> <cflock name="verity" timeout="60"> <cfindex collection="snippets" action="refresh" type="path" key="c:\inetpub\wwwroot\cfdocs\snippets" urlpath="http://localhost/cfdocs/snippets/" custom1="custom1" custom2="custom2" recurse="yes" extensions=".htm,.html,.cfm,.cfml" > </cflock>...
  • Page 199 datasource="book"> select * from book where bookid='file' </cfquery> <cfoutput query="book"> --#description#-- <br> </cfoutput> <cfindex collection="snippets" action="delete" type="file" query="book" key="description" > </cflock> <!--- ACTION=DELETE, #3 (TYPE=PATH) ----> <cflock name="verity" timeout="60"> <cfindex collection="snippets" action="delete" type="path" key="c:\inetpub\wwwroot\cfdocs\snippets" extensions=".cfm" recurse="no"> </cflock> <!--- ACTION=DELETE, #4 (TYPE=PATH) (key is a query result set column) ----> <cflock name="verity"...
  • Page 200 <!--- for ACTION=PURGE-----------------------------------------------> <cflock name="verity" timeout="60"> <cfindex action="purge" collection="snippets"> </cflock> Chapter 2: ColdFusion Tags...
  • Page 201: Cfinput

    cfinput Description Used within the tag, to place radio buttons, check boxes, or text boxes on a form. cfform Provides input validation for the specified control type. Category Forms tags Syntax <cfinput type = "input_type" name = "name" value = "initial_value" required = "Yes"...
  • Page 202 Attribute Req/Opt Default Description validate Optional Verifies a value’s format: • date: US date mm/dd/yyyy • eurodate: European date dd/mm/yyyy • time: time hh:mm:ss • float: floating point entry • integer: integer entry • telephone: telephone . Separator: hyphen or ###-###-#### blank.
  • Page 203 • class • • onBlur • onChange • onClick • onDblclick • onFocus • style • tabIndex Usage If the attribute is true and the form posts back to the same page, the cfform preserveData posted value of the cfinput control is used, instead of its Value or Checked attribute. check box or radio type values match the submitted value for the control, ColdFusion cfinput checks their values.
  • Page 204 message = "Enter a correctly formatted date (dd/mm/yy)" validate = "date" required = "No"> <input type = "Submit" name = "" value = "send my information"> </cfform> Chapter 2: ColdFusion Tags...
  • Page 205: Cfinsert

    cfinsert Description Inserts records in data sources from data in a ColdFusion form or form Scope. Category Database manipulation tags Syntax <cfinsert dataSource = "ds_name" tableName = "tbl_name" tableOwner = "owner" tableQualifier = "tbl_qualifier" username = "username" password = "password" formFields = "formfield1, formfield2, ...">...
  • Page 206 Example <!--- This shows how to use cfinsert instead of cfquery to put data in a datasource. ---> <!--- if form.POSTED exists, we insert new record, so begin cfinsert tag ---> <cfif IsDefined ("form.posted")> <cfinsert dataSource = "cfsnippets" tableName = "Comments" formFields = "Email,FromUser,Subject,MessText,Posted">...
  • Page 207 <input type = "hidden" name = "posted" value = "<cfoutput>#Now()#</cfoutput>"> </pre> <input type = "Submit" name = "" value = "insert my comment"> </form> cfinsert...
  • Page 208: Cfinvoke

    cfinvoke Description Does either of the following: • Invokes a component method from within a ColdFusion page or component. • Invokes a web service. This tag works as follows: • Transiently instantiates a component or web service and invokes a method on it •...
  • Page 209 inputParam1 = "value1" inputParam2 = "value2" returnVariable = "var_name" ...> <!--- Syntax 4A - this syntax invokes a component. This syntax shows instantiation with the cfobject tag. This cfinvoke syntax applies to instantiating a component with the cfobject tag and to instantiating a component with the createobject function.
  • Page 210 Attributes Attribute Req/Opt Default Description component See Usage String or component object; a reference to a section component, or component to instantiate. method See Usage Name of a method. For a web service, the section name of an operation. returnVariable Optional Name of a variable for the invocation result.
  • Page 211 This attribute is For this tag syntax: cfinvoke required, optional, ignored, or invalid: Syntax 1 Syntax 2 Syntax 3 Syntax 4A Syntax 4B username Ignored Ignored Optional Ignored Optional password Ignored Ignored Optional Ignored Optional webservice Ignored Ignored Required Ignored Required timeout Invalid...
  • Page 212 </cfinvoke> <cfoutput>#res#</cfoutput> Example2 This example uses Syntax 1. <!--- passing the arguments using argumentCollection ---> <cfset args = StructNew()> <cfset args.symbol = "macr"> <cfinvoke component="nasdaq.quote" method="getLastTradePrice" argumentCollection="#args#" returnVariable="res"> <cfoutput>#res#</cfoutput> Example3 This example uses Syntax 2. <!--- called only from within a component, MyComponent---> <cfinvoke method = "a method name of MyComponent"...
  • Page 213: Cfinvokeargument

    cfinvokeargument Description Passes the name and value of a parameter to a component method or a web service. This tag is used within the tag. cfinvoke Category Extensibility tags Syntax <cfinvokeargument name="argument name" value="argument value"> See also cfargument, cfcomponent, cffunction, cfinvoke, cfobject, cfproperty, cfreturn History ColdFusion MX: Added this tag.
  • Page 214 name="sourcedata" value="Hello world, friend"> </cfinvoke> <cfoutput>#varName#</cfoutput> Chapter 2: ColdFusion Tags...
  • Page 215: Cfldap

    cfldap Description Provides an interface to a Lightweight Directory Access Protocol (LDAP) directory server, such as the Netscape Directory Server. Category Forms tags, Internet Protocol tags Syntax <cfldap server = "server_name" port = "port_number" username = "name" password = "password" action = "action"...
  • Page 216 Attributes Attribute Req/Opt Default Description server Required Host name or IP address of LDAP server. port Optional Port username Required if (anonymous) User ID secure = "CFSSL_BASIC" password Required if Password that corresponds to user name. secure = , V2 encrypts the secure = "CFSSL_BASIC"...
  • Page 217 Attribute Req/Opt Default Description sort Optional Attribute(s) by which to sort query results. Use a comma delimiter. sortControl Optional • nocase: case-insensitive sort • asc: ascending (a to z) case-sensitive sort • desc: descending (z to a) case-sensitive sort You can enter a combination of sort types; for example, sortControl = "nocase, asc"...
  • Page 218 Attribute Req/Opt Default Description separator Optional , [comma] Delimiter to separate attribute values of multi-value attributes. Used by , and actions, query modify and by to output multi-value attributes. cfldap For example, if $ (dollar sign), the attributes attribute could be "objectclass = top$person"...
  • Page 219 <p>Provides an interface to LDAP directory servers. The example uses the University of Connecticut public LDAP server. For more public LDAP servers, see <a href="http://www.emailman.com">http://www.emailman.com</a>.</p> <p>Enter a name and search the public LDAP resource. An asterisk before or after the name acts as a wildcard.</p> <!--- If form.name exists, the form was submitted;...
  • Page 220: Cflocation

    cflocation Description Stops execution of the current page and opens a ColdFusion page or HTML file. Category Flow-control tags, Page processing tags Syntax <cflocation url = "url" addToken = "Yes" or "No"> See also cfabort, cfbreak, cfexecute, cfexit, cfif, cfloop, cfswitch, cfthrow, cftry Attributes Attribute...
  • Page 221: Cflock

    cflock Description Ensures the integrity of shared data. Instantiates the following kinds of locks: • Exclusive allows single-thread access to the CFML constructs in its body. The tag body can be executed by one request at a time. No other requests can start executing code within the tag while a request has an exclusive lock.
  • Page 222 Attribute Req/Opt Default Description throwOnTimeout Optional How timeout conditions are handled. • Yes: exception is generated for the timeout. • No: execution continues past this tag. type Optional Exclusive • readOnly: lets more than one request read shared data. • exclusive: lets one request read or write shared data. Note: Limit the scope of code that updates shared data structures, files, and CFXs.
  • Page 223 • Chapter 15, “Using Persistent Data and Locking,” in Developing ColdFusion MX Applications • Article #20370, ColdFusion Locking Best Practices, on the Macromedia website at www.macromedia.com/support/service/ Example <!--- This example shows how cflock can guarantee consistency of data updates to variables in the Application, Server, and Session scopes. --->...
  • Page 224 <!--- Copy the following code into an Application.cfm file in the application root directory. ---> <!---------------- beginning of Application.cfm code ---------------> <!--- cfapplication defines scoping for a ColdFusion application and enables or disables storing of application and session variables. Put this tag in a special file called Application.cfm. It is run before any other CF page in its directory.
  • Page 225 <cfelse> <!--- Show the form only if it has not been submitted. ---> <cflock scope = "Application" timeout = "30" type = "Readonly"> <cfoutput> E-Turtleneck has sold #application.number# turtlenecks to date. </cfoutput> </cflock> <form method="post" action="cflocktest.cfm"> <p>Congratulations! You selected the most comfortable turtleneck in the world.
  • Page 226: Cflog

    cflog Description Writes a message to a log file. Category Data output tags Syntax <cflog text = "text" log = "log type" file = "filename" type = "message type" application = "application name yes or no"> See also cfcol, cfcontent, cfoutput, cftable History ColdFusion MX: Deprecated the...
  • Page 227 Usage This tag logs custom messages to standard or custom log files. You can specify a file for the log message or send messages to the default application or scheduler log. The log message can include ColdFusion expressions. Log files must have the suffix .log and must be located in the ColdFusion log directory.
  • Page 228: Cflogin

    cflogin Description A container for user login and authentication code. ColdFusion runs the code in this tag if a user is not already logged in. You put code in the tag that authenticates the user and identifies the user with a set of roles. Used with tag.
  • Page 229 tag has a built-in structure that contains two variables, cflogin cflogin cflogin.name if the page is executing in response to any of the following: cflogin.password, • Submission of a form that contains input fields with the names j_username j_password • A request that uses CFHTTP Basic authentication, and therefore includes an Authorization header with the username and password.
  • Page 230: Cfloginuser

    cfloginuser Description Identifies an authenticated user to ColdFusion. Specifies the user ID and roles. Used within a tag. cflogin Category Extensibility tags Syntax <cfloginuser name = "name" password = "password-string" roles = "roles"> See also Chapter 16, cflogin, cflogout, GetAuthUser, IsUserInRole, cfapplication, “Securing Applications,”...
  • Page 231: Cflogout

    cflogout Description Logs the current user out. Removes knowledge of the user ID, password, and roles from the server. If you do not use this tag, the user is automatically logged out when the session ends. Category Extensibility tags Syntax <cflogout>...
  • Page 232: Cfloop

    cfloop Description Looping is a programming technique that repeats a set of instructions or displays output repeatedly until one or more conditions are met. This tag supports the following types of loops: • “cfloop: index loop” on page 233 • “cfloop: conditional loop”...
  • Page 233: Cfloop: Index Loop

    cfloop: index loop Description An index loop repeats for a number of times that is determined by a numeric value. An index loop is also known as a FOR loop. Syntax <cfloop index = "parameter_name" from = "beginning_value" to = "ending_value" step = "increment">...
  • Page 234 In this example, the code loops four times, displaying the value each time. The value of index decreased by one for each iteration. This does not affect the value of , because it is a copy of that is made before entering the loop. <cfset j = 4>...
  • Page 235: Cfloop: Conditional Loop

    cfloop: conditional loop Description A conditional loop iterates over a set of instructions as long as a condition is True. To use this type of loop correctly, the instructions must change the condition every time the loop iterates, until the condition is False. Conditional loops are known as WHILE loops, as in, "loop WHILE this condition is true."...
  • Page 236: Cfloop: Looping Over A Query

    cfloop: looping over a query Description A loop over a query executes for each record in a query record set. The results are similar to those of the tag. During each iteration, the columns of the current row are available for cfoutput output.
  • Page 237 dataSource = "Library" maxRows = "5"> SELECT TemplateName FROM Templates </cfquery> <cfloop query = "TemplateName"> <cfinclude template = "#TemplateName#"> </cfloop> cfloop: looping over a query...
  • Page 238: Cfloop: Looping Over A List Or File

    cfloop: looping over a list or file Description Looping over a list steps through elements contained in any of these entities: • A variable • A value that is returned from an expression • A file Syntax <cfloop index = "index_name" list = "list_items"...
  • Page 239: Cfloop: Looping Over A Com Collection Or Structure

    cfloop: looping over a COM collection or structure Description attribute loops over every object within a COM/DCOM collection cfloop collection object, or every element in a structure: • A COM/DCOM collection object is a set of similar items referenced as a group. For example, the group of open documents in an application is a collection.
  • Page 240: Cfmail

    cfmail Description Sends an e-mail message that optionally contains query output, using an SMTP server. Category Forms tags, Internet Protocol tags Syntax <cfmail to = "recipient" from = "sender" cc = "copy_to" bcc = "blind_copy_to" subject = "msg_subject" replyto = "reply_to_addr" failto = "fail_message_addr"...
  • Page 241 Req/Opt Default Description Required Message recipient e-mail addresses. • Static address. For example, " " support@macromedia.com • Variable that contains an address. For example, " ". #Form.Email# • Name of a query column that contains an address. For example, "...
  • Page 242 Attribute Req/Opt Default Description charset Optional Character Character encoding of the mail message, including the encoding headers. The following list includes commonly used values: selected in • utf-8 ColdFusion • iso-8859-1 • windows-1252 Administrator • us-ascii Mail page; • shift_jis default is •...
  • Page 243 Attribute Req/Opt Default Description port Optional TCP/IP port on which SMTP server listens for requests (normally 25). A value here overrides the Administrator. mailerID Optional ColdFusion Mailer ID to be passed in X-Mailer SMTP header, which identifies the mailer application. Application Server timeout...
  • Page 244 Specifying mail servers attribute can specify one or more mail servers. server Note: If you specify multiple mail servers in ColdFusion MX Standard, the cfmail tag uses only the first server in the specification. ColdFusion logs a warning message to the mail log file and ignores the additional servers.
  • Page 245 <p><input type = "Submit" name = ""> </form> ---> cfmail...
  • Page 246: Cfmailparam

    cfmailparam Description Attaches a file or adds a header to an e-mail message. Can only be used in the tag. You can cfmail use more than one tag within a tag. cfmailparam cfmail Category Forms tags, Internet Protocol tags Syntax <cfmail to = "recipient"...
  • Page 247 <cfmailparam name = "Importance" value = "Hich"> Please review the new logo. Tell us what you think. <cfmailparam file = "c:\work\readme.txt" type="text/plain"> <cfmailparam file = "c:\work\logo.gif" type="image/gif"> </cfmail> cfmailparam...
  • Page 248: Cfmailpart

    cfmailpart Description Specifies one part of a multipart e-mail message. Can only be used in the tag. You can use cfmail more than one tag within a tag. cfmailpart cfmail Category Forms tags, Internet Protocol tags Syntax <cfmail ... > (Optional cfmailparam entries) <cfmailpart type="mime type"...
  • Page 249 Attribute Req/Opt Default Description wraptext Optional Do not Specifies the maximum line length, in characters of the mail text. wrap text If a line has more than the specified number of characters, replaces the last white space character, such as a tab or space, preceding the specified position with a line break.
  • Page 250: Cfmodule

    Name.Name.Name... attribute is used Identifies subdirectory, under the ColdFusion tag root directory, that contains custom tag page. For example (Windows format): <cfmodule name = "macromedia.Forums40. GetUserOptions"> This identifies the page GetUserOptions.cfm in the directory CustomTags\macromedia\Forums40 under the ColdFusion root directory.
  • Page 251 Attribute Req/Opt Default Description attributeCollection Optional Structure. A collection of key-value pairs that represent attribute names and values. You can specify multiple key-value pairs. You can specify this attribute only once. attribute_name Optional Attribute for a custom tag. You can include multiple instances of this attribute to specify the parameters of a custom tag.
  • Page 252 <!--- <CFMODULE Name="myTag" X="3" attributeCollection=#attrCollection1# Y="4"> ---> <!--- show the code ---> <HR size="2" color="#0000A0"> <P>Here is another way to invoke the custom tag, using the NAME attribute.</P> <cfoutput>#HTMLCodeFormat(" <CFMODULE NAME='myTag' attributeCollection=##attrCollection1## Y=4>")# </cfoutput> <P>The result: <cfoutput>#result#</cfoutput> <!--- Call the tag using the short cut notation ---> <!--- <CF_myTag X="3"...
  • Page 253: Cfobject

    For example, if " ", for a class, use either of the context=NameService following formats for the parameter: class " " Macromedia/Eng/CF " " Macromedia.current/Eng.current/CF (In earlier releases, the format was " ".) Macromedia.Eng.CF • For CORBA object: changed the attribute;...
  • Page 254: Cfobject: Com Object

    cfobject: COM object Description Creates and manipulates a Component Object Model (COM) object. Invokes a registered automation server object type. For information on OLEView, and about COM and DCOM, see the Microsoft OLE Development website: www.microsoft.com. To use this tag, you must provide the object’s program ID or filename, the methods and properties available through the IDispatch interface, and the arguments and return types of the object's methods.
  • Page 255 Attribute Req/Opt Default Description context Optional • inproc • local • remote On Windows: If not specified, uses Registry setting. server Required if Server name, using Universal Naming Convention (UNC) or Domain Name Serve (DNS) convention, in one of these context = forms: "Remote"...
  • Page 256: Cfobject: Component Object

    cfobject: component object Description Creates an instance of a ColdFusion component (CFC) object. Syntax <cfobject name = "variable name" component = "component name"> See also cfcollection, cfcomponent, cfexecute, cfindex, cfreport, cfsearch, cfwddx Attributes Attribute Req/Opt Default Description name Required String; name for the instantiated component. The name must not have a period as the first or last character.
  • Page 257: Cfobject: Corba Object

    cfobject: CORBA object Description Calls methods on a registered CORBA object. Syntax <cfobject type = "corba" context = "context" class = "file or naming service" name = "text" locale = "type-value arguments"> See also cfcollection, cfexecute, cfindex, cfreport, cfsearch, cfwddx History See the History section of the main tag page.
  • Page 258 Example <cfobject type = "corba" context = "ior" class = "c:\\myobject.ior" name = "GetName"> Chapter 2: ColdFusion Tags...
  • Page 259: Cfobject: Java Or Ejb Object

    cfobject: Java or EJB object Description Creates and manipulates a Java and Enterprise Java Bean (EJB) object. Syntax <cfobject type = "Java" action = "Create" class = "Java class" name = "object name"> See also cfcollection, cfexecute, cfindex, cfreport, cfsearch, cfwddx Attributes Attribute...
  • Page 260 Example <!--- Example of a Java Object his cfobject call loads the class MyClass but does not create an instance object. Static methods and fields are accessible after a call to cfobject. ---> <cfobject action = "create" type = "java" class = "myclass"...
  • Page 261: Cfobject: Web Service Object

    cfobject: web service object Description Creates a web service proxy object. Syntax <cfobject webservice= "http://..?wsdl" or "name set in Administrator" name = "myobjectname"> See also cfcollection, cfexecute, cfindex, cfreport, cfsearch, cfwddx Attributes Attribute Req/Opt Default Description webservice Required URL to web service WSDL file. •...
  • Page 262: Cfobjectcache

    cfobjectcache Description Flushes the query cache. Category Database manipulation tags Syntax <cfobjectcache action = "clear"> See also cfobject History ColdFusion 5: Added this tag. Attributes Attribute Req/Opt Default Description action Required clear: Clears queries from the cache in the Application scope Chapter 2: ColdFusion Tags...
  • Page 263: Cfoutput

    cfoutput Description Displays output that can contain the results of processing ColdFusion variables and functions. Can loop over the results of a database query. Category Data output tags Syntax <cfoutput query = "query_name" group = "query_column" groupCaseSensitive = "Yes" or "No" startRow = "start_row"...
  • Page 264 This tag requires an end tag. Example <!--- This example shows how cfoutput operates ---> <!--- run a sample query ---> <cfquery name = "GetCourses" dataSource = "cfsnippets"> SELECT Dept_ID, CorName, CorLevel FROM courseList ORDER by Dept_ID, CorLevel, CorName </cfquery> <h3>cfoutput Example</h3>...
  • Page 265: Cfparam

    cfparam Description Tests for a parameter’s existence, tests its data type, and, if a default value is not assigned, optionally provides one. Category Variable manipulation tags Syntax <cfparam name = "param_name" type = "data_type" default = "value"> See also cfcookie, cfregistry, cfsavecontent, cfschedule, cfset Attributes Attribute...
  • Page 266 • To test whether an optional variable exists, use this tag with the attributes. name default If the variable does not exist, it is created and set to the attribute value. If the variable default exists, processing continues; the value is not changed. If you specify for the attribute, the parameter value must be a string...
  • Page 267: Cfpop

    cfpop Description Retrieves or deletes e-mail messages from a POP mail server. Category Forms tags, Internet Protocol tags Syntax <cfpop server = "servername" port = "port_number" username = "username" password = "password" action = "action" name = "queryname" messageNumber = "number" uid = "number"...
  • Page 268 Attribute Req/Opt Default Description action Optional getHeaderOnly • getHeaderOnly: returns message header information only • getAll: returns message header information, message text, and attachments if attachmentPath is specified • delete: deletes messages on POP server name Required if Name for query object that contains the action = retrieved message information.
  • Page 269 cfpop query variables The following table describes the variables that provide information about the query that is returned by cfpop Variable names Description queryname.recordCount Number of records returned by query queryname.currentRow Current row that is processing cfoutput queryname.columnList List of column names in query queryname.UID Unique identifier for the e-mail message file Query message header and body columns...
  • Page 270 To create a ColdFusion date/time object from the date-time string that is extracted from a mail message in the column, use the following table: queryname.date Locale How to create a ColdFusion date/time object from queryname.date English (US) Use the function. If you specify the attribute, the ParseDateTime pop-conversion...
  • Page 271: Cfprocessingdirective

    cfprocessingdirective Description Provides the following insformation to ColdFusion on how to process the current page: • Specifies whether to remove excess whitespace character from ColdFusion generated content in the tag body. • Identifies the character encoding (character set) of the page contents. Category Data output tags Syntax...
  • Page 272 For more information on character encodings, see: www.w3.org/International/O-charset.html. Usage tag has limitations that depend on the attribute you use. For this cfprocssingdirective reason, Macromedia recommends that you include either the pageencoding attribute in a tag, not both. To specify both suppresswhitespace cfprocessingdirective values, use separate tags.
  • Page 273 • If a page has a byte order mark (BOM), and a attribute specifies an encoding pageengoding that differs from the BOM, ColdFusion generates an error. The following rules apply to the attribute: suppressWhiteSpace • You can specify the attribute value as a constant or a variable. To use a suppresswhitespace variable: define the variable (for example, ), assign it the value "...
  • Page 274: Cfprocparam

    cfprocparam Description Defines stored procedure parameters. This tag is nested within a tag. cfstoredproc Category Database manipulation tags Syntax <cfprocparam type = "in" or "out" or "inout" variable = "variable name" value = "parameter value" CFSQLType = "parameter datatype" maxLength = "length" scale = "decimal places"...
  • Page 275 Attribute Req/Opt Default Description CFSQLType Required SQL type to which the parameter (any type) is bound. ColdFusion supports the following values, where the last element of the name corresponds to the SQL data type. Different database systems might support different subsets of this list.
  • Page 276 Example The following example shows how to invoke an Oracle 8 PL/SQL stored procedure. It makes use of Oracle 8 support of the Reference Cursor type. The following package, houses a procedure that declares output Foo_Data, refcurproc parameters as Reference Cursor: •...
  • Page 277 <hr> <cftable query = "rs1" colHeaders HTMLTable border = "1"> <cfcol header = "EMPNO" text = "#EMPNO#"> <cfcol header = "EMPLOYEE name" text = "#ENAME#"> <cfcol header = "JOB" text = "#JOB#"> <cfcol header = "SALARY" text = "#SAL#"> <cfcol header = "DEPT NUMBER" text = "#DEPTNO#"> </cftable>...
  • Page 278: Cfprocresult

    cfprocresult Description Associates a query object with a result set returned by a stored procedure. Other ColdFusion tags, such as , use this query object to access the result set. This tag is nested cfoutput cftable within a tag. cfstoredproc Category Database manipulation tags Syntax...
  • Page 279 <cfprocparam type = "IN" CFSQLType = CF_SQL_INTEGER value = "1" dbVarName = @param1> <cfprocparam type = "OUT" CFSQLType = CF_SQL_DATE variable = FOO dbVarName = @param2> <!--- Close the cfstoredproc tag ---> </cfstoredproc> <cfoutput> The output param value: ’#foo#’<br> </cfoutput> <h3>The Results Information</h3>...
  • Page 280: Cfproperty

    cfproperty Description Defines properties of a ColdFusion component (CFC). Used to create complex data types for web services. The attributes of this tag are exposed as component metadata and are subject to inheritance rules. Category Extensibility tags Syntax <cfproperty name="name" type="type"...
  • Page 281 Attribute Req/Opt Default Description required Optional no Whether the parameter is required default Optional If no property value is set when the component is used for a web service, specifies a default value. If this attribute is present, the attribute must be set to required "...
  • Page 282: Cfquery

    Description Passes queries or SQL statements to a data source. Macromedia recommends that you use the tag within every tag, to help cfqueryparam cfquery secure your databases from unauthorized users. For more information, see: • Security Bulletin ASB99-04, "Multiple SQL Statements in Dynamic Queries," in the Macromedia Security Zone, http://www.macromedia.com/devnet/security/security_zone/...
  • Page 283 Attributes Attribute Req/Opt Default Description name Required Name of query. Used in page to reference query record set. Must begin with a letter. Can include letters, numbers, and underscores. dataSource Required Name of data source from which query gets data. dbtype Optional query...
  • Page 284 Database query results for date and time values can vary in sequence and formatting, unless you use functions to format the results. To ensure that customers using your ColdFusion application are not confused by the display, Macromedia recommends that you use the DateFormat functions to format values from queries.
  • Page 285 <td bgcolor="f0f0f0"> <b><i>State</i></b> </td> </tr> <!---- Output the query and define the startrow and maxrows parameters. Use the query variable CurrentCount to keep track of the row you are displaying. ------> <cfoutput query="GetParks" startrow="#StartRow#" maxrows="#MaxRows#"> <tr> <td valign="top" bgcolor="ffffed"> <b>#GetParks.CurrentRow#</b> </td>...
  • Page 286: Cfqueryparam

    This tag is nested within a tag, embedded in a query SQL statement. If you specify cfquery optional parameters, this tag performs data validation. Macromedia recommends that you use the tag within every tag, to help cfqueryparam cfquery secure your databases from unauthorized users. For more information, see: •...
  • Page 287 Attributes Attribute Req/Opt Default Description value Required Value that ColdFusion passes to the right of the comparison operator in a clause. where is a date or time option, ensure that the date CFSQLType value uses your DBMS-specific date format. Use the CreateODBCDateTime DateFormat TimeFormat...
  • Page 288 Usage in any SQL statement (for example, SELECT, INSERT, UPDATE, and cfqueryparam DELETE) that uses ColdFusion variables. For maximum validation of string data, specify the attribute. maxlength This tag does the following: • Allows the use of SQL bind parameters, which improves performance. •...
  • Page 289 <cfquery name="getFirst" datasource="cfsnippets"> SELECT * FROM employees WHERE LastName=<cfqueryparam value="#LastName#" cfsqltype="CF_SQL_VARCHAR" maxlength="17"> </cfquery> <cfoutput query="getFirst"> <p> Course Number: #FirstName# #LastName# Description: #Department# </p> </cfoutput> cfqueryparam...
  • Page 290: Cfregistry

    cfregistry Description This tag is deprecated for the UNIX platform. Reads, writes, and deletes keys and values in the system registry. Provides persistent storage of client variables. Note: For this tag execute, it must be enabled in the ColdFusion Administrator. For more information, see Configuring and Administering ColdFusion MX.
  • Page 291: Cfregistry Action = "Getall

    cfregistry action = "getAll" Description Returns all registry keys and values defined in a branch. You can access the values as you would any record set. Syntax <cfregistry action = "getAll" branch = "branch" type = "data type" name = "query name" sort = "criteria">...
  • Page 292: Cfregistry Action = "Get

    cfregistry action = "get" Description Accesses a registry value and stores it in a ColdFusion variable. Syntax <cfregistry action = "get" branch = "branch" entry = "key or value" variable = "variable" type = "data type"> Attributes Attribute Req/Opt Default Description action Required...
  • Page 293: Cfregistry Action = "Set

    cfregistry action = "set" Description Adds a registry key, adds a value, or updates a value. Syntax <cfregistry action = "set" branch = "branch" entry = "key or value" type = "value type" value = "data"> Attributes Attribute Req/Opt Default Description action Required branch...
  • Page 294: Cfregistry Action = "Delete

    cfregistry action = "delete" Description Deletes a registry key or value. Syntax <cfregistry action = "delete" branch = "branch" entry = "keyorvalue"> Attributes Attribute Req/Opt Default Description action Required delete branch Required • For key deletion: name of registry key to delete. Do not specify the entry.
  • Page 295: Cfreport

    cfreport Description Runs a predefined Crystal Reports report. Applies only to Windows systems. Uses the CFCRYSTAL.exe file to generate reports. Sets parameters in the Crystal Reports engine according to its attribute values. Category Extensibility tags Syntax <cfreport report = "report_path" dataSource = "ds_name"...
  • Page 296 Attribute Req/Opt Default Description password Optional Password that corresponds to username required for database access. Overrides default settings for data source in ColdFusion Administrator. formula Optional One or more named formulas. Terminate each formula with a semicolon. Use the format: formula = "formulaname1 = 'formula1';formulaname2 = 'formula2';"...
  • Page 297: Cfrethrow

    cfrethrow Description Rethrows the currently active exception. Preserves the exception’s cfcatch type variable values. cfcatch.tagContext Category Exception handling tags, Extensibility tags Syntax <cfrethrow> See also cferror, cfthrow, cftry Usage Use this tag within a block. This tag is useful in error handling code, if the error handler cfcatch cannot handle an error that it catches.
  • Page 298: Cfreturn

    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...
  • Page 299 </cffunction> </cfcomponent> cfreturn...
  • Page 300: Cfsavecontent

    cfsavecontent Description Saves the generated content of the tag, including the results of evaluating cfsavecontent expressions and executing custom tags, in the specified variable. Category Variable manipulation tags Syntax <cfsavecontent variable = "variable name"> the content </cfsavecontent> See also cfcookie, cfparam, cfregistry, cfschedule, cfset Attributes Attribute Req/Opt Default...
  • Page 301: Cfschedule

    cfschedule Description Provides a programmatic interface to the ColdFusion scheduling engine. Can run a CFML page at scheduled intervals, with the option to write the page output to a static HTML page. This feature enables you to schedule pages that publish data, such as reports, without waiting while a database transaction is performed to populate the page.
  • Page 302 Attributes Attribute Req/Opt Default Description action Required • delete: deletes the specified task • update: updates an existing task or creates a new task, if one with the name specified by the attribute does not exist task • run: executes the specified task task Required Name of the task.
  • Page 303 Attribute Req/Opt Default Description proxyPassword Opt Password to provide to the proxy server. resolveURL Optional • Yes: resolve links in the output page to absolute references • No Usage This tag and the ColdFusion MX Administrator Scheduled task page schedule ColdFusion tasks. Tasks that you add or change using this tag are visible in the Aministrator.
  • Page 304: Cfscript

    cfscript Description Encloses a code block that contains statements. cfscript Category Application framework tags, Other tags Syntax <cfscript> cfscript code here </cfscript> See also Chapter 6, “Extending ColdFusion Pages with CFML cfinvoke, cfmodule, CreateObject, Scripting,” in Developing ColdFusion MX Applications History ColdFusion MX: •...
  • Page 305 You cannot use the construct within a tag. You can use code such as the elseif cfscript following: else if ( condition ) Exception handling with the cfscript tag To handle exceptions with this tag, use statements, which are equivalent to the catch tags.
  • Page 306 xlatstring = ws.BabelFish("en_es", "Hello world, friend"); writeoutput(xlatstring); </cfscript> For more information, see Chapter 32, “Using Web Services,” in Developing ColdFusion MX Applications. Example <p>This simple example shows variable declaration and manipulation. <cfif IsDefined("form.myValue")> <cfif IsNumeric(form.myValue)> <cfset x = form.myValue> <cfscript> y = x;...
  • Page 307: Cfsearch

    cfsearch Description Searches Verity collections using ColdFusion or K2Server, whichever search engine a collection is registered by. (ColdFusion can also search collections that have not been registered, with the tag.) cfcollection A collection must be created and indexed before this tag can return search results. A collection can be created in these ways: •...
  • Page 308 • Changed Verity operations behavior: ColdFusion supports Verity operations on Acrobat PDF files. • Changed multiple collection behavior: this tag can search multiple collections. In a multiple collection search, you cannot combine collections that are registered with K2Server and registered in another way. •...
  • Page 309 (criteria="\<") does not work in this context. For more information, see Chapter 25, “Using Verity Search Expressions,” in Developing ColdFusion MX Applications. Macromedia does not recommend using the tag with this tag; Verity provides the locking cflock function.
  • Page 310 You can use query result columns in standard CFML expressions, preceding the result column name with the name of the query, as follows: #DocSearch.url# #DocSearch.key# #DocSearch.title# #DocSearch.score# Example <!--- #1 (TYPE=SIMPLE) -----------------------------> <cfsearch name="name" collection="snippets,syntax,snippets" criteria="example" > <p> <cfoutput>Search Result total = #name.RecordCount# </cfoutput><br>...
  • Page 311 criteria = "cf_key=bookid2"> <cfoutput> url=#book.url#<br> key=#book.key#<br> title=#book.titleE#<br> score=#book.score#<br> custom1=#book.custom1#<br> custom2=#book.custom2#<br> summary=#book.summary#<br> recordcount=#book.recordcount#<br> currentrow=#book.currentrow#<br> columnlist=#book.columnlist#<br> recordssearched=#book.recordssearched#<br> </cfoutput> <cfdump var = #book#> <br> cfsearch...
  • Page 312: Cfselect

    cfselect Description Constructs a drop-down list box form control. Used within a tag. cfform You can populate the list from a query, or by using the HTML tag. option Category Forms tags Syntax <cfselect name = "name" required = "Yes" or "No" message = "text"...
  • Page 313 Attribute Req/Opt Default Description value Optional Query column to use for the value of each list element. Used with attribute. query display Optional Value of Query column to use for the display label of each list element. Used with attribute. value query attribute...
  • Page 314 Example <!--- This example shows the use of cftree, cfselect and cfgrid in a cfform. The query takes a list of employees, and uses cftree and cfselect to display results of query. cfgrid is used to show an alternate means of displaying the data --->...
  • Page 315 expand="No" queryasroot="No"> <cftreeitem value="#Phone#" display="Phone" parent="#Emp_ID#" queryasroot="No" expand="No"> <cftreeitem value="#Phone#" parent="#Phone#" expand="No" queryasroot="No"> <cftreeitem value="#Email#" display="Email" parent="#Emp_ID#" queryasroot="No" expand="No"> <cftreeitem value="#Email#" parent="#Email#" expand="No" queryasroot="No"> </cfloop> </cftree> <!----- You can also use CFGRID for a more comprehensive, quicker view at the data ----------------------------------------------------------------> <h3>CFGRID Presentation of Data</h3>...
  • Page 316: Cfservlet

    cfservlet Description This tag is deprecated. Executes a Java servlet on a JRun engine. To access servlets that run on the same server as ColdFusion, use code such as the following, in which path specifies a servlet, JSP, or anything else: GetPageContext().include(path) GetPageContext().forward(path) For more information, see the JSP PageContext API or the Servlet RequestDispatcher API.
  • Page 317: Cfservletparam

    cfservletparam Description This tag is deprecated. A child tag of the tag. Passes data to a servlet. Each tag within the cfservlet cfservletparam block passes a separate item of data to the servlet. cfservlet To access servlets that run on the same server as ColdFUsion, use code such as the following, in which path specifies a servlet, JSP, or anything else: GetPageContext().include(path) GetPageContext().forward(path)
  • Page 318: Cfset

    cfset Description Sets a value in ColdFusion. Used to create a variable, if it does not exist, and assign it a value. Also used to call functions. Category Variable manipulation tags Syntax <cfset var variable_name = expression > See also cfcookie, cfparam, cfregistry, cfsavecontent, cfschedule Attributes...
  • Page 319 Function local variables keyword specifies that the variable being defined is only available inside the body of a function that you define using the tag. The variable value that is set in one cffunction invocation of the function is not available in any other invocation of the function. The keyword is the equivalent of the statement in CFScript.
  • Page 320 <p>In addition, cfset can be used to pass variables from other pages, such as this example, which takes the url parameter Test from this link: (<a href = "cfset.cfm?test = <cfoutput> #URLEncodedFormat("hey, you, get off of my cloud")#</cfoutput> ">click here</A>) to display a message: <p>...
  • Page 321: Cfsetting

    cfsetting Description Controls aspects of page processing, such as the output of HTML code in pages. Category Page processing tags, Variable manipulation tags Syntax <cfsetting enableCFoutputOnly = "Yes" or "No" showDebugOutput = "Yes" or "No" requestTimeOut = "value in seconds" > See also cfcache, cfflush, cfheader, cfhtmlhead, cfinclude, cfsilent...
  • Page 322 If you nest tags: to make HTML output visible, you must match each cfsetting statement with an statement. For enableCFoutputOnly = "Yes" enableCFoutputOnly = "No" example, after five statements, to enable HTML output, you enableCFoutputOnly = "Yes" must have five corresponding statements.
  • Page 323: Cfsilent

    cfsilent Description Suppresses output produced by CFML within a tag’s scope. Category Data output tags, Page processing tags Syntax <cfsilent> </cfsilent> See also cfcache, cfflush, cfheader, cfhtmlhead, cfinclude, cfsetting Usage This tag requires an end tag. Example <h3>cfsilent</h3> <cfsilent> <cfset a = 100> <cfset b = 99>...
  • Page 324: Cfslider

    cfslider Description Puts a slider control, for selecting a numeric value from a range, in a ColdFusion form. The slider moves over the slider groove. As the user moves the slider, the current value displays. Used within tag. cfform Category Forms tags Syntax <cfslider...
  • Page 325 Attribute Req/Opt Default Description refreshLabel Optional • Yes: when user moves slider, label is refreshed • No range Optional "0,100" Numeric slider range values. Separate values with a comma. scale Optional Unsigned integer. Defines slider scale, within range. For example, if , the range = "0,1000"...
  • Page 326 Attribute Req/Opt Default Description tickMarkLabels Optional • yes: numeric tickmarks based on the value of the range attributes. scale • no: prevents label text from displaying • Comma-delimited list of strings for tickmark labels; for example, "ten, twenty, thirty, forty" If you do not specify enough values, the last value is repeated for remaining tickmarks.
  • Page 327 Usage This tag requires the client to download a Java applet. Using this tag may be slightly slower than using an HTML form element to display the same information. For this tag to work properly. the browser must be JavaScript-enabled. If the following conditions are true, a user’s selection from query data that populates this tag’s options continues to display after the user submits the form: •...
  • Page 328: Cfstoredproc

    cfstoredproc Description Executes a stored procedure in a server database. It specifies database connection information and identifies the stored procedure. Category Database manipulation tags Syntax <cfstoredproc procedure = "procedure name" dataSource = "ds_name" username = "username" password = "password" blockFactor = "blocksize" debug = "Yes"...
  • Page 329 • If the stored procedure uses input or output parameters, code one cfprocparam tag per parameter. Additionally, you must code tags in the same cfprocparam cfprocparam order as the parameters in the stored procedure definition. If you set , this tag sets the variable , which returnCode = "Yes"...
  • Page 330: Cfswitch

    cfswitch Description Evaluates a passed expression and passes control to the tag that matches the expression cfcase result. You can, optionally, code a tag, which receives control if there is no cfdefaultcase matching tag value. cfcase Category Flow-control tags Syntax <cfswitch expression = "expression">...
  • Page 331 <!--- By outputting the query and using cfswitch, we classify the output without using a cfloop construct. ---> <p>Each time the case is fulfilled, the specific information is printed; if the case is not fulfilled, the default case is output </p> <cfoutput query="GetEmployees">...
  • Page 332: Cftable

    cftable Description Builds a table in a ColdFusion page. This tag renders data as preformatted text, or, with the attribute, in an HTML table. If you don't want to write HTML table tag code, or if HTMLTable your data can be presented as preformatted text, use this tag. Preformatted text (defined in HTML with the <pre>...
  • Page 333 Attribute Req/Opt Default Description colHeaders Optional Displays column heads. If you use this attribute, you must also use the attribute to define them. cfcol header If you use this attribute (regardless of its value), ColdFusion displays column heads. startRow Optional The query result row to put in the first table row.
  • Page 334: Cftextinput

    cftextinput Description Puts a single-line text entry box in a tag and controls its display characteristics. cfform Category Forms tags Syntax <cftextinput name = "name" value = "text" required = "Yes" or "No" range = "min_value, max_value" validate = "data_type" pattern = "Java regular expression"...
  • Page 335 Attribute Req/Opt Default Description validate Optional • date: verifies format mm/dd/yy. • eurodate: verifies date format dd/mm/yyyy. • time: verifies time format hh:mm:ss. • float: verifies floating point format. • integer: verifies integer format. • telephone: verifies telephone format ###-###-####. The separator can be a blank.
  • Page 336 Attribute Req/Opt Default Description align Optional Alignment of text entry box with respect to adjacent HTML content: • top • left • bottom • baseline • texttop • absbottom • middle • absmiddle • right bgColor Optional Background color of control. For a hex value, use the form: , where x = 0-9 or A-F;...
  • Page 337 • attribute posts to the same page as the form itself (this is the default), or cfform action the action page has a form that contains controls with the same names as corresponding controls on the user entry form For more information, see cfform If the attribute is...
  • Page 338: Cfthrow

    cfthrow Description Throws a developer-specified exception, which can be caught with a tag that has any of cfcatch the following attribute options: type • type = "custom_type" • type = "Application" • type = "Any" Category Exception handling tags, Flow-control tags Syntax 1 <cfthrow type = "exception_type "...
  • Page 339 Usage Use this tag within a block, to throw an error. The block can access cftry cfcatch accompanying information, as follows: • Message, with cfcatch.message • Detail, with cfcatch.detail • Error code, with cfcatch.errorcode To get more information, use . This array shows where control switches cfcatch.tagContext from one page to another in the tag stack (for example, cfinclude...
  • Page 340 (#sCurrent["LINE"]#,#sCurrent["COLUMN"]#) #sCurrent["TEMPLATE"]# </cfloop> </cfoutput> </cfcatch> </cftry> Example2 The following example shows how to throw an exception from a component method: <cfcomponent> <cffunction name="getEmp"> <cfargument name="lastName" required="yes"> <cfquery name="empQuery" datasource="ExampleApps" > SELECT LASTNAME, FIRSTNAME, EMAIL FROM tblEmployees WHERE LASTNAME LIKE '#arguments.lastName#' </cfquery>...
  • Page 341: Cftrace

    cftrace Description Displays and logs debugging data about the state of an application at the time the cftrace executes. Tracks runtime logic flow, variable values, and execution time. Displays output at the end of the request or in the debugging section at the end of the request; or, in Dreamweaver MX and later, in the Server Debug tab of the Results window.
  • Page 342 Attribute Req/Opt Default Description type Optional Information Corresponds to the attribute; displays an cflog type appropriate icon. • Information • Warning • Error • Fatal Information Optional The name of a simple or complex variable to display. Useful for displaying a temporary value, or a value that does not display on any CFM page.
  • Page 343: Cftransaction

    cftransaction Description Instructs the database management system to treat multiple database operations as a single transaction. Provides database commit and rollback processing. Category Database manipulation tags Syntax <cftransaction action = "begin" or "commit" or "rollback" isolation = "read_uncommitted" or "read_committed" or "repeatable_read"...
  • Page 344 <cftransaction> <cfquery name='makeNewCourse' datasource='Snippets'> INSERT INTO Courses (Number, Descript) VALUES ('#myNumber#', '#myDescription#') </cfquery> <cfquery name='insertNewCourseToList' datasource='Snippets'> INSERT INTO CourseList (CorNumber, CorDesc, Dept_ID, CorName, CorLevel, LastUpdate) VALUES ('#myNumber#', '#myDescription#', '#myDepartment#', '#myDescription#', '#myCorLevel#', #Now()#) </cfquery> </cftransaction> ---> Chapter 2: ColdFusion Tags...
  • Page 345: Cftree

    cftree Description Inserts a tree control in a form. Validates user selections. Used within a tag block. You can cftree use a ColdFusion query to supply data to the tree. Category Forms tags Syntax <cftree name = "name" required = "Yes" or "No" delimiter = "delimiter"...
  • Page 346 Attribute Req/Opt Default Description completePath Optional No; tree • Yes: passes the root part of form variable treename.path name is when is submitted cftree returned as • No, or omitted: root level of form variable is not passed; root path value starts with the first node For the attribute of to work with the...
  • Page 347 Attribute Req/Opt Default Description align Optional • top • left • bottom • baseline • texttop • absbottom • middle • absmiddle • right border Optional Yes • Yes • No hScroll Optional Yes • Yes: permits horizontal scrolling • No vScroll Optional Yes •...
  • Page 348 <!--- query the datasource to find the employee information---> <cfquery name = "GetEmployees" dataSource = "cfsnippets"> SELECT Emp_ID, FirstName, LastName, EMail, Phone, Department FROM Employees where lastname <cfif #employeeNames# is not ""> = ’#employeeNames#’</cfif> </cfquery> <html> <body> <h3>cftree Example</h3> <!--- Use cfform when using other cfinput tools ---> <cfform action = "cftree.cfm">...
  • Page 349: Cftreeitem

    cftreeitem Description Populates a form tree control, created with the tag, with elements. To display icons, you cftree can use the values that ColdFusion provides, or reference your own icons. Category Forms tags Syntax <cftreeitem value = "text" display = "text" parent = "parent_name"...
  • Page 350 Attribute Req/Opt Default Description imgopen Optional Icon displayed with open tree item. You can specify icon filename with a relative path. You can use a ColdFusion image. href Optional URL to associate with tree item or query column for a tree that is populated from a query.
  • Page 351 <!--- Use cfselect to present the contents of the query by column ---> <h3>cfselect Presentation of Data</h3> <h4>Click an employee’s last name and click "see information for this employee" to see expanded information.</h4> <cfselect name = "EmployeeNames" message = "Select an Employee Name" size = "#getEmployees.recordcount#"...
  • Page 352 headeritalic="No"> <cfgridcolumn name="Phone" header="Phone" headeralign="LEFT" dataalign="LEFT" bold="No" italic="Yes" select="No" display="Yes" headerbold="No" headeritalic="No"> <cfgridcolumn name="Department" header="Department" headeralign="LEFT" dataalign="LEFT" bold="Yes" italic="No" select="No" display="Yes" headerbold="No" headeritalic="No"> <cfgridcolumn name="Emp_ID" header="ID" headeralign="LEFT" dataalign="LEFT" width="40" bold="No" italic="No" select="No" display="Yes" headerbold="No" headeritalic="No"> </cfgrid> </cfform> Chapter 2: ColdFusion Tags...
  • Page 353: Cftry

    cftry Description Used with one or more tags. Together, they catch and process exceptions in ColdFusion cfcatch pages. Exceptions are events that disrupt the normal flow of instructions in a ColdFusion page, such as failed database operations, missing include files, and developer-specified events. Category Exception handling tags Syntax...
  • Page 354 </cfoutput> </cfcatch> </cftry> Chapter 2: ColdFusion Tags...
  • Page 355: Cfupdate

    cfupdate Description Updates records in a data source from data in a ColdFusion form or form Scope. Category Database manipulation tags Syntax <cfupdate dataSource = "ds_name" tableName = "table_name" tableOwner = "name" tableQualifier = "qualifier" username = "username" password = "password" formFields = "field_names">...
  • Page 356 Example <!--- This example shows the use of CFUPDATE to change records in a datasource. ---> <!--- if course_ID has been passed to this form, then perform the update on that record in the datasource ---> <cfif IsDefined("form.Course_ID")> <!--- check that course_id is numeric ---> <cfif Not IsNumeric(form.Course_ID)>...
  • Page 357 </cftable> </cfif> </body> </html> cfupdate...
  • Page 358: Cfwddx

    cfwddx Description Serializes and deserializes CFML data structures to the XML-based WDDX format. The WDDX is an XML vocabulary for describing complex data structures in a standard, generic way. Implementing it lets you use the HTTP protocol to such information among application server platforms, application servers, and browsers.
  • Page 359 Attribute Req/Opt Default Description useTimeZoneInfo Optional Whether to output time-zone information when serializing CFML to WDDX. • Yes: the hour-minute offset, represented in ISO8601 format, is output. • No: the local time is output. validate Optional Applies if action = "wddx2cfml" "wddx2js"...
  • Page 360 <!--- Deserialize to a variable named wddxResult ---> Deserializing WDDX packet...<p> <cfwddx action = "wddx2cfml" input = #wddxText# output = "qnew"> The recordset data is:...<p> <cfoutput query = qnew> #Message_ID# #Thread_ID# #Username#<br> </cfoutput><p> Chapter 2: ColdFusion Tags...
  • Page 361: Cfxml

    cfxml Description Creates a ColdFusion XML document object that contains the markup in the tag body. This tag can include XML and CFML tags. ColdFusion processes the CFML code in the tag body, then assigns the resulting text to an XML document object variable. Category Extensibility tags Syntax...
  • Page 362 </cfloop> </MyDoc> </cfxml> <cfdump var=#MyDoc#> Chapter 2: ColdFusion Tags...
  • Page 363: Chapter 3: Coldfusion Functions

    CHAPTER 3 ColdFusion Functions This chapter lists and categorizes ColdFusion Markup Language (CFML) functions. Contents Function list............. . 364 Functions by category .
  • Page 364 Function list ColdFusion Markup Language (CFML) includes a set of functions that you use in ColdFusion pages to perform logical and arithmetic operations and manipulate data. The following table lists CFML functions: GetHttpTimeString ACos GetK2ServerDocCount Minute ArrayAppend GetK2ServerDocCountLimit Month ArrayAvg GetLocale MonthAsString ArrayClear...
  • Page 365 BitXor IsDefined Reverse Ceiling IsK2ServerABroker Right IsK2ServerDocCountExceeded RJustify CJustify IsK2ServerOnline Round Compare IsLeapYear RTrim CompareNoCase IsNumeric Second IsNumericDate SetEncoding CreateDate IsObject SetLocale CreateDateTime IsQuery SetProfileString CreateObject IsSimpleValue SetVariable CreateODBCDate IsStruct CreateODBCDateTime IsUserInRole CreateODBCTime IsWDDX SpanExcluding CreateTime IsXmlDoc SpanIncluding CreateTimeSpan IsXmlElem CreateUUID IsXmlRoot StripCR...
  • Page 366 DollarFormat ListQualify TimeFormat Duplicate ListRest ToBase64 Encrypt ListSetAt ToBinary Evaluate ListSort ToString ListToArray Trim ExpandPath ListValueCount UCase FileExists ListValueCountNoCase URLDecode Find LJustify URLEncodedFormat FindNoCase URLSessionFormat FindOneOf Log10 FirstDayOfMonth LSCurrencyFormat ValueList LSDateFormat Week FormatBaseN LSEuroCurrencyFormat Wrap GetAuthUser LSIsCurrency WriteOutput GetBaseTagData LSIsDate XmlChildPos GetBaseTagList LSIsNumeric...
  • Page 367: Functions By Category

    Functions by category The following tables list functions by their category or purpose. Array functions ............367 Authentication functions .
  • Page 368: Date And Time Functions

    ToBinary ListToArray XmlFormat ToString URLDecode XmlParse Date and time functions CreateDate DateFormat GetTimeZoneInfo MonthAsString CreateDateTime DatePart Hour CreateODBCDate IsDate ParseDateTime CreateODBCDateTime DayOfWeek IsLeapYear Quarter CreateODBCTime DayOfWeekAsString IsNumericDate Second CreateTime DayOfYear LSDateFormat TimeFormat CreateTimeSpan DaysInMonth LSIsDate Week DateAdd DaysInYear LSParseDateTime Year DateCompare FirstDayOfMonth LSTimeFormat...
  • Page 369: Dynamic Evaluation Functions

    Dynamic evaluation functions Evaluate SetVariable Extensibility functions CreateObject XmlElemNew XmlParse ReleaseComObject XmlFormat XmlSearch XmlChildPos XmlNew XmlTransform Full-text search functions History ColdFusion MX 6.1: These functions are deprecated. They might not work, and might cause errors, in a future release. GetK2ServerDocCount IsK2ServerABroker IsK2ServerOnline GetK2ServerDocCountLimit IsK2ServerDocCoun tExceeded...
  • Page 370: Mathematical Functions

    Mathematical functions BitNot FormatBaseN Randomize ACos BitOr IncrementValue RandRange ArrayAvg BitSHLN InputBaseN Round ArraySum BitSHRN ASin BitXor Ceiling Log10 BitAnd BitMaskClear DecrementValue BitMaskRead BitMaskSet Rand Other functions CreateUUID GetBaseTagList QuotedValueList URLEncodedFormat Decrypt GetBaseTemplatePath StripCR URLSessionFormat DeleteClientVariable GetClientVariablesList ToBase64 ValueList Duplicate GetTickCount ToBinary WriteOutput...
  • Page 371: Structure Functions

    Compare REFind ToBase64 CompareNoCase LJustify REFindNoCase ToBinary DayOfWeekAsString ListValueCount RemoveChars ToString Decrypt ListValueCountNoCase RepeatString Trim Encrypt LSIsCurrency Replace UCase FormatBaseN LSIsDate ReplaceList URLDecode Find LSIsNumeric ReplaceNoCase URLEncodedFormat FindNoCase LSParseCurrency REReplace FindOneOf LSParseDateTime REReplaceNoCase Wrap GetToken LSParseEuroCurrency Reverse XmlFormat Hash LSParseNumber Right Insert LTrim...
  • Page 372: Function Changes Since Coldfusion 5

    Function changes since ColdFusion 5 The following tables list functions, parameters and values that have changed since ColdFusion 5.0 and indicate the specific release in which the change was made. Array functions ............367 Deprecated functions, parameters, and values .
  • Page 373: Deprecated Functions, Parameters, And Values

    Function Parameter or value Added in this ColdFusion release XmlSearch ColdFusion MX XmlTransform ColdFusion MX Deprecated functions, parameters, and values The following functions, parameters, and values are deprecated. Do not use them in ColdFusion applications. They might not work, and might cause an error, in releases later than ColdFusion Function Parameter or value Deprecated as of this ColdFusion release...
  • Page 374: Abs

    Description Absolute-value function. The absolute value of a number is the number without its sign. Returns The absolute value of a number. Category Mathematical functions Function syntax Abs(number See also Parameters Parameter Description number A number Example <h3>Abs Example</h3> <p>The absolute value of the following numbers: 1,3,-4,-3.2,6 is <cfoutput>...
  • Page 375: Acos

    ACos Description Arccosine function. The arccosine is the angle whose cosine is number. Returns The arccosine, in radians, of a number. Category Mathematical functions Function syntax ACos(number) See also Cos, Sin, ASin, Tan, Atn, Parameters Parameter Description number Cosine of an angle. The value must be between -1.0 and 1.0, inclusive. Usage The range of the result is 0 to .
  • Page 376: Arrayappend

    ArrayAppend Description Appends an array element to an array. Returns True, on successful completion. Category Array functions Function syntax ArrayAppend(array, value) See also ArrayPrepend History ColdFusion MX: Changed behavior: this function can be used on XML objects. Parameters Parameter Description array Name of an array value...
  • Page 377: Arrayavg

    ArrayAvg Description Calculates the average of the values in an array. Returns Number. If the parameter value is an empty array, returns zero. array Category Array functions, Mathematical functions Function syntax ArrayAvg(array) See also ArraySum Parameters Parameter Description array Name of an array Usage The following example uses the ColdFusion built-in variable , which is...
  • Page 378 <table cellspacing = "2" cellpadding = "2" border = "0"> <cfloop index = "LoopItem" from = "1" to = "#FormElem#"> <tr> <cfoutput> <th align = "left">Number #LoopItem#</th> <td><input type = "text" name = "number#LoopItem#"></td> </cfoutput> </tr> </cfloop> </table> <input type = "submit" name = "submit" value = "get the average"> </form>...
  • Page 379: Arrayclear

    ArrayClear Description Deletes the data in an array. Returns True, on successful completion. Category Array functions Function syntax ArrayClear(array) See also ArrayDeleteAt History ColdFusion MX: Changed behavior: this function can be used on XML objects. Parameters Parameter Description array Name of an array Example <h3>ArrayClear Example</h3>...
  • Page 380: Arraydeleteat

    ArrayDeleteAt Description Deletes an element from an array. When an element is deleted, ColdFusion recalculates index positions. For example, in an array that contains the months of the year, deleting the element at position 5 removes the entry for May. After this, to delete the entry for June, you would delete the element at position 5 (not 6). Returns True, on successful completion.
  • Page 381: Arrayinsertat

    ArrayInsertAt Description Inserts a value into an array. Array elements whose indexes are greater than the new position are incremented by one. The array length increases by one. Returns True, on successful completion. Category Array functions Function syntax ArrayInsertAt(array, position, value) See also ArrayDeleteAt History...
  • Page 382: Arrayisempty

    ArrayIsEmpty Description Determines whether an array is empty of data elements. Returns True, if the array is empty; otherwise, False. Category Array functions Function syntax ArrayIsEmpty(array) See also ArrayLen History ColdFusion MX: Changed behavior: this function can be used on XML objects. Parameters Parameter Description...
  • Page 383: Arraylen

    ArrayLen Description Determines the number of elements in an array. Returns The number of elements in an array. Category Array functions Function syntax ArrayLen(array) See also ArrayIsEmpty History ColdFusion MX: Changed behavior: this function can be used on child XML objects. Parameters Parameter Description...
  • Page 384: Arraymax

    ArrayMax Description Array maximum function. Returns The largest numeric value in an array. If the parameter value is an empty array, returns array zero. Category Array functions Function syntax ArrayMax(array) Parameters Parameter Description array Name of an array Example <h3>ArrayMax Example</h3> <p>This example uses ArrayMax to find the largest number in an array.<br>...
  • Page 385: Arraymin

    ArrayMin Description Array minimum function. Returns The smallest numeric value in an array. If the parameter value is an empty array, returns array zero. Category Array functions Function syntax ArrayMin(array) Parameters Parameter Description array Name of an array Example <h3>ArrayMin Example</h3> <p>This example uses ArrayMin to find the smallest number in an array.<br></p>...
  • Page 386: Arraynew

    ArrayNew Description Creates an array of 1–3 dimensions. Index array elements with square brackets: [ ]. ColdFusion arrays expand dynamically as data is added. Returns An array Category Array functions Function syntax ArrayNew(dimension) Parameters Parameter Description dimension Number of dimensions in new array. 1, 2, or 3 Example <h3>ArrayNew Example</h3>...
  • Page 387: Arrayprepend

    ArrayPrepend Description Inserts an array element at the beginning of an array. Returns True, on successful completion. Category Array functions Function syntax ArrayPrepend(array, value) See also ArrayAppend Parameters Parameter Description array Name of an array value Value to insert at beginning of array Example <h3>ArrayPrepend Example</h3>...
  • Page 388: Arrayresize

    ArrayResize Description Resets an array to a specified minimum number of elements. This can improve performance, if used to size an array to its expected maximum. For more than 500 elements, use ArrayResize immediately after using the tag. ArrayNew ColdFusion arrays expand dynamically as data is added. Returns True, on successful completion.
  • Page 389: Arrayset

    ArraySet Description In a one-dimensional array, sets the elements in a specified index range to a value. Useful for initializing an array after a call to ArrayNew Returns True, on successful completion. Category Array functions Function syntax ArraySet(array, start_pos, end_pos, value) See also ArrayNew History...
  • Page 390: Arraysort

    ArraySort Description Sorts array elements numerically or alphanumerically. Returns True, if sort is successful; False, otherwise. Category Array functions, List functions Function syntax ArraySort(array, sort_type [, sort_order ]) History ColdFusion MX: • Changed thrown exceptions: this function can throw the ArraySortSimpleValueException error and ValueNotNumeric error.
  • Page 391 Throws If an array element is other than a simple element, this function throws an ArraySortSimpleValueException error. If is numeric and an array element is not sort_type numeric, this function throws a ValueNotNumeric error. Example <!--- This example shows ArraySort ---> <cfquery name = "GetEmployeeNames"...
  • Page 392: Arraysum

    ArraySum Description Array sum function. Returns The sum of values in an array. If the parameter value is an empty array, returns zero. array Category Array functions, Mathematical functions Function syntax ArraySum(array) Parameters Parameter Description array Name of an array Example <h3>ArraySum Example</h3>...
  • Page 393: Arrayswap

    ArraySwap Description Swaps array values of an array at specified positions. This function is more efficient than multiple tags. cfset Returns True, on successful completion. Category Array functions Function syntax ArraySwap(array, position1, position2) Parameters Parameter Description array Name of an array position1 Position of first element to swap position2...
  • Page 394: Arraytolist

    ArrayToList Description Converts a one-dimensional array to a list. Returns Delimited list, as a string. Category Array functions, Conversion functions, List functions Function syntax ArrayToList(array [, delimiter ]) Parameters Parameter Description array Name of array delimiter Character or multi-character string to separate list elements. Default: comma. Example <h3>ArrayToList Example</h3>...
  • Page 395 Description Determines the value of a character. Returns The value of the first character of a string; if string is empty, returns zero. Category String functions Function syntax Asc(string) See also History ColdFusion MX: Changed Unicode support: ColdFusion supports the Java UCS-2 representation of Unicode characters, up to a value of 65536.
  • Page 396: Asin

    ASin Description Determines the arcsine of a number. The arcsine is the angle whose sine is number. Returns The arcsine, in radians, of a number. Category Mathematical functions Function syntax ASin(number) See also Sin, Cos, ACos, Tan, Atn, Parameters Parameter Description number Sine of an angle.
  • Page 397 <br><input type = "Text" name = "sinNum" size = "25"> <p><input type = "Submit" name = ""> <input type = "RESET"> </form> ASin...
  • Page 398 Description Arctangent function. The arctangent is the angle whose tangent is number. Returns The arctangent, in radians, of a number. Category Mathematical functions Function syntax Atn(number) See also Atn, Sin, ASin, Cos, ACos, Parameters Parameter Description number Tangent of an angle Usage The range of the result is - /2 to /2 radians.
  • Page 399: Authenticatedcontext

    AuthenticatedContext Description This function is obsolete. Use the newer security tools; see “Authentication functions” on page 367 Chapter 16, “Securing Applications,” in Developing ColdFusion MX Applications. History ColdFusion MX: This function is obsolete. It does not work in ColdFusion MX and later ColdFusion releases.
  • Page 400: Authenticateduser

    AuthenticatedUser Description This function is obsolete. Use the newer security tools; see “Authentication functions” on page 367 Chapter 16, “Securing Applications,” in Developing ColdFusion MX Applications. History ColdFusion MX: This function is obsolete. It does not work in ColdFusion MX and later ColdFusion releases.
  • Page 401: Bitand

    BitAnd Description Performs a bitwise logical AND operation. Returns The bitwise AND of two long integers. Category Mathematical functions Function syntax BitAnd(number1, number2) See also BitNot, BitOr, BitXor Parameters Parameter Description number1 32-bit signed integer number2 32-bit signed integer Usage Bit functions operate on 32-bit signed integers, in the range -2147483648 –...
  • Page 402: Bitmaskclear

    BitMaskClear Description Performs a bitwise mask clear operation. Returns A number, bitwise cleared, with length bits beginning at start. Category Mathematical functions Function syntax BitMaskClear(number, start, length) See also BitMaskRead, BitMaskSet Parameters Parameter Description number 32-bit signed integer start Integer, in the range 0-31, inclusive; start bit for mask length Integer, in the range 0-31, inclusive;...
  • Page 403: Bitmaskread

    BitMaskRead Description Performs a bitwise mask read operation. Returns An integer, created from length bits of number, beginning at start. Category Mathematical functions Function syntax BitMaskRead(number, start, length) See also BitMaskClear, BitMaskSet Parameters Parameter Description number 32-bit signed integer to mask start Integer, in the range 0-31, inclusive;...
  • Page 404: Bitmaskset

    BitMaskSet Description Performs a bitwise mask set operation. Returns A number, bitwise masked with length bits of mask beginning at start. Category Mathematical functions Function syntax BitMaskSet(number, mask, start, length) See also BitMaskClear, BitMaskRead Parameters Parameter Description number 32-bit signed integer mask 32-bit signed integer;...
  • Page 405: Bitnot

    BitNot Description Performs a bitwise logical NOT operation. Returns A number; the bitwise NOT of a long integer. Category Mathematical functions Function syntax BitNot(number) See also BitAnd, BitOr, BitXor Parameters Parameter Description number 32-bit signed integer Usage Bit functions operate on 32-bit signed integers, in the range -2147483648 – 2147483647. Example <h3>BitNot Example</h3>...
  • Page 406: Bitor

    BitOr Description Performs a bitwise logical OR operation. Returns A number; the bitwise OR of two long integers. Category Mathematical functions Function syntax BitOr(number1, number2) See also BitAnd, BitNot, BitXor Parameters Parameter Description number1 32-bit signed integer number2 32-bit signed integer Usage Bit functions operate on 32-bit signed integers, in the range -2147483648 –...
  • Page 407: Bitshln

    BitSHLN Description Performs a bitwise shift-left, no-rotation operation. Returns A number, bitwise shifted without rotation to the left by count bits. Category Mathematical functions Function syntax BitSHLN(number, count) See also BitSHRN Parameters Parameter Description number 32-bit signed integer count Integer, in the range 0-31, inclusive; number of bits to shift the number Usage Bit functions operate on 32-bit signed integers, in the range -2147483648 –...
  • Page 408: Bitshrn

    BitSHRN Description Performs a bitwise shift-right, no-rotation operation. Returns A number, bitwise shifted, without rotation, to the right by count bits. Category Mathematical functions Function syntax BitSHRN(number, count) See also BitSHLN Parameters Parameter Description number 32-bit signed integer count Integer, in the range 0-31, inclusive. Number of bits to shift the number Usage Bit functions operate on 32-bit signed integers, in the range -2147483648 –...
  • Page 409: Bitxor

    BitXor Description Performs a bitwise logical XOR operation. Returns Bitwise XOR of two long integers. Category Mathematical functions Function syntax BitXor(number1, number2) See also BitAnd, BitNot, BitOr Parameters Parameter Description number1 32-bit signed integer number2 32-bit signed integer Usage Bit functions operate on 32-bit signed integers, in the range -2147483648 – 2147483647. Example <h3>BitXOr Example</h3>...
  • Page 410: Ceiling

    Ceiling Description Determines the closest integer that is greater than a specified number. Returns The closest integer that is greater than a given number. Category Mathematical functions Function syntax Ceiling(number) See also Int, Fix, Round Parameters Parameter Description number A real number Example <h3>Ceiling Example</h3>...
  • Page 411 Converts a numeric value to a UCS-2 character. Returns A character with the specified UCS-2 character code. Category String functions Function syntax Chr(number) See also History ColdFusion MX: Changed Unicode support: ColdFusion supports the Java UCS-2 representation of Unicode characters, up to a value of 65535. (Earlier releases supported 1-255.) Parameters Parameter Description...
  • Page 412: Cjustify

    CJustify Description Centers a string in a field length. Returns String, center-justified by adding spaces before or after the input parameter. If length is less than the length of the input parameter string, the string is returned unchanged. Category Display and formatting functions, String functions Function syntax...
  • Page 413: Compare

    Compare Description Performs a case-sensitive comparison of two strings. Returns • -1, if string1 is less than string2 • 0, if string1 is equal to string2 • 1, if string1 is greater than string2 Category String functions Function syntax Compare(string1, string2) See also CompareNoCase, Find...
  • Page 414 <p>String 1 <br><input type = "Text" name = "string1"> <p>String 2 <br><input type = "Text" name = "string2"> <p><input type = "Submit" value = "Compare these Strings" name = ""> <input type = "RESET"> </form> Chapter 3: ColdFusion Functions...
  • Page 415: Comparenocase

    CompareNoCase Description Performs a case-insensitive comparison of two strings. Returns An indicator of the difference: • A negative number, if string1 is less than string2 • 0, if string1 is equal to string2 • A positive number, if string1 is greater than string2 Category String functions Function syntax...
  • Page 416 <P><INPUT TYPE="Submit" VALUE="Compare these Strings" NAME=""> <INPUT TYPE="RESET"> </FORM> Chapter 3: ColdFusion Functions...
  • Page 417 Description Calculates the cosine of an angle that is entered in radians. Returns A number; the cosine of the angle. Category Mathematical functions Function syntax Cos(number) See also ACos, Sin, ASin, Tan, Atn, Parameters Parameter Description number Angle, in radians, for which to calculate the cosine Usage The range of the result is -1 to 1.
  • Page 418 <br><br> <input type = "Submit" name = "">&nbsp;&nbsp; <input type = "RESET" </form> Chapter 3: ColdFusion Functions...
  • Page 419: Createdate

    CreateDate Description Creates a date/time object. Returns A date/time value. Category Date and time functions Function syntax CreateDate(year, month, day) See also CreateDateTime, CreateODBCDate Parameters Parameter Description year Integer in the range 0-9999. Integers in the range 0-29 are converted to 2000- 2029.
  • Page 420 #DateFormat(CreateODBCDateTime(yourDate), "d/m/yy")# </ul> </cfoutput> </CFIF> <CFFORM ACTION="createdate.cfm" METHOD="POST"> <p>Enter the year, month and day, as integers: <PRE> Year<CFINPUT TYPE="Text" NAME="year" VALUE="1998" VALIDATE="integer" REQUIRED="Yes"> Month<CFINPUT TYPE="Text" NAME="month" VALUE="6" VALIDATE="integer" REQUIRED="Yes"> Day<CFINPUT TYPE="Text" NAME="day" VALUE="8" VALIDATE="integer" REQUIRED="Yes"> </PRE> <p><INPUT TYPE="Submit" NAME=""> <INPUT TYPE="RESET"> </cfform>...
  • Page 421: Createdatetime

    CreateDateTime Description Creates a date-time object. Returns A date/time value. Category Date and time functions Function syntax CreateDateTime(year, month, day, hour, minute, second) See also CreateDate, CreateTime, CreateODBCDateTime, Parameters Parameter Description year Integer in the range 0-9999. Integers in the range 0-29 are converted to 2000- 2029.
  • Page 422 <li>Formatted with CreateODBCDate and DateFormat: #DateFormat(CreateODBCDate(yourDate), "mmmm d, yyyy")# <li>Formatted with CreateODBCDateTime and DateFormat: #DateFormat(CreateODBCDateTime(yourDate), "d/m/yy")# </ul> </cfoutput> </CFIF> <CFFORM ACTION="createdatetime.cfm" METHOD="POST"> <p>Please enter the year, month, and day, in integer format, for a date to view: <PRE> Year<CFINPUT TYPE="Text" NAME="year" VALUE="1998" VALIDATE="integer" REQUIRED="Yes">...
  • Page 423: Createobject

    For example, if " ", for a class, use either of the context=NameService following formats for the parameter: class " " Macromedia/Eng/CF " " Macromedia.current/Eng.current/CF (In earlier releases, the format was " ".) Macromedia.Eng.CF • For CORBA object: changed the attribute;...
  • Page 424: Createobject: Com Object

    CreateObject: COM object Description function can create a Component Object Model (COM) object. CreateObject To create a COM object, you must provide this information: • The object’s program ID or filename • The methods and properties available to the object through the IDispatch interface •...
  • Page 425: Createobject: Component Object

    CreateObject: component object Description function can create an instance of a ColdFusion component (CFC) object. CreateObject Returns A component object. Function syntax CreateObject(type, component-name) Parameters Parameter Description type Type of object to create. • com • corba • java • component •...
  • Page 426: Createobject: Corba Object

    Use either of the following formats: • " " Macromedia/Eng/CF • " " Macromedia.current/Eng.current/CF ColdFusion Enterprise supports CORBA through the Dynamic Invocation Interface (DII). To use this function with CORBA objects, you must provide the name of the file that contains a string version of the IOR, or the object’s naming context in the naming service.
  • Page 427 = CreateObject("corba", "Macromedia/Eng/CF", "nameservice", "visibroker") // uses nameservice myobj = CreateObject("corba", "d:\temp\tester.ior", "nameservice") // uses nameservice and default configuration CreateObject...
  • Page 428: Createobject: Java Or Ejb Object

    CreateObject: Java or EJB object Description function can create a Java object, and, by extension, an EJB object. CreateObject Returns A Java object. Function syntax CreateObject(type, class) Parameters Parameter Description type Type of object to create. • com • corba •...
  • Page 429: Createobject: Web Service Object

    CreateObject: web service object Description This function can create a web service object. Returns A web service object. Function syntax CreateObject(type, urltowsdl) Parameters Parameter Description type Type of object to create. • com • corba • java • component • webservice urltowsdl WSDL file URL;...
  • Page 430: Createodbcdate

    (for example, to ensure that a day/month/year entry is not confused with a month/day/ year entry, and so on), Macromedia recommends that you parse entered dates with the function, using the mm-dd-yyyy mask, into three elements. Ensure that values are DateFormat within appropriate ranges;...
  • Page 431 </ul> </cfoutput> </cfif> <cfform action="createodbcdate.cfm" method="POST"> <p>Enter the year, month and day, as integers: <pre> Year <cfinput type="text" name="year" value="1998" validate="integer" required="yes"> Month<cfinput type="text" name="month" value="6" range="1,12" message="please enter a month (1-12)" validate="integer" REQUIRED="Yes"> <cfinput type="text" name="day" value="8" range="1,31" MESSAGE="Please enter a day of the month (1-31)" VALIDATE="integer" REQUIRED="Yes">...
  • Page 432: Createodbcdatetime

    CreateODBCDateTime Description Creates an ODBC date-time object. Returns A date/time object, in ODBC timestamp format. Category Date and time functions Function syntax CreateODBCDateTime(date) See also CreateDateTime, CreateODBCDate, CreateODBCTime, Parameters Parameter Description date Date/time object in the range 100 AD–9999 AD. Usage When passing a date/time value as a string, you must enclose it in quotation marks.
  • Page 433 <CFFORM ACTION="createodbcdatetime.cfm" METHOD="POST"> <p>Enter a year, month and day, as integers: <pre> Year <CFINPUT TYPE="Text" NAME="year" VALUE="1998" VALIDATE="integer" REQUIRED="Yes"> Month<cfinput TYPE="Text" NAME="month" VALUE="6" RANGE="1,12" MESSAGE="Enter a month (1-12)" VALIDATE="integer" REQUIRED="Yes"> Day <cfinput type="text" name="day" value="8" range="1,31" MESSAGE="Enter a day of the month (1-31)" VALIDATE="integer" REQUIRED="Yes">...
  • Page 434: Createodbctime

    CreateODBCTime Description Creates an ODBC time object. Returns A time object, in ODBC timestamp format. Category Date and time functions Function syntax CreateODBCTime(date) See also CreateODBCDateTime, CreateTime Parameters Parameter Description date Date/time object in the range 100 AD–9999 AD. Usage When passing a date/time value as a string, you must enclose it in quotation marks.
  • Page 435: Createtime

    CreateTime Description Creates a time variable. Returns A time variable. Category Date and time functions Function syntax CreateTime(hour, minute, second) See also CreateODBCTime, CreateDateTime Parameters Parameter Description hour Number in the range 0–23 minute Number in the range 0–59 second Number in the range 0–59 Usage is a subset of...
  • Page 436: Createtimespan

    CreateTimeSpan Description Creates a date/time object that defines a time period. You can add or subtract it from other date/ time objects and use it with the attribute of cachedWithin cfquery Returns A date/time object. Category Date and time functions Function syntax CreateTimeSpan(days, hours, minutes, seconds) See also...
  • Page 437 <!--- build HTML table to display query ---> <table cellpadding = 1 cellspacing = 1> <TR> <TD colspan = 2 bgcolor = f0f0f0> <b><I>Park Name</i></b> </TD> <TD bgcolor = f0f0f0> <b><i>Region</i></b> </TD> <TD bgcolor = f0f0f0> <b><i>State</i></b> </TD> </TR> <!--- Output query, define startrow and maxrows. Use query variable CurrentCount to track the row you are displaying.
  • Page 438: Createuuid

    CreateUUID Description Creates a Universally Unique Identifier (UUID). A UUID is a 35-character string representation of a unique 128-bit integer. Returns A ColdFusion format UUID, in the format , where xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx is a hexadecimal digit (0-9 or A-F). (The character groups are 8-4-4-4-16.) Category Other functions Function syntax...
  • Page 439: Dateadd

    DateAdd Description Adds units of time to a date. Returns A date/time object. Category Date and time functions Function syntax DateAdd("datepart", number, "date") See also DateConvert, DatePart, CreateTimeSpan History ColdFusion MX 6.1: Added the datepart character L or l to represent milliseconds. Parameters Parameter Description...
  • Page 440 <cfif IsDefined("form.type")> <cfset type = form.type> </cfif> <cfquery name="GetMessages" datasource="cfsnippets"> SELECT UserName, Subject, Posted FROMMessages </cfquery> <p>This example uses DateAdd to determine when a message in the database will expire. Currently, messages older than <cfoutput>#value#</cfoutput> <cfswitch expression="#type#"> <cfcase value="yyyy">years</cfcase> <cfcase value="q">quarters</cfcase> <cfcase value="m">months</cfcase>...
  • Page 441: Datecompare

    DateCompare Description Performs a full date/time comparison of two dates. Returns • -1, if date1 is less than date2 • 0, if date1 is equal to date2 • 1, if date1 is greater than date2 Category Date and time functions Function syntax DateCompare("date1", "date2"...
  • Page 442 <h3><cfoutput>#DateFormat(FORM.date1)# #TimeFormat(FORM.date1)#</cfoutput> (Date 1) is equal to <cfoutput>#DateFormat(FORM.date2)# #TimeFormat(FORM.date2)#</cfoutput> (Date 2)</h3> <I>The dates are equal!</I> </cfcase> <cfcase value = "1"> <h3><cfoutput>#DateFormat(FORM.date1)# #TimeFormat(FORM.date1)#</cfoutput> (Date 1) is later than <cfoutput>#DateFormat(FORM.date2)# #TimeFormat(FORM.date2)#</cfoutput> (Date 2)</h3> <I>The dates are not equal</I> </cfcase> <cfdefaultcase> <h3>This is the default case</h3> </cfdefaultcase>...
  • Page 443: Dateconvert

    DateConvert Description Converts local time to Coordinated Universal Time (UTC), or UTC to local time. The function uses the daylight savings settings in the executing computer to compute daylight savings time, if required. Returns UTC- or local-formatted time object. Category Date and time functions Function syntax DateConvert("conversion-type", "date")
  • Page 444 <p><cfoutput>Your UTC date and time, converted back to local date and time: #DateConvert("utc2local", yourUTC)#. </cfoutput></p> <cfelse> Type the date and time, and press Enter to see the conversion. </cfif> <Hr size = "2" color = "#0000A0"> <form action = "dateconvert.cfm"> <p>Enter year, month and day in integer format for date value to view: <table cellspacing = "2"...
  • Page 445: Datediff

    DateDiff Description Determines the integer number of units by which date1 is less than date2. Returns A number of units, of type datepart. Category Date and time functions Function syntax DateDiff("datepart", "date1", "date2") See also DateAdd, DatePart, CreateTimeSpan History ColdFusion MX: •...
  • Page 446 Example <cfif IsDefined("form.value")> <cfset value = form.value> </cfif> <cfif IsDefined("form.type")> <cfset type = form.type> </cfif> <cfif IsDefined("form.date1") and IsDefined("form.date2")> <cfif IsDate(form.date1) and IsDate(form.date2)> <p>This example uses DateDiff to determine the difference <cfswitch expression = "#form.type#"> <cfcase value="yyyy">years</cfcase> <cfcase value="q">quarters</cfcase> <cfcase value="m">months</cfcase> <cfcase value="y">days</cfcase>...
  • Page 447 <input type="Text" name="date1" value="<CFOUTPUT>#DateFormat(Now())#</ CFOUTPUT>"> Date 2 <input type="Text" name="date2" value="<CFOUTPUT>#DateFormat(Now())#</ CFOUTPUT>"> What kind of unit to show difference? <select name="type"> <option value="yyyy" selected>years <option value="q">quarters <option value="m">months <option value="y">days of year <option value="d">days <option value="w">weekdays <option value="ww">weeks <option value="h">hours <option value="n">minutes <option value="s">seconds </select>...
  • Page 448: Dateformat

    DateFormat Description Formats a date value using U.S. date formats. For international date support, use LSDateFormat Returns A text string representing the date formatted according to the mask. If no mask is specified, returns the value in dd-mmm-yy format. Category Date and time functions Function syntax DateFormat("date"...
  • Page 449 Date and time values in database query results can vary in sequence and formatting unless you use functions to format them. To ensure that application users correctly understand displayed dates and times, Macromedia recommends that you use this function and the LSDateFormat , and functions to format resultset values.
  • Page 450: Datepart

    DatePart Description Extracts a part from a date value. Returns Part of a date, as an integer. Category Date and time functions Function syntax DatePart("datepart", "date") See also DateAdd, DateConvert History ColdFusion MX 6.1: Added the datepart character L or l to represent milliseconds. Parameters Parameter Description...
  • Page 451 <li>day: #DatePart("d", todayDate)# <li>weekday: #DatePart("w", todayDate)# <li>week: #DatePart("ww", todayDate)# <li>hour: #DatePart("h", todayDate)# <li>minute: #DatePart("n", todayDate)# <li>second: #DatePart("s", todayDate)# </ul> </cfoutput> DatePart...
  • Page 452 Description Determines the day of the month, in a date. Returns The ordinal for the day of the month, ranging from 1 to 31. Category Date and time functions Function syntax Day("date") See also DayOfWeek, DayOfWeekAsString, DayOfYear, DaysInMonth, DaysInYear, FirstDayOfMonth Parameters Parameter Description...
  • Page 453: Dayofweek

    DayOfWeek Description Determines the day of the week, in a date. Returns The ordinal for the day of the week, as an integer in the range 1 (Sunday) to 7 (Saturday). Category Date and time functions Function syntax DayOfWeek("date") See also Day, DayOfWeekAsString, DayOfYear, DaysInMonth, DaysInYear, FirstDayOfMonth Parameters...
  • Page 454: Dayofweekasstring

    DayOfWeekAsString Description Determines the day of the week, in a date, as a string function. Returns The day of the week, as a string that corresponds to day_of_week. Category Date and time functions, String functions Function syntax DayOfWeekAsString(day_of_week) See also Day, DayOfWeek, DayOfYear, DaysInMonth, DaysInYear, FirstDayOfMonth Parameters...
  • Page 455: Dayofyear

    DayOfYear Description Determines the day of the year, in a date. Returns The ordinal value of day of the year, as an integer. Category Date and time functions Function syntax DayOfYear("date") See also Day, DayOfWeek, DayOfWeekAsString, DaysInMonth, DaysInYear, FirstDayOfMonth Parameters Parameter Description date...
  • Page 456: Daysinmonth

    DaysInMonth Description Determines the number of days in a month. Returns The number of days in the month in Date. Category Date and time functions Function syntax DaysInMonth("date") See also Day, DayOfWeek, DayOfWeekAsString, DayOfYear, DaysInYear, FirstDayOfMonth Parameters Parameter Description date Date/time object, in the range 100 AD–9999 AD.
  • Page 457: Daysinyear

    DaysInYear Description Determines the number of days in a year. Returns The number of days in a year. Category Date and time functions Function syntax DaysInYear("date") See also Day, DayOfWeek, DayOfWeekAsString, DayOfYear, DaysInMonth, DaysInYear, FirstDayOfMonth, IsLeapYear Parameters Parameter Description date •...
  • Page 458 Description Postpones evaluation of a string as an expression, when it is passed as a parameter to the functions. Escapes any double quotation marks in the parameter and wraps the result Evaluate in double quotation marks. This function is especially useful with the function, to prevent the function from evaluating a string that is to be output.
  • Page 459 </tr> </cfloop> </table> </cfoutput> For more information and code examples, see Chapter 4, “Using Expressions and Pound Signs,” in Developing ColdFusion MX Applications. Example <!--- This example shows the use of DE and Evaluate ---> <h3>DE Example</h3> <cfif IsDefined("FORM.myExpression")> <h3>The Expression Result</h3> <cftry>...
  • Page 460: Decimalformat

    DecimalFormat Description Converts a number to a decimal-formatted string. Returns A number as a string formatted with two decimal places and a thousands separator. Category Display and formatting functions Function syntax DecimalFormat(number) See also DollarFormat, NumberFormat Parameters Parameter Description number Number to format Example <h3>DecimalFormat Function</h3>...
  • Page 461: Decrementvalue

    DecrementValue Description Decrements the integer part of a number. Returns Integer part of number, decremented by one. Category Mathematical functions Function syntax DecrementValue(number) See also IncrementValue Parameters Parameter Description number Number to decrement Example <h3>DecrementValue Example</h3> <p>Returns the integer part of a number decremented by one. <p>DecrementValue(0): <cfoutput>#DecrementValue(0)#</cfoutput>...
  • Page 462: Decrypt

    Decrypt Description Decrypts a string that is encrypted with the function. Encrypt Returns String, unencrypted. Category Other functions, String functions Function syntax Decrypt(encrypted_string, seed) See also Duplicate, Encrypt Parameters Parameter Description encrypted_string String or a variable that contains one. String to decrypt seed String.
  • Page 463: Deleteclientvariable

    DeleteClientVariable Description Deletes a client variable. (To test for the existence of a variable, use IsDefined Returns True, if the variable is successfully deleted; false, otherwise. Category Other functions Function syntax DeleteClientVariable("name") See also GetClientVariablesList History ColdFusion MX: Changed behavior: if the variable is not present, this function now returns False. (In earlier releases, it threw an error.) Parameters Parameter...
  • Page 464: Directoryexists

    DirectoryExists Description Determines whether a directory exists. Returns Yes, if the specified directory exists; No, otherwise. Category System functions Function syntax DirectoryExists(absolute_path) See also FileExists Parameters Parameter Description absolute_path An absolute path Example <h3>DirectoryExists Example</h3> <h3>Enter a directory to check for existence.</h2> <form action = "directoryexists.cfm"...
  • Page 465: Dollarformat

    DollarFormat Description Formats a string in U.S. format. (For other currencies, use LSCurrencyFormat LSEuroCurrencyFormat.) Returns A number as a string, formatted with two decimal places, thousands separator, and dollar sign. If number is negative, the return value is enclosed in parentheses. If number is an empty string, returns zero.
  • Page 466: Duplicate

    Duplicate Description Returns a clone, also known as a deep copy, of a variable. There is no reference to the original variable. Returns A clone of a variable. Category Structure functions, System functions Function syntax Duplicate(variable_name) See also other Structure functions StructCopy, History ColdFusion MX: Changed behavior: this function can be used on XML objects.
  • Page 467: Encrypt

    Encrypt Description Encrypts a string. Uses a symmetric key-based algorithm, in which the same key is used to encrypt and decrypt a string. The security of the encrypted string depends on maintaining the secrecy of the key. Uses an XOR-based algorithm that uses a pseudo-random 32-bit key, based on a seed passed by the user as a function parameter.
  • Page 468: Evaluate

    Evaluate Description Evaluates one or more string expressions, dynamically, from left to right. (The results of an evaluation on the left can have meaning in an expression to the right.) Returns the result of evaluating the rightmost expression. Returns An object; the result of the evaluation(s). Category Dynamic evaluation functions Function syntax...
  • Page 469 Description Calculates the exponent whose base is e that represents number. The constant e equals 2.71828182845904, the base of the natural logarithm. This function is the inverse of , the natural logarithm of number. Returns The constant e, raised to the power of number. Category Mathematical functions Function syntax...
  • Page 470: Expandpath

    ExpandPath Description Creates an absolute, platform-appropriate path that is equivalent to the value of relative_path appended to the base path. This function (despite its name) can accept an absolute or relative path in the attribute relative_path The base path is the currently executing page’s directory path. It is stored in pageContext.getServletContext().
  • Page 471 The current directory is: #GetDirectoryFromPath(thisPath)# <cfif IsDefined("form.yourFile")> <cfif form.yourFile is not ""> <cfset yourFile = form.yourFile> <cfif FileExists(ExpandPath(yourfile))> <p>Your file exists in this directory. You entered the correct file name, #GetFileFromPath("#thisPath#/#yourfile#")# <CFELSE> <p>Your file was not found in this directory: <br>Here is a list of the other files in this directory: <!--- use CFDIRECTORY to give the contents of the snippets directory, order by name and size --->...
  • Page 472: Fileexists

    FileExists Description Determines whether a file exists. Returns Yes, if the file specified in the parameter exists; No, otherwise. Category System functions, Decision functions Function syntax FileExists(absolute_path) See also DirectoryExists, ExpandPath, GetTemplatePath Parameters Parameter Description absolute_path An absolute path Example <h3>FileExists Example</h3>...
  • Page 473: Find

    Find Description Finds the first occurrence of a substring in a string, from a specified start position. The search is case-sensitive. Returns A number; the position of substring in string; or 0, if substring is not in string. Category String functions Function syntax Find(substring, string [, start ]) See also...
  • Page 474: Findnocase

    FindNoCase Description Finds the first occurrence of a substring in a string, from a specified start position. If substring is not in string, returns zero. The search is case-insensitive. Returns The position of substring in string; or 0, if substring is not in string. Category String functions Function syntax...
  • Page 475: Findoneof

    FindOneOf Description Finds the first occurrence of any one of a set of characters in a string, from a specified start position. The search is case-sensitive. Returns The position of the first member of set found in string; or 0, if no member of set is found in string. Category String functions Function syntax...
  • Page 476: Firstdayofmonth

    FirstDayOfMonth Description Determines the ordinal (day number, in the year) of the first day of the month in which a given date falls. Returns A number corresponding to a day-number in a year. Category Date and time functions Function syntax FirstDayOfMonth(date) See also Day, DayOfWeek, DayOfWeekAsString, DayOfYear, DaysInMonth,...
  • Page 477 Description Converts a real number to an integer. Returns If number is greater than or equal to 0, the closest integer less than number. If number is less than 0, the closest integer greater than number. Category Mathematical functions Function syntax Fix(number) See also Ceiling, Int,...
  • Page 478: Formatbasen

    FormatBaseN Description Converts number to a string, in the base specified by radix. Returns String that represents number, in the base radix. Category Display and formatting functions, Mathematical functions, String functions Function syntax FormatBaseN(number, radix) See also InputBaseN Parameters Parameter Description number Number to convert...
  • Page 479: Getauthuser

    GetAuthUser Description Gets the name of an authenticated user. Returns The name of an authenticated user. Category Authentication functions Function syntax GetAuthUser() See also Chapter 16, “Securing Applications,” in Developing IsUserInRole, cflogin, cfloginuser, ColdFusion MX Applications History ColdFusion MX: Added this function. Usage This function works with authentication or web server authentication.
  • Page 480: Getbasetagdata

    GetBaseTagData Description Used within a custom tag. Finds calling (ancestor) tag by name and accesses its data. Returns An object that contains data (variables, scopes, and so on) from an ancestor tag. If there is no ancestor by the specified name, or if the ancestor does not expose data (for example, ), an cfif exception is thrown.
  • Page 481: Getbasetaglist

    GetBaseTagList Description Gets ancestor tag names, starting with the parent tag. Returns A comma-delimited list of uppercase ancestor tag names, as a string. The first list element is the current tag. If the current tag is nested, the next element is the parent tag. If the function is called for a top-level tag, it returns an empty string.
  • Page 482: Getbasetemplatepath

    GetBaseTemplatePath Description Gets the absolute path of an application’s base page. Returns The absolute path of the application base page, as a string. Category Other functions, System functions Function syntax GetBaseTemplatePath() See also GetCurrentTemplatePath, FileExists, ExpandPath Example <h3>GetBaseTemplatePath Example</h3> <p>The template path of the current page is: <cfoutput>#GetBaseTemplatePath()#</cfoutput>...
  • Page 483: Getclientvariableslist

    GetClientVariablesList Description Finds the client variables to which a page has write access. Returns Comma-delimited list of non-read-only client variables, as a string. Category List functions, Other functions Function syntax GetClientVariablesList() See also DeleteClientVariable Usage The list of variables returned by this function is compatible with ColdFusion list functions. Example <!--- this example is view only --->...
  • Page 484: Getcurrenttemplatepath

    GetCurrentTemplatePath Description Gets the path of the page that calls this function. Returns The absolute path of the page that contains the call to this function, as a string. Category System functions Function syntax GetCurrentTemplatePath() See also GetBaseTemplatePath, FileExists, ExpandPath Usage If the function call is made from a page included with a tag, this function returns the...
  • Page 485: Getdirectoryfrompath

    GetDirectoryFromPath Description Extracts a directory from an absolute path. Returns Absolute path, without the filename. The last character is a forward or backward slash, depending on the operating system. Category System functions Function syntax GetDirectoryFromPath(path) See also ExpandPath, GetFileFromPath Parameters Parameter Description path...
  • Page 486 <input type="Submit" NAME=""> </form> ---> Chapter 3: ColdFusion Functions...
  • Page 487: Getencoding

    GetEncoding Description Returns the encoding (character set) of the Form or URL scope. Returns String; the character encoding of the specified scope. Category International functions, System functions Function syntax GetEncoding(scope_name) See also SetEncoding, cfcontent, cfprocessingdirective, URLDecode, URLEncodedFormat History ColdFusion MX: Added this function. Parameters Parameter Description...
  • Page 488: Getexception

    GetException Description Used with the tags. Retrieves a Java exception object from a Java object. cftry cfcatch Returns Any Java exception object raised by a previous method call on the Java object. Category System functions Syntax getException(object) Parameters Parameter Description object A Java object.
  • Page 489: Getfilefrompath

    GetFileFromPath Description Extracts a filename from an absolute path. Returns Filename, as a string. Category System functions Function syntax GetFileFromPath(path) See also ExpandPath, GetCurrentTemplatePath Parameters Parameter Description path Absolute path (drive, directory, filename, and extension) Example <h3>GetFileFromPath Example</h3> <cfset thisPath = ExpandPath("*.*")> <cfset thisDirectory = GetDirectoryFromPath(thisPath)>...
  • Page 490: Getfunctionlist

    GetFunctionList Description Displays a list of the functions that are available in ColdFusion. Returns A structure of functions. Category System functions Function syntax GetFunctionList() Example <!----- This example shows the use of GetFunctionList. ----> <cfset fList = GetFunctionList()> <cfoutput>#StructCount(fList)# functions<br><br> </cfoutput>...
  • Page 491: Gethttprequestdata

    GetHttpRequestData Description Makes HTTP request headers and body available to CFML pages. Useful for capturing SOAP request data, which can be delivered in an HTTP header. Returns A ColdFusion structure. Category System functions Function syntax GetHttpRequestData() Parameters Parameter Description content Raw content from form submitted by client, in string or binary format.
  • Page 492 <b>http_content --- #x.content#</b> </cfoutput> Chapter 3: ColdFusion Functions...
  • Page 493: Gethttptimestring

    GetHttpTimeString Description Gets the current time, in the Universal Time code (UTC). Returns The time, as a string, according to the HTTP standard described in RFC 1123. Category Date and time functions, International functions Function syntax GetHttpTimeString(date_time_object) See also GetLocale, GetTimeZoneInfo, SetLocale Parameters Parameter...
  • Page 494: Getk2Serverdoccount

    GetK2ServerDocCount Description This function is deprecated. Determines the number of documents that can be searched by the ColdFusion registered K2 Server. This function is used primarily by the ColdFusion Verity and K2Server Administrator pages, and requires significant processing time. Avoid using it in production applications. This function uses Verity K2Server Release K2.2.0.
  • Page 495: Getk2Serverdoccountlimit

    For ColdFusion MX Evaluation: 250,000 • For ColdFusion MX Developer: 10,000 • For ColdFusion MX Professional: 125,000 • For ColdFusion MX Enterprise: 250,000 • For ColdFusion MX with Macromedia Spectra: 750,000 K2Broker with ColdFusion MX has no limit. Example <cfoutput>GetK2ServerDocCountLimit = $*#GetK2ServerDocCountLimit()#*$</cfoutput> GetK2ServerDocCountLimit...
  • Page 496: Getlocale

    GetLocale Description Gets the current geographic/language locale value. To set the default display format of date, time, number, and currency values in a ColdFusion application session, you use the function. SetLocale Returns The current locale value, as a string. Category Display and formatting functions, International...
  • Page 497: Getmetadata

    GetMetaData Description Gets metadata (the methods, properties, and parameters of a component) associated with an object that is deployed on the ColdFusion server. This functionality, called introspection, lets applications dynamically determine how to use a component. Returns Key-value pairs, as a component descriptor data structure or as structured XML Category System functions Function syntax...
  • Page 498 Property metadata contains at least the following key: • : the property name name Other property attributes are returned as additional keys. Chapter 3: ColdFusion Functions...
  • Page 499: Getmetricdata

    GetMetricData Description Gets server performance metrics. Returns ColdFusion structure that contains metric data, depending on the value. mode Category System functions Function syntax GetMetricData(mode) History ColdFusion MX: Deprecated the parameter. It might not work, and it might cause an cachepops error, in later releases.
  • Page 500 Field Description ReqTimedOut Number of HTTP requests that timed out while in the staging queue or during processing. BytesIn Number of bytes in HTTP requests to ColdFusion MX BytesOut Number of bytes in HTTP responses from ColdFusion MX AvgQueueTime For the last two HTTP requests (current and previous), the average length of time the request waited in the staging queue.
  • Page 501: Getpagecontext

    GetPageContext Description Gets the current ColdFusion MX PageContext object that provides access to page attributes and configuration, request and response objects. Returns The current ColdFusion MX Java PageContext Java object. Category System functions Function syntax GetPageContext() History ColdFusion MX: Added this function. Usage The ColdFusion MX PageContext class is a wrapper class for the Java PageContext object that can resolve scopes and perform case-insensitive variable lookups.
  • Page 502: Getprofilesections

    GetProfileSections Description Gets all the sections of an initialization file. An initialization file assigns values to configuration variables, also known as entries, that are set when the system boots, the operating system comes up, or an application starts. An initialization file has the suffix INI;...
  • Page 503: Getprofilestring

    GetProfileString Description Gets an initialization file entry. An initialization file assigns values to configuration variables, also known as entries, that are set when the system boots, the operating system comes up, or an application starts. An initialization file has the suffix INI; for example, boot.ini, Win32.ini. Returns An entry in an initialization file, as a string.
  • Page 504 </tr></table> </form> Chapter 3: ColdFusion Functions...
  • Page 505: Gettempdirectory

    GetTempDirectory Description Gets the path of the directory that ColdFusion uses for temporary files. The directory depends on the account under which ColdFusion is running and other factors. Before using this function in an application, test to determine the directory it returns under your account. Returns The absolute pathname of a directory, including a trailing slash, as a string.
  • Page 506: Gettempfile

    GetTempFile Description Creates a temporary file in a directory whose name starts with (at most) the first three characters of prefix. Returns Name of a temporary file, as a string. Category System functions Function syntax GetTempFile(dir, prefix) See also GetTempDirectory Parameters Parameter Description...
  • Page 507: Gettemplatepath

    GetTemplatePath Description This function is deprecated. Use the function instead. GetBaseTemplatePath Gets the absolute path of an application’s base page. History ColdFusion MX: Deprecated this function. It might not work, and it might cause an error, in later releases. GetTemplatePath...
  • Page 508: Gettickcount

    GetTickCount Description Returns the current value of an internal millisecond timer. Returns A string representation of the system time, in milliseconds. Category Date and time functions Function syntax GetTickCount() Usage This function is useful for timing CFML code segments or other page processing elements. The value of the counter has no meaning.
  • Page 509: Gettimezoneinfo

    GetTimeZoneInfo Description Gets local time zone information for the computer on which it is called, relative to Universal Time Coordinated (UTC). UTC is the mean solar time of the meridian of Greenwich, England, used as the basis for calculating standard time throughout the world. ColdFusion stores date and time values as date-time objects: real numbers on a universal time line.
  • Page 510: Gettoken

    GetToken Description Determines whether a token of the list in the parameter is present in a string. delimiters Returns The token found at position index of the string, as a string. If index is greater than the number of tokens in the string, returns an empty string. Category String functions Function syntax...
  • Page 511 The output is as follows: four, ,five, nine,zero:; nine,ten:, eleven:;twelve:;thirteen, ,four function recognizes explicit spaces, tabs, or newline characters as the parameter GetToken delimiters (To specify a space character, the code is ; a tab character, ; and a chr(32) chr(9) newline character, chr(10)
  • Page 512 The function finds the second delimiter, and returns the substring just before it that is between the first and second delimiter. This substring is " ". ,five,nine,zero:; Example <h3>GetToken Example</h3> <cfif IsDefined("FORM.yourString")> <!--- set delimiter ---> <cfif FORM.yourDelimiter is not ""> <cfset yourDelimiter = FORM.yourDelimiter>...
  • Page 513: Hash

    Hash Description Converts a variable-length string to a 32-byte, hexadecimal string, using the MD5 algorithm. (It is not possible to convert the hash result back to the source string.) Returns 32-byte, hexadecimal string Category Conversion functions, Other functions, String functions Function syntax Hash(string) Parameters...
  • Page 514: Hour

    Hour Description Gets the current hour of the day. Returns Ordinal value of the hour, in the range 0 - 23. Category Date and time functions Function syntax Hour(date) See also DatePart, Minute, Second Parameters Parameter Description date Date/time object, in the range 100 AD–9999 AD. Usage When passing a date/time value as a string, you must enclose it in quotation marks.
  • Page 515: Htmlcodeformat

    HTMLCodeFormat Description Replaces special characters in a string with their HTML-escaped equivalents and inserts <pre> tags at the beginning and end of the string. </pre> Returns HTML-escaped string string, enclosed in tags. Returns are removed from <pre> </pre> string. Special characters ( ) are escaped.
  • Page 516: Htmleditformat

    HTMLEditFormat Description Replaces special characters in a string with their HTML-escaped equivalents. Returns HTML-escaped string string. Returns are removed from string. Special characters (for example, ) are escaped. < " & Category Display and formatting functions Function syntax HTMLEditFormat(string [, version ]) See also HTMLCodeFormat Parameters...
  • Page 517 Description Evaluates a Boolean conditional dynamic expression. Depending on whether the expression is true or false, dynamically evaluates one of two string expressions and returns the result. This function is convenient for incorporating a tag in-line in HTML. cfif For general conditional processing, see .
  • Page 518 Note: If you use pound signs (#) in string_expression1 or string_expression2, ColdFusion evaluates the part of the expression in pound signs first. If you misuse the pound signs, you can cause unexpected results from the IIf function. For example, if you use pound signs around the whole expression in string_expression1, and if there is an undefined variable in string_expression1, the function might fail, with the error 'Error Resolving Parameter,' If a variable is undefined, ColdFusion throws an error when it processes this function.
  • Page 519 </cfoutput> </b>...
  • Page 520: Incrementvalue

    IncrementValue Description Adds one to an integer. Returns The integer part of number, incremented by one. Category Mathematical functions Function syntax IncrementValue(number) See also DecrementValue Parameters Parameter Description number Number to increment Example <h3>IncrementValue Example</h3> <p>Returns the integer part of a number incremented by one. <p>IncrementValue(0): <cfoutput>#IncrementValue(0)#</cfoutput>...
  • Page 521: Inputbasen

    InputBaseN Description Converts string, using the base specified by radix, to an integer. Returns A number in the range 2-36, as a string. Category Mathematical functions Function syntax InputBaseN(string, radix) See also FormatBaseN Parameters Parameter Description string A string or a variable that contains one. String that represents a number, in the base specified by radix.
  • Page 522: Insert

    Insert Description Inserts a substring in a string after a specified character position. If = 0, prefixes the position substring to the string. Returns A string. Category String functions Function syntax Insert(substring, string, position) See also RemoveChars, Parameters Parameter Description substring A string or a variable that contains one.
  • Page 523 Description Calculates the closest integer that is smaller than number. Returns An integer, as a string. Category Mathematical functions Function syntax Int(number) See also Ceiling, Fix, Round Parameters Parameter Description number Real number to round down to an integer Example <h3>Int Example</h3>...
  • Page 524: Isarray

    IsArray Description Determines whether a value is an array. Returns True, if value is an array, or a query column object. Category Array functions, Decision functions Function syntax IsArray(value [, number ]) See also Array functions History ColdFusion MX: • Changed behavior: if the attribute contains a reference to a query result column, this value...
  • Page 525: Isauthenticated

    IsAuthenticated Description This function is obsolete. Use the newer security tools; see “Authentication functions” on page 367 Chapter 16, “Securing Applications,” in Developing ColdFusion MX Applications. History ColdFusion MX: This function is obsolete. It does not work in ColdFusion MX and later ColdFusion releases.
  • Page 526: Isauthorized

    IsAuthorized Description This function is obsolete. Use the newer security tools; see “Authentication functions” on page 367 Chapter 16, “Securing Applications,” in Developing ColdFusion MX Applications History ColdFusion MX: This function is obsolete. It does not work in ColdFusion MX and later releases. Chapter 3: ColdFusion Functions...
  • Page 527: Isbinary

    IsBinary Description Determines whether a value is stored as binary data. Returns True, if the value is binary; False, otherwise. Category Decision functions Function syntax IsBinary(value) See also ToBinary, ToBase64, IsNumeric, YesNoFormat Parameters Parameter Description value Number or string Example <!--- Create a string of all ASCII characters (32-255) and concatenate them together.
  • Page 528: Isboolean

    IsBoolean Description Determines whether a value can be converted to Boolean Returns True, if the parameter can be converted to Boolean; False, otherwise. Category Decision functions Function syntax IsBoolean(value) See also IsNumeric, YesNoFormat Parameters Parameter Description value Number or string Example <h3>IsBoolean Example</h3>...
  • Page 529: Iscustomfunction

    IsCustomFunction Description Determines whether a name represents a custom function. Returns True, if name can be called as a custom function; False, otherwise. Category Decision functions Function syntax IsCustomFunction(name) Parameters Parameter Description name Name of a custom function. Must not be in quotes. If not a defined variable or function name, ColdFusion generates an error.
  • Page 530 IsCustomFunction(myTestCFCobject.testFunc)> myTestCFCobject.testFunc is a function. </CFIF> Chapter 3: ColdFusion Functions...
  • Page 531: Isdate

    IsDate Description Determines whether a string or Java object can be converted to a date/time value. Returns True, if string can be converted to a date/time value; otherwise, False. ColdFusion converts the Boolean return value to its string equivalent, "Yes" or "No." Category Date and time functions,...
  • Page 532: Isdebugmode

    IsDebugMode Description Determines whether debugging output is enabled. Returns True, if debugging mode is set in the ColdFusion Administrator; False if debugging mode is disabled. Category Decision functions Function syntax IsDebugMode() See also cfsetting Description If debugging output is enabled in ColdFusion Administrator and has not been overridden by setting the attribute to No, the function returns...
  • Page 533: Isdefined

    IsDefined Description Evaluates a string value to determine whether the variable named in it exists. This function is an alternative to the function, which is deprecated. ParameterExists Returns True, if the variable is found, or, for a structure, if the specified key is defined; False, otherwise. Returns False for an array or structure element referenced using bracket notation.
  • Page 534 <input type="Submit" name=""> </form> Chapter 3: ColdFusion Functions...
  • Page 535: Isk2Serverabroker

    IsK2ServerABroker Description This function is deprecated. Determines whether the K2Server version is K2 Broker. For more information, see on page 495. This function is used primarily by the ColdFusion GetK2ServerDocCountLimit Verity and K2Server Administrator pages. This function uses Verity K2Server Release K2.2.0. Returns True, if K2Broker is in configured with ColdFusion;...
  • Page 536: Isk2Serverdoccountexceeded

    IsK2ServerDocCountExceeded Description This function is deprecated. Determines whether the number of documents that can be searched by the ColdFusion registered K2 Server exceed the limit. Depends on the K2Server platform limit; see on page 495. GetK2ServerDocCountLimit This function is used primarily by the ColdFusion Verity and K2Server Administrator pages. This function uses Verity K2Server Release K2.2.0.
  • Page 537: Isk2Serveronline

    IsK2ServerOnline Description This function is deprecated. Determines whether the K2Server is running and available to perform a search. This function is used primarily by the ColdFusion Verity and K2Server Administrator pages. This function uses Verity K2Server Release K2.2.0. Returns True, if the K2Server is available to perform a search; False, otherwise. Category Decision functions,...
  • Page 538: Isleapyear

    IsLeapYear Description Determines whether a year is a leap year. Returns True, if year is a leap year; otherwise, False. Category Date and time functions, Decision functions Function syntax IsLeapYear(year) See also DaysInYear Parameters Parameter Description year Number representing a year Example <h3>IsLeapYear Example</h3>...
  • Page 539: Isnumeric

    IsNumeric Description Determines whether a string can be converted to a numeric value. Supports numbers in U.S. number format. For other number support, use LSIsNumeric Returns True, if string can be converted to a number; otherwise, False. Category Decision functions Function syntax IsNumeric(string) See also...
  • Page 540: Isnumericdate

    IsNumericDate Description Evaluates whether a real number is a valid representation of a date (date/time object). Returns True, if the parameter represents a valid date/time object; otherwise, False. Category Date and time functions, Decision functions Function syntax IsNumericDate(number) See also IsDate, ParseDateTime Parameters...
  • Page 541: Isobject

    IsObject Description Determines whether a value is an object. Returns True, if the value represents a ColdFusion object. False if the value is any other type of data, such as an integer, string, date, or struct. Category Decision functions Function syntax IsObject(value) See also IsDate, IsNumeric, IsNumericDate, IsQuery, IsSimpleValue, IsStruct, IsWDDX,...
  • Page 542 </cfif> </cfif> Chapter 3: ColdFusion Functions...
  • Page 543: Isprotected

    IsProtected Description This function is obsolete. Use the newer security tools; see “Authentication functions” on page 367 Chapter 16, “Securing Applications,” in Developing ColdFusion MX Applications History ColdFusion MX: This function is obsolete. It does not work in ColdFusion MX and later releases. IsProtected...
  • Page 544: Isquery

    IsQuery Description Determines whether value is a query. Returns True, if value is a query. Category Decision functions, Query functions Function syntax IsQuery(value) See also QueryAddRow Parameters Parameter Description value Query variable Example <!--- Shows an example of IsQuery and IsSimpleValue ---> <h3>IsQuery Example</h3>...
  • Page 545: Issimplevalue

    IsSimpleValue Description Determines the type of a value. Returns True, if value is a string, number, Boolean, or date/time value; False, otherwise. Category Decision functions Function syntax IsSimpleValue(value) Parameters Parameter Description value Variable or expression Example <!--- Shows an example of IsQuery and IsSimpleValue ---> <h3>IsSimpleValue Example</h3>...
  • Page 546: Isstruct

    IsStruct Description Determines whether a variable is a structure. Returns True, if variable is a ColdFusion structure or is a Java object that implements the java.lang.Map interface. Returns False if the object in variable is a user-defined function (UDF). Category Decision functions, Structure functions...
  • Page 547 </cfcase> </cfswitch> ---> IsStruct...
  • Page 548: Isuserinrole

    IsUserInRole Description Determines whether an authenticated user belongs to the specified Role. Returns True, if the authenticated user, belongs to the specified Role; False, otherwise. Category Authentication functions, Decision functions Function syntax IsUserInRole("role_name") See also Chapter 16, “Securing Applications,” in Developing GetAuthUser, cflogin, cfloginuser, ColdFusion MX Applications History...
  • Page 549: Iswddx

    IsWDDX Description Determines whether a value is a well-formed WDDX packet. Returns True, if the value is a well-formed WDDX packet; False, otherwise. Category Decision functions, XML functions Syntax IsWDDX(value) History ColdFusion MX: Changed behavior: if the parameter is not a WDDX packet, ColdFusion value returns False.
  • Page 550 IsWDDX() returns #IsWDDX(packet)#<br> </cfoutput> Chapter 3: ColdFusion Functions...
  • Page 551: Isxmldoc

    IsXmlDoc Description Determines whether a function parameter is an Extended Markup language (XML) document object. Returns True, if the function argument is an XML document object; False, otherwise. Category Decision functions, XML functions Function syntax IsXmlDoc(value) See also IsXmlElem, IsXmlRoot, XmlChildPos, XmlNew, XmlParse, XmlSearch, XmlTransform History ColdFusion MX: Added this function.
  • Page 552: Isxmlelem

    IsXmlElem Description Determines whether a function parameter is an Extended Markup language (XML) document object element. Returns True, if the function argument is an XML document object element; False, otherwise. Category Decision functions, XML functions Function syntax IsXmlElem(value) See also IsXmlDoc, IsXmlRoot, XmlChildPos, XmlNew, XmlParse, XmlSearch, XmlTransform History...
  • Page 553: Isxmlroot

    IsXmlRoot Description Determines whether a function parameter is the root element of an Extended Markup language (XML) document object. Returns True, if the function argument is the root object of an XML document object; False, otherwise. Category Decision functions, XML functions Function syntax IsXmlRoot(value) See also...
  • Page 554: Javacast

    JavaCast Description Converts the data type of a ColdFusion variable to pass as an argument to an overloaded method of a Java object. Use only for scalar and string arguments. Returns The variable, as type type. Category String functions Function syntax JavaCast(type, variable) See also CreateObject,...
  • Page 555 Within ColdFusion, you use the following code: <cfobject action="create" type = "java" class = "fooClass" name = obj> <!--- ColdFusion can treat this as a string or a real number ---> <cfset x = 33> Perform an explicit cast to an int and call fooMethod:<br> <cfset myInt = JavaCast("int", x)>...
  • Page 556: Jsstringformat

    JSStringFormat Description Escapes special JavaScript characters, such as single quotation mark, double quotation mark, and newline. Returns A string that is safe to use with JavaScript. Category String functions Function syntax JSStringFormat(string) Parameters Parameter Description string A string or a variable that contains one. Usage Escapes special JavaScript characters, so you can put arbitrary strings safely into JavaScript.
  • Page 557: Lcase

    LCase Description Converts the alphabetic characters in a string to lowercase. Returns A string, converted to lowercase. Category String functions Function syntax LCase(string) See also UCase Parameters Parameter Description string A string or a variable that contains one Example <h3>LCase Example</h3> <cfif IsDefined("FORM.sampleText")>...
  • Page 558: Left

    Left Description Returns the leftmost count characters in a string. Returns String; the first count characters in the string parameter. Category String functions Function syntax Left(string, count) See also Right, Mid, Parameters Parameter Description string A string or a variable that contains one. count A positive integer or a variable that contains one.
  • Page 559 <option value="9">9</select> <input type="Submit" name="Remove characters"> </form> Left...
  • Page 560 Description Determines the length of a string or binary object. Returns Number; length of a string or a binary object. Category String functions Function syntax Len(string or binary object) See also ToBinary, Left, Right, History ColdFusion MX: Changed Unicode support: ColdFusion supports the Java UCS-2 representation of Unicode character values 0–65535.
  • Page 561: Listappend

    If this parameter contains more than one character, ColdFusion uses only the first character. Usage ColdFusion inserts a delimiter character before value. To add an element to the beginning or end of a list, Macromedia recommends that you do so with code such as the following, rather than with the functions: ListAppend ListPrepend <cfset MyValue = "another element">...
  • Page 562 <cfquery name = "GetParkInfo" datasource = "cfsnippets"> SELECT PARKNAME,CITY,STATE FROM PARKS WHERE PARKNAME LIKE ‘AL%’ </cfquery> <cfset temp = ValueList(GetParkInfo.ParkName)> <cfoutput> <p>The original list: #temp# </cfoutput> <!--- now, append a park name to the list ---> <cfset temp2 = ListAppend(Temp, "ANOTHER PARK")> Chapter 3: ColdFusion Functions...
  • Page 563: Listchangedelims

    ListChangeDelims Description Changes a list delimiter. Returns A copy of the list, with each delimiter character replaced by new_delimiter. Category List functions Function syntax ListChangeDelims(list, new_delimiter [, delimiters ]) See also ListFirst, ListQualify Parameters Parameter Description list A list or a variable that contains one. new_delimiter Delimiter string or a variable that contains one.
  • Page 564: Listcontains

    ListContains Description Determines the index of the first list element that contains a specified substring. Returns Index of the first list element that contains substring. If not found, returns zero. Category List functions Function syntax ListContains(list, substring [, delimiters ]) See also ListContainsNoCase, ListFind...
  • Page 565 <cfoutput> The string "two" is in <b>element #ListFind(aList, "two")#</b> of the list. </cfoutput> ListContains...
  • Page 566: Listcontainsnocase

    ListContainsNoCase Description Determines the index of the first list element that contains a specified substring. Returns Index of the first list element that contains substring, regardless of case. If not found, returns zero. Category List functions Function syntax ListContainsNoCase(list, substring [, delimiters ]) See also ListContains, ListFindNoCase...
  • Page 567: Listdeleteat

    ListDeleteAt Description Deletes an element from a list. Returns A copy of the list, without the specified element. Category List functions Function syntax ListDeleteAt(list, position [, delimiters ]) See also ListGetAt, ListSetAt, ListLen Parameters Parameter Description list A list or a variable that contains one. position A positive integer or a variable that contains one.
  • Page 568 <p>The changed list: #temp2# <p><I>This list element:<br>#deleted_element#<br> is no longer present at position three of the list.</I> </cfoutput> Chapter 3: ColdFusion Functions...
  • Page 569: Listfind

    ListFind Description Determines the index of the first list element in which a specified value occurs. Case-sensitive. Returns Index of the first list element that contains value, with matching case. If not found, returns zero. The search is case-sensitive. Category List functions Function syntax ListFind(list, value [, delimiters ])
  • Page 570 <!--- Is this case-sensitive or case-insensitive searching ---> <cfif form.type is "ListFind"> <cfset temp = ListFind(myList, form.myString)> <cfif temp is 0> <h3>An employee with that exact last name was not found</h3> <cfelse> <cfoutput> <p>Employee #ListGetAt(ValueList(SearchEmpLastName.FirstName), temp)# #ListGetAt(ValueList(SearchEmpLastName.LName), temp)#, of the #ListGetAt(ValueList(SearchEmpLastName.Department), temp)# Department, can be reached at #ListGetAt(ValueList(SearchEmpLastName.Phone), temp)#.
  • Page 571: Listfindnocase

    ListFindNoCase Description Determines the index of the first list element in which a specified value occurs. Returns Index of the first list element that contains value. If not found, returns zero. The search is case- insensitive. Category List functions Function syntax ListFindNoCase(list, value [, delimiters ]) See also ListContains,...
  • Page 572 <cfif form.type is "ListFind"> <cfset temp = ListFind(myList, form.myString)> <cfif temp is 0> <h3>An employee with that exact last name was not found</h3> <cfelse> <cfoutput> <p>Employee #ListGetAt(ValueList(SearchEmpLastName.FirstName), temp)# #ListGetAt(ValueList(SearchEmpLastName.LName), temp)#, of the #ListGetAt(ValueList(SearchEmpLastName.Department), temp)# Department, can be reached at #ListGetAt(ValueList(SearchEmpLastName.Phone), temp)#.
  • Page 573: Listfirst

    ListFirst Description Gets the first element of a list. Returns The first element of a list. If the list is empty, returns an empty string. Category List functions Function syntax ListFirst(list [, delimiters ]) See also ListGetAt, ListLast, ListQualify Parameters Parameter Description list...
  • Page 574: Listgetat

    ListGetAt Description Gets a list element at a specified position. Returns Index of the list element at position position. Category List functions Function syntax ListGetAt(list, position [, delimiters ]) See also ListFirst, ListLast, ListQualify, ListSetAt Parameters Parameter Description list A list or a variable that contains one. position A positive integer or a variable that contains one.
  • Page 575 <cfloop From = "1" To = "#ListLen(temp)#" index = "Counter"> <cfoutput><li>Username #Counter#: #ListGetAt(temp, Counter)# </cfoutput> </cfloop> </ul> ListGetAt...
  • Page 576: Listinsertat

    ListInsertAt Description Inserts an element in a list. Returns A copy of the list with value inserted at the specified position. Category List functions Function syntax ListInsertAt(list, position, value [, delimiters ]) See also ListDeleteAt, ListAppend, ListPrepend, ListSetAt Parameters Parameter Description list A list or a variable that contains one.
  • Page 577: Listlast

    ListLast Description Gets the last element of a list. Returns The last element of the list. Category List functions Function syntax ListLast(list [, delimiters ]) See also ListGetAt, ListFirst Parameters Parameter Description list A list or a variable that contains a list. delimiters A string or a variable that contains one.
  • Page 578 <p>(Users who posted more than once are listed more than once.) <p>The last user in the list is: <cfoutput>#ListLast(temp)#</cfoutput> Chapter 3: ColdFusion Functions...
  • Page 579: Listlen

    ListLen Description Determines the number of elements in a list. Integer; the number of elements in a list. Category List functions Function syntax ListLen(list [, delimiters ]) See also ListAppend, ListDeleteAt, ListInsertAt, ListPrepend Parameters Parameter Description list A list or a variable that contains one. delimiters A string or a variable that contains one.
  • Page 580: Listprepend

    (""), ColdFusion returns the contents of the delimiters parameter. value To add an element to the beginning or end of a list, Macromedia recommends that you do so with code such as the following, rather than with the functions: ListAppend ListPrepend <cfset MyValue = "another element">...
  • Page 581 <cfset first_element = ListFirst(temp)> <cfoutput><p>The original list: #temp#</cfoutput> <!--- now, insert an element at position 1---> <cfset temp2 = ListPrepend(Temp, "my Inserted Value")> ListPrepend...
  • Page 582: Listqualify

    ListQualify Description Inserts a string at the beginning and end of list elements. Returns A copy of the list, with qualifier before and after the specified element(s). Category List functions Function syntax ListQualify(list, qualifier [, delimiters ] [, elements ]) History ColdFusion MX: Changed behavior: as the parameter value, you must specify "...
  • Page 583 <!--- sort that array descending alphabetically ---> <cfset myAlphaArray = ArraySort(myArray, "textnocase")> <!--- show the resulting array as a list ---> <cfset myList = ArrayToList(myArray, ",")> <cfoutput> <p>The contents of the unqualified list are as follows:</p> #myList# </cfoutput> <!--- show the resulting alphabetized array as a qualified list with single quotes around each full name.
  • Page 584: Listrest

    ListRest Description Gets a list, without its first element. Returns A copy of list, without the first element. If list has one element, returns an empty list. Category List functions Function syntax ListRest(list [, delimiters ]) See also ListFirst, ListGetAt, ListLast Parameters Parameter...
  • Page 585: Listsetat

    ListSetAt Description Replaces the contents of a list element. Returns A copy of a list, with a new value assigned to the element at a specified position. Category List functions Function syntax ListSetAt(list, position, value [, delimiters ]) See also ListDeleteAt, ListGetAt, ListInsertAt History...
  • Page 586 subjects posted in messages.</h3> <cfset ChangedElement = ListGetAt(temp, 2)> <cfset TempToo = ListSetAt(temp, 2, "I changed this subject", ",")> <ul> <cfloop From = "1" To = "#ListLen(temptoo)#" INDEX = "Counter"> <cfoutput><li>(#Counter#) SUBJECT: #ListGetAt(temptoo, Counter)# </cfoutput> </cfloop> </ul> <p>Note that element 2, "<cfoutput>#changedElement#</cfoutput>", has been altered to "I changed this subject"...
  • Page 587: Listsort

    ListSort Description Sorts list elements according to a sort type and sort order. Returns A copy of a list, sorted. Category List functions Function syntax ListSort(list, sort_type [, sort_order] [, delimiters ]) History ColdFusion MX: Changed the order in which sorted elements are returned: in a textnocase descending sort, this function might return elements in a different sort order than in earlier releases.
  • Page 588 Parameter Description sort_order • asc - ascending sort order. Default. - aabzABZ or aAaBbBzzZ, depending on value of , for letters sort_type - from smaller to larger, for numbers • desc - descending sort order. - ZBAzbaa or ZzzBbBaAa, depending on value of , for letters sort_type - from larger to smaller, for numbers...
  • Page 589: Listtoarray

    ListToArray Description Copies the elements of a list to an array. Returns An array Category Array functions, Conversion functions, List functions Function syntax ListToArray(list [, delimiters ]) See also ArrayToList Parameters Parameter Description list A list or a variable that contains one. You define a list variable with a statement.
  • Page 590: Listvaluecount

    ListValueCount Description Counts instances of a specified value in a list. The search is case-sensitive. Returns The number of instances of value in the list. Category List functions, String functions Function syntax ListValueCount(list, value [, delimiters ]) See also ListValueCountNoCase Parameters Parameter Description...
  • Page 591 <cfif IsDefined("FORM.Submit") and IsDefined("FORM.departmentName")> <cfset myList = ValueList(SearchByDepartment.Department)> <cfset numberInDepartment = ListValueCount(myList, FORM.departmentName)> <cfif numberInDepartment is 0> <h3>There are no employees in <cfoutput>#FORM.departmentName#</cfoutput></ h3> <cfelseIf numberInDepartment is 1> <cfoutput><p>There is only one person in #FORM.departmentName#. </cfoutput> <cfelse> <cfoutput><p>There are #numberInDepartment# people in #FORM.departmentName#.
  • Page 592: Listvaluecountnocase

    ListValueCountNoCase Description Counts instances of a specified value in a list. The search is case-insensitive. Returns The number of instances of value in the list. Category List functions Function syntax ListValueCountNoCase(list, value [, delimiters ]) See also ListValueCount Parameters Parameter Description list A list or a variable that contains one.
  • Page 593 <!--- wait to have a string for searching defined ---> <cfif IsDefined("FORM.Submit") and IsDefined("FORM.departmentName")> <cfset myList = ValueList(SearchByDepartment.Department)> <cfset numberInDepartment = ListValueCountNoCase(myList, FORM.departmentName)> <cfif numberInDepartment is 0> <h3>There are no employees in <cfoutput>#FORM.departmentName#</ cfoutput></h3> <cfelseIf numberInDepartment is 1> <cfoutput><p>There is only one person in #FORM.departmentName#. </cfoutput>...
  • Page 594: Ljustify

    LJustify Description Left justifies characters in a string of a specified length. Returns A copy of a string, left-justified. Category Display and formatting functions, String functions Function syntax LJustify(string, length) See also CJustify, RJustify Parameters Parameter Description string A string or a variable that contains one length Length of field in which to justify string Example...
  • Page 595 Description Calculates the natural logarithm of a number. Natural logarithms are based on the constant e (2.71828182845904). Returns The natural logarithm of a number. Category Mathematical functions Function syntax Log(number) See also Exp, Log10 Parameters Parameter Description number Positive real number for which to calculate the natural logarithm Example <h3>Log Example</h3>...
  • Page 596: Log10

    Log10 Description Calculates the logarithm of number, to base 10. Returns Number; the logarithm of number, to base 10. Category Mathematical functions Function syntax Log10(number) See also Exp, Parameters Parameter Description number Positive real number for which to calculate the logarithm Example <h3>Log10 Example</h3>...
  • Page 597: Lscurrencyformat

    LSCurrencyFormat Description Formats a number in a locale-specific currency format. For countries that use the euro, the result depends on the JVM. Returns A formatted currency value. Category Display and formatting functions, International functions Function syntax LSCurrencyFormat(number [, type ]) See also LSEuroCurrencyFormat, LSIsCurrency, LSParseCurrency, LSParseEuroCurrency, SetLocale...
  • Page 598 Locale Type = Local Type = International Type = None Chinese (Taiwan) NT$100,000.00 TWD100,000.00 100,000.00 Dutch (Belgian) 100.000,00 ¤ BEF100.000,00 100.000,00 100.000,00 BF EUR100.000,00 Dutch (Standard) ¤ 100.000,00 NLG100.000,00 100.000,00 fl 100.000,00 EUR100.000,00 English (Australian) $100,000.00 AUD100,000.00 100,000.00 English (Canadian) $100,000.00 CAD100,000.00 100,000.00...
  • Page 599 Note: ColdFusion maps Spanish (Modern) to the Spanish (Standard) format. To set the default display format of date, time, number, and currency values, use the SetLocale function. Example <h3>LSCurrencyFormat Example</h3> <p>LSCurrencyFormat returns a currency value using the locale convention. Default value is "local." <!--- loop through list of locales;...
  • Page 600: Lsdateformat

    LSDateFormat Description Formats the date part of a date/time value in a locale-specific format. Returns A formatted date/time value. If no mask is specified, the value is formatted according to the locale setting of the client computer. Category Date and time functions, Display and formatting functions,...
  • Page 601 When passing date/time value as a string, enclose it in quotation marks. Otherwise, it is interpreted as a number representation of a date/time object. To calculate a difference between time zones, use the function. GetTimeZoneInfo Example <h3>LSDateFormat Example</h3> <p>LSDateFormat formats the date part of a date/time value using the locale convention.
  • Page 602 LSEuroCurrencyFormat Description Formats a number in a locale-specific currency format. Returns A formatted currency value. For countries in the Euro currency zone, the function uses the locale’s rule’s for formatting currency in euros. Category Display and formatting functions, International functions Function syntax LSEuroCurrencyFormat(currency-number [, type ]) See also...
  • Page 603 Currency output The following table shows examples of currency output: Locale Type = Local Type = International Type = None Chinese (China) ¥100,000.00 CNY100,000.00 100,000.00 Chinese (Hong Kong) HK$100,000.00 HKD100,000.00 100,000.00 Chinese (Taiwan) NT$100,000.00 TWD100,000.00 100,000.00 Dutch (Belgian) 100.000,00 ¤ EUR100.000,00 100.000,00 Dutch (Standard)
  • Page 604 The following example shows how the function formats negative values. The format includes a negative sign before the value, or parentheses around the value, according to the formatting rules of the current locale. Input value Output if locale = French (Standard) Output if locale = English (US) -1234.56 -1 234,56 ¤...
  • Page 605: Lsiscurrency

    LSIsCurrency Description Determines whether a string is a valid representation of a currency amount in the current locale. Returns True, if the parameter is formatted as a valid currency amount, including the appropriate currency indicator. Returns True for amounts in the local, international, or none currency formats. Category Display and formatting functions,...
  • Page 606 <p><form action = "LSIsCurrency.cfm"> <p>Select a locale for which you would like to check a currency value: <!--- check the current locale for server ---> <cfset serverLocale = GetLocale()> Chapter 3: ColdFusion Functions...
  • Page 607: Lsisdate

    LSIsDate Description Determines whether a string is a valid representation of a date/time value in the current locale. Returns True, if the string can be formatted as a date/time value in the current locale; False, otherwise. Category Date and time functions, Display and formatting functions,...
  • Page 608 <!--- check the current locale for server ---> <cfset serverLocale = GetLocale()> Chapter 3: ColdFusion Functions...
  • Page 609: Lsisnumeric

    LSIsNumeric Description Determines whether a string is a valid representation of a number in the current locale. Returns True, if the string represents a number the current locale; False, otherwise. Category Decision functions, International functions, String functions Function syntax LSIsNumeric(string) See also GetLocale, SetLocale...
  • Page 610: Lsnumberformat

    LSNumberFormat Description Formats a number in a locale-specific format. Returns A formatted number. • If no mask is specified, it returns the number formatted as an integer • If no mask is specified, truncates the decimal part; for example, it truncates 34.57 to 35 •...
  • Page 611 Character Meaning Puts space before positive number; minus sign before negative number. Separates every third decimal place with a comma (or locale-appropriate symbol). Left-justifies or center-justifies number within width of mask column. First character of mask must be L or C. Default: right-justified. Puts a dollar sign (or locale-appropriate symbol) before formatted number.
  • Page 612 Number Mask Result 3.21 C(__^)__ "( 3.21) " 3.21 C__(^)__ " (3.21) " To set the default display format of date, time, number, and currency values, use the SetLocale function. When converting from string to double, to prevent rounding errors, this function adds a rounding factor of 1.5543122344752E-014 to the converted number.
  • Page 613: Lsparsecurrency

    LSParseCurrency Description Converts a locale-specific currency string into a formatted number. Attempts conversion by comparing the string with each the three supported currency formats (none, local, international) and using the first that matches. Returns A formatted number (string representation of a number) that matches the value of the parameter. Category International functions,...
  • Page 614 <!--- loop through a list of locales; show currency values for 123,456 units - --> <cfloop LIST = "#Server.Coldfusion.SupportedLocales#" index = "locale" delimiters = ","> <cfset oldlocale = SetLocale(locale)> <cfoutput><p><B><I>#locale#</I></B><br> Local: #LSCurrencyFormat(123456.78, "local")#<br> Parsed local Currency: #LSParseCurrency(LSCurrencyFormat(123456,"local"))#<br> International: #LSCurrencyFormat(123456.78999, "international")#<br> Parsed International Currency: #LSParseCurrency(LSCurrencyFormat(123456.78999,"international"))#<br>...
  • Page 615: Lsparsedatetime

    LSParseDateTime Description Converts a string that is a valid date/time representation in the current locale into a date/time object. Returns A date/time object. Category Date and time functions, Display and formatting functions, International functions, String functions Function syntax LSParseDateTime(date/time-string) See also LSDateFormat, ParseDateTime, SetLocale, GetLocale History...
  • Page 616 Valid dates are in the range 100 AD–9999 AD. Two digit years in the range 00-29 are interpreted as being 2000-2029. Two digit years in the range 30-99 are interpreted as being 1930-1999 This function corrects for differences between the current time zone and any time zone specified in the input parameter.
  • Page 617: Lsparseeurocurrency

    LSParseEuroCurrency Description Formats a locale-specific currency string as a number. Attempts conversion through each of the default currency formats (none, local, international). Ensures correct handling of euro currency for Euro zone countries. Returns A formatted number that matches the value of the string. Category International functions,...
  • Page 618 <cfset IntlCurrency = LSEuroCurrencyFormat(123456, "international")> Value with International currency formatting: #IntlCurrency#<br> Parsed using LSParseEuroCurrency: #LSParseEuroCurrency(IntlCurrency)#<br> <cfset Currency = LSEuroCurrencyFormat(123456, "none")> Value with no currency formatting: #currency#<br> Parsed using LSParseEuroCurrency: #LSParseEuroCurrency(Currency)#<br> <hr noshade> </cfoutput> </cfloop> Chapter 3: ColdFusion Functions...
  • Page 619: Lsparsenumber

    LSParseNumber Description Converts a string that is a valid numeric representation in the current locale into a formatted number. Returns A formatted number that matches the value of the string. Category International functions, String functions Function syntax LSParseNumber(string) See also LSParseDateTime, SetLocale History...
  • Page 620 </cfoutput> </cfloop> Chapter 3: ColdFusion Functions...
  • Page 621: Lstimeformat

    LSTimeFormat Description Formats the time part of a date/time string into a string in a locale-specific format. Returns A string representing the time value. Category Date and time functions, Display and formatting functions, International functions Function syntax LSTimeFormat(time [, mask ]) See also LSParseDateTime, LSDateFormat, TimeFormat...
  • Page 622 Usage This function uses Java standard locale formatting rules on all platforms. When passing date/time value as a string, enclose it in quotation marks. Otherwise, it is interpreted as a number representation of a date/time object. To calculate a difference between time zones, use the function.
  • Page 623: Ltrim

    LTrim Description Removes leading spaces from a string. Returns A copy of the string, without leading spaces. Category Display and formatting functions, String functions Function syntax LTrim(string) See also RTrim, ToBase64 Parameters Parameter Description string A string or a variable that contains one Example <h3>LTrim Example</h3>...
  • Page 624 Description Determines the greater of two numbers. Returns The greater of two numbers. Category Mathematical functions Function syntax Max(number1, number2) See also Parameters Parameter Description number1, number2 Numbers Example <h3>Max Example</h3> <cfif IsDefined("FORM.myNum1")> <cfif IsNumeric(FORM.myNum1) and IsNumeric(FORM.myNum2)> <p>The maximum of the two numbers is <cfoutput>#Max(FORM.myNum1, FORM.myNum2)#</cfoutput>...
  • Page 625 Description Extracts a substring from a string. Returns A string; the set of characters from string, beginning at start, of length count. Category String functions Function syntax Mid(string, start, count) See also Left, Len, Right Parameters Parameter Description string A string or a variable that contains one. Must be single-quote or double-quote delimited.
  • Page 626 Description Determines the lesser of two numbers. Returns The lesser of two numbers. Category Mathematical functions Function syntax Min(number1, number2) See also Parameters Parameter Description number1, number2 Numbers Example <h3>Min Example</h3> <cfif IsDefined("FORM.myNum1")> <cfif IsNumeric(FORM.myNum1) and IsNumeric(FORM.myNum2)> <p>The maximum of the two numbers is <cfoutput>#Max(FORM.myNum1, FORM.myNum2)#</cfoutput>...
  • Page 627: Minute

    Minute Description Extracts the minute value from a date/time object. Returns The ordinal value of the minute, in the range 0–59. Category Date and time functions Function syntax Minute(date) See also DatePart, Hash, Second Parameters Parameter Description date • A date/time object, in the range 100 AD–9999 AD. Usage When passing a date/time value as a string, you must enclose it in quotation marks.
  • Page 628: Month

    Month Description Extracts the month value from a date/time object. Returns The ordinal value of the month, in the range 1 (January) – 12 (December). Category Date and time functions Function syntax Month(date) See also DatePart, MonthAsString, Quarter Parameters Parameter Description date Date/time object, in the range 100 AD–9999 AD.
  • Page 629: Monthasstring

    MonthAsString Description Determines the name of the month that corresponds to month_number. Returns A string; the name of a month. Category Date and time functions, String functions Function syntax MonthAsString(month_number) See also DatePart, Month, Quarter Parameters Parameter Description month_number An integer in the range 1 – 12. Example <h3>MonthAsString Example</h3>...
  • Page 630 Description Gets the current date and time of the computer running the ColdFusion server. The return value can be passed as a parameter to date functions such as DaysInYear FirstDayOfMonth Returns A date/time object; the current date and time of the computer running the ColdFusion server. Category Date and time functions Function syntax...
  • Page 631: Numberformat

    NumberFormat Description Creates a custom-formatted number value. Supports the numeric formatting used in the U.S. For international number formatting, see LSNumberFormat Returns A formatted number value: • If no mask is specified, returns the value as an integer with a thousands separator. •...
  • Page 632 Mask character Meaning Puts a dollar sign before formatted number. First character of mask must be the dollar sign ($). Separates left and right formatting. Note: If you do not specify a sign for the mask, positive and negative numbers do not align in columns.
  • Page 633 When converting from string to double, to prevent rounding errors, this function adds a rounding factor of 1.5543122344752E-014 to the converted number. For example, without adding the rounding factor, converting the string value 1.275 to double with two digits of precision results in a value of 1.27499999999999999, which would be rounded up to 1.27.
  • Page 634: Paragraphformat

    ParagraphFormat Description Replaces characters in a string: • Single newline characters (CR/LF sequences) with spaces • Double newline characters with HTML paragraph tags (<p>) Returns A copy of the string, with characters converted. Category Display and formatting functions, String functions Function syntax ParagraphFormat(string) See also...
  • Page 635: Parameterexists

    ParameterExists Description This function is deprecated. Use the function. IsDefined Determines whether a parameter exists. ColdFusion does not evaluate the argument. History ColdFusion MX: Deprecated this function. It might not work, and might cause an error, in later releases. ParameterExists...
  • Page 636: Parsedatetime

    ParseDateTime Description Parses a date/time string according to the English (U.S.) locale conventions. (To format a date/ time string for other locales, use the function.) LSParseDateTime Returns A date/time object Category Date and time functions, Display and formatting functions Function syntax ParseDateTime(date/time-string [, pop-conversion ] ) See also IsDate, IsNumericDate,...
  • Page 637 <form action="#CGI.ScriptName#" method="POST"> <p>Enter an expression, and discover if it can be evaluated to a date value. <input type="Text" name="TheTestValue" value="<CFOUTPUT>#DateFormat(Now())# #TimeFormat(Now())#</CFOUTPUT>"> <input type="Submit" value="Parse the Date" name=""> </form> ParseDateTime...
  • Page 638 Description Gets the mathematical constant , accurate to 15 digits. Returns The number 3.14159265358979. Category Mathematical functions Function syntax Pi() See also ASin, Cos, Sin, Example <h3>Pi Example</h3> <!--- By default, ColdFusion displays only 11 significant digits. Use NumberFormat to display all 15. ---> The Pi function Returns the number <cfoutput>...
  • Page 639: Preservesinglequotes

    PreserveSingleQuotes Description Prevents ColdFusion from automatically escaping single quotation mark characters that are contained in a variable. ColdFusion does not evaluate the argument. Returns (None) Category Other functions Function syntax PreserveSingleQuotes(variable) History ColdFusion MX: Changed behavior: ColdFusion automatically escapes simple-variable, array- variable, and structure-variable references within a tag body or block.
  • Page 640 This function ensures that ColdFusion evaluates the code as follows: '1', '2', '3' Example <h3>PreserveSingleQuotes Example</h3><p>This is a useful function for creating lists of information to return from a query. In this example, we pick the list of Centers in Suisun, San Francisco, and San Diego, using the SQL grammar IN to modify a WHERE clause, rather than looping through the result set after the query is run.
  • Page 641: Quarter

    Quarter Description Calculates the quarter of the year in which a date falls. Returns An integer, 1–4. Category Date and time functions Function syntax Quarter(date) See also DatePart, Month Parameters Parameter Description date A date/time object in the range 100 AD–9999 AD. Usage When passing a date/time value as a string, you must enclose it in quotation marks.
  • Page 642: Queryaddcolumn

    QueryAddColumn Description Adds a column to a query and populates its rows with the contents of a one-dimensional array. Pads query columns, if necessary, to ensure that all columns have the same number of rows. Returns The number of the column that was added. Category Query functions Function syntax...
  • Page 643 <!--- add a column to the query ---> <cfset nColumnNumber = QueryAddColumn(myQuery, "FastFood", FastFoodArray)> <!--- create a second array ---> <cfset FineCuisineArray = ArrayNew(1)> <cfset FineCuisineArray[1] = "Lobster"> <cfset FineCuisineArray[2] = "Flambe"> <!--- add a second column to the query ---> <cfset nColumnNumber2 = QueryAddColumn(myQuery, "FineCuisine", FineCuisineArray)>...
  • Page 644: Queryaddrow

    QueryAddRow Description Adds a specified number of empty rows to a query. Returns The number of rows in the query Category Query functions Function syntax QueryAddRow(query [, number ]) See also QueryAddColumn, QueryAddRow, QuerySetCell, QueryNew Parameters Parameter Description query Name of an executed query. number Number of rows to add to the query.
  • Page 645: Querynew

    QueryNew Description Creates an empty query (query object). Returns An empty query with a set of named columns, or an empty query. Category Query functions Function syntax QueryNew(columnlist) See also QueryAddColumn, QueryAddRow, QuerySetCell Parameters Parameter Description columnlist A string or a variable that contains one. Delimited list of column names, or an empty string.
  • Page 646: Querysetcell

    QuerySetCell Description Sets a cell to a value. If no row number is specified, the cell on the last row is set. Returns True, if successful; False, otherwise. Category Query functions Function syntax QuerySetCell(query, column_name, value [, row_number ]) See also QueryAddColumn, QueryAddRow, QueryNew Parameters...
  • Page 647: Quotedvaluelist

    QuotedValueList Description Gets the values of each record returned from an executed query. ColdFusion does not evaluate the arguments. Returns A delimited list of the values of each record returned from an executed query. Each value is enclosed in single quotation marks. Category Query functions Function syntax...
  • Page 648: Rand

    Rand Description Generates a random number. Returns A random decimal number, in the range 0 – 1. Category Mathematical functions Function syntax Rand() See also Randomize, RandRange Usage To ensure greater randomness, call the function before calling Randomize Rand Example <h3>Rand Example</h3>...
  • Page 649: Randomize

    Randomize Description Seeds the ColdFusion random number generator with an integer number. Seeding the generator helps ensure that the function generates highly random numbers. Rand Returns A non-random decimal number, in the range 0 – 1. Category Mathematical functions Function syntax Randomize(number) See also Rand,...
  • Page 650: Randrange

    RandRange Description Generates a random integer between two specified numbers. Requests for random integers that are greater than 100,000,000 result in non-random numbers, to prevent overflow during internal computations. Returns A random integer Category Mathematical functions Function syntax RandRange(number1, number2) See also Rand, Randomize...
  • Page 651: Refind

    REFind Description Uses a regular expression (RE) to search a string for a pattern. The search is case sensitive. For more information on regular expressions, including escape sequences, anchors, and modifiers, Chapter 7, “Using Regular Expressions in Functions,” in Developing ColdFusion MX Applications.
  • Page 652 Parameter Description start Optional. A positive integer, or a variable that contains one. Position in the string at which to start search. Default: 1. returnsubexpressions Optional. Boolean. Whether to return substrings of reg_expression, in arrays named • True: if the regular expression is found, the first array element contains the length and position, respectively, of the first match.
  • Page 653 <p> <cfoutput> The number of elements in each array: #ArrayLen(st.pos)#. </cfoutput></p> <p><b>The number of elements in the pos and len arrays is always one if you do not use parentheses in the regular expression.</b></p> <p>The value of st.pos[1] is: <cfoutput>#st.pos[1]#.</cfoutput></p> <p>The value of st.len[1] is: <cfoutput>#st.len[1]#.</cfoutput></p>...
  • Page 654: Refindnocase

    REFindNoCase Description Uses a regular expression (RE) to search a string for a pattern, starting from a specified position. The search is case-insensitive. For more information on regular expressions, including escape sequences, anchors, and modifiers, Chapter 7, “Using Regular Expressions in Functions,” in Developing ColdFusion MX Applications.
  • Page 655 Parameter Description start Optional. A positive integer or a variable that contains one. Position at which to start search. Default: 1. returnsubexpressions Optional. Boolean. Whether to return substrings of reg_expression, in arrays named • True: if the regular expression is found, the first array element contains the length and position, respectively, of the first match.
  • Page 656 <cfset st = REFindNoCase("[[:alpha:]]+",testString,1,"True")> <p> <cfoutput> The number of elements in each array: #ArrayLen(st.pos)#. </cfoutput></p> <p><b>The number of elements in the pos and len arrays will always be one, if you do not use parentheses to denote subexpressions in the regular expression.</b></p>...
  • Page 657: Releasecomobject

    ReleaseComObject Description Releases a COM Object and frees up resources that it used. Returns Nothing. Category Extensibility functions Function syntax ReleaseComObject(objectName) See also CreateObject, cfobject History ColdFusion MX 6.1: Added this function. Parameters Parameter Description objectName Variable name of a COM object that was created using the function CreateObject tag.
  • Page 658: Removechars

    RemoveChars Description Removes characters from a string. Returns A copy of the string, with count characters removed from the specified start position. If no characters are found, returns zero. Category String functions Function syntax RemoveChars(string, start, count) See also Insert, Parameters Parameter Description...
  • Page 659: Repeatstring

    RepeatString Description Creates a string that contains a specified number of repetitions of the specified string. Returns A string. Category String functions Function syntax RepeatString(string, count) See also CJustify, LJustify, RJustify Parameters Parameter Description string A string or a variable that contains one count Number of repeats Example...
  • Page 660: Replace

    Replace Description Replaces occurrences of substring1 in a string with substring2, in a specified scope. The search is case-sensitive. Returns The string, after making replacements. Category String functions Function syntax Replace(string, substring1, substring2 [, scope ]) See also Find, REFind, ReplaceNoCase, ReplaceList, REReplace Parameters Parameter...
  • Page 661: Replacelist

    ReplaceList Description Replaces occurrences of the elements from a delimited list in a string with corresponding elements from another delimited list. The search is case-sensitive. Returns A copy of the string, after making replacements. Category List functions, String functions Function syntax ReplaceList(string, list1, list2) See also Find, REFind, Replace,...
  • Page 662 #replacelist(stringtoreplace,"dog,brown,fox,black", "cow,black,ferret,white")# </cfoutput> Chapter 3: ColdFusion Functions...
  • Page 663: Replacenocase

    ReplaceNoCase Description Replaces occurrences of substring1 with substring2, in the specified scope. The search is case- insensitive. Returns A copy of the string, after making replacements. Category String functions Function syntax ReplaceNoCase(string, substring1, substring2 [, scope ]) See also Find, REFind, Replace, ReplaceList, REReplace Parameters Parameter...
  • Page 664: Rereplace

    REReplace Description Uses a regular expression (RE) to search a string for a string pattern and replace it with another. The search is case-sensitive. Returns If the attribute is set to , returns a string with the first occurrence of the regular scope expression replaced by the value of substring.
  • Page 665 Example <p>The REReplace function returns <i>string</i> with a regular expression replaced with <i>substring</i> in the specified scope. Case-sensitive search. <p>REReplace("CABARET","C|B","G","ALL"): <cfoutput>#REReplace("CABARET","C|B","G","ALL")#</cfoutput> <p>REReplace("CABARET","[A-Z]","G","ALL"): <cfoutput>#REReplace("CABARET","[A-Z]","G","ALL")#</cfoutput> <p>REReplace("I love jellies","jell(y|ies)","cookies"): <cfoutput>#REReplace("I love jellies","jell(y|ies)","cookies")# </cfoutput> <p>REReplace("I love jelly","jell(y|ies)","cookies"): <cfoutput>#REReplace("I love jelly","jell(y|ies)","cookies")#</cfoutput> REReplace...
  • Page 666: Rereplacenocase

    REReplaceNoCase Description Uses a regular expression to search a string for a string pattern and replace it with another. The search is case-insensitive. Returns • : returns a string with the first occurrence of the regular expression replaced scope = "one" by the value of substring.
  • Page 667 <cfoutput>#REReplaceNoCase("I LOVE JELLIES","jell(y|ies)","cookies")# </cfoutput> <p>REReplaceNoCase("I LOVE JELLY","jell(y|ies)","cookies"): <cfoutput>#REReplaceNoCase("I LOVE JELLY","jell(y|ies)","cookies")# </cfoutput> REReplaceNoCase...
  • Page 668: Reverse

    Reverse Description Reverses the order of items, such as the characters in a string, the digits in a number, or the elements in an array. Returns A copy of string, with the characters in reverse order. Category String functions Function syntax Reverse(string) See also Left, Mid,...
  • Page 669: Right

    Right Description Gets a specified number of characters from a string, beginning at the right. Returns • If the length of the string is greater than or equal to , the rightmost characters of count count the string • is greater than the length of the string, the whole string count •...
  • Page 670: Rjustify

    RJustify Description Right justifies characters of a string. Returns A copy of a string, right-justified in the specified field length. Category Display and formatting functions, String functions Function syntax RJustify(string, length) See also CJustify, LJustify Parameters Parameter Description string A string enclosed in quotation marks, or a variable that contains one. length A positive integer or a variable that contains one.
  • Page 671: Round

    Round Description Rounds a number to the closest integer. Returns An integer. Category Mathematical functions Function syntax Round(number) See also Ceiling, Fix, Parameters Parameter Description number Number to round Example <h3>Round Example</h3> <p>This function rounds a number to the closest integer. <ul>...
  • Page 672: Rtrim

    RTrim Description Removes spaces from the end of a string. Returns A copy of string, after removing trailing spaces. Category String functions Function syntax RTrim(string) See also LTrim, Trim Parameters Parameter Description string A string or a variable that contains one Example <h3>RTrim Example</h3>...
  • Page 673: Second

    Second Description Extracts the ordinal for the second from a date/time object. Returns An integer in the range 0–59. Category Date and time functions Function syntax Second(date) See also DatePart, Hash, Minute Parameters Parameter Description date A date/time object Usage When passing a date/time object as a string, you must enclose it in quotation marks.
  • Page 674: Setencoding

    SetEncoding Description Sets the character encoding (character set) of Form and URL scope variable values; used when the character encoding of the input to a form, or the character encoding of a URL, is not in UTF-8 encoding. Returns None Category International functions,...
  • Page 675 • www.iana.org/assignments/character-sets is a complete list of character sets names used on the Internet, maintained by the Internet Assigned Numbers Authority. • java.sun.com/j2se/1.4.1/docs/guide/intl/encoding.doc.html lists the character encoding that Java 1.4.1, and therefore the default ColdFusion configuration, can interpret. If you use a JVM that does not conform to the Sun Java 2 Platform, Standard Edition, v 1.4.1, the supported locales may differ.
  • Page 676: Setlocale

    SetLocale Description Sets the country/language locale for ColdFusion processing and the page returned to the client. The locale value determines the default format of date, time, number, and currency values, according to language and regional conventions. Returns The locale value prior to setting the new locale, as a string. Category International functions,...
  • Page 677 ColdFusion determines the locale value as follows: • By default, ColdFusion uses the JVM locale, and the default JVM locale is the operating system locale. You can set JVM locale value explicitly in ColdFusion MX in the ColdFusion Administrator Java and JVM Settings page JVM Arguments field; for example: - Duser.language=de -Duser.region=DE.
  • Page 678: Setprofilestring

    SetProfileString Description Sets the value of a profile entry in an initialization file. Returns An empty string, upon successful execution; otherwise, an error message. Category System functions Function syntax SetProfileString(iniPath, section, entry, value) See also GetProfileSections, GetProfileString, SetProfileString Parameters Parameter Description iniPath Absolute path of initialization file...
  • Page 679 <cfelse> <p>The timeout value in your initialization file is already <cfoutput>#MyTimeout#</cfoutput>.</p> </cfif> <cfset timeout = GetProfileString(IniPath, Section, "timeout")> <cfset default = GetProfileString(IniPath, Section, "default")> <h4>Boot Loader</h4> <p>Timeout is set to: <cfoutput>#timeout#</cfoutput>.</p> <p>Default directory is: <cfoutput>#default#</cfoutput>.</p> </cfif> <form action = "setprofilestring.cfm"> <hr size = "2"...
  • Page 680: Setvariable

    SetVariable Description This function is no longer required in well-formed ColdFusion pages. Sets a variable in the parameter to the value of the parameter. name value Returns The new value of the variable. Category Dynamic evaluation functions Function syntax SetVariable(name, value) See also DE, Evaluate, Parameters...
  • Page 681 <p>Your variable, #varName# <p>The value of #varName# is #varNameValue# </cfoutput> </cfif> SetVariable...
  • Page 682 Description Determines the sign of a number. Returns • 1, if is positive. number • 0, if is 0. number • -1, if is negative. number Category Mathematical functions Function syntax Sgn(number) See also Parameters Parameter Description number A number Example <h3>Sgn Example</h3>...
  • Page 683 Description Calculates the sine of an angle that is entered in radians. Returns A number; the sine of the angle. Category Mathematical functions Function syntax Sin(number) See also ASin, Cos, ACos, Tan, Atn, Parameters Parameter Description number Angle, in radians for which to calculate the sine. Usage The range of the result is -1 to 1.
  • Page 684 <br><br> <input type = "Submit" name = "">&nbsp;&nbsp; <input type = "RESET" </form> Chapter 3: ColdFusion Functions...
  • Page 685: Spanexcluding

    SpanExcluding Description Gets characters from a string from the beginning to a character that is in a specified set of characters. The search is case-sensitive. Returns A string; characters from from the beginning to a character that is in string, Category String functions Function syntax...
  • Page 686: Spanincluding

    SpanIncluding Description Gets characters from a string from the beginning to a character that is not in a specified set of characters. The search is case-sensitive. Returns A string; characters from from the beginning to a character that is not in string, Category String functions...
  • Page 687 Description Calculates the square root of a number. Returns Number; square root of number. Category Mathematical functions Function syntax Sqr(number) See also Parameters Parameter Description number A positive integer or a variable that contains one. Number whose square root to get. Usage The value in must be greater than or equal to 0.
  • Page 688: Stripcr

    StripCR Description Deletes return characters from a string. Returns A copy of string, after removing return characters. Category Display and formatting functions, Other functions, String functions Function syntax StripCR(string) See also ParagraphFormat Parameters Parameter Description string A string or a variable that contains one Usage Useful for preformatted (between tags) HTML display of data entered in...
  • Page 689: Structappend

    StructAppend Description Appends one structure to another. Returns True, upon successful completion; False, otherwise. Category Structure functions Function syntax StructAppend(struct1, struct2, overwriteFlag) See also Structure functions History ColdFusion MX: Changed behavior: this function can be used on XML objects. Parameters Parameter Description struct1...
  • Page 690 <p> The person struct <b>before</b> the Append call:<br> <cfloop collection=#personCLK# item="myItem"> <cfoutput> #myItem#<br> </cfoutput> </cfloop> <!--- Merge the Name struct into the top-level person struct ---> <cfset bSuccess = StructAppend( personCLK, addrCLK )> <!--- Display the contents of the person struct, after the Append ---> <p>...
  • Page 691: Structclear

    StructClear Description Removes all data from a structure. Returns True, on successful execution; False, otherwise. Category Structure functions Function syntax StructClear(structure) See also Structure functions History ColdFusion MX: Changed behavior: this function can be used on XML objects. Parameters Parameter Description structure Structure to clear...
  • Page 692 <!--- Call the custom tag that adds employees ---> <cf_addemployee empinfo = "#employee#"> <cfscript>StructClear(employee);</cfscript> </cfif> Chapter 3: ColdFusion Functions...
  • Page 693: Structcopy

    StructCopy Description Copies a structure. Copies top-level keys, values, and arrays in the structure by value; copies nested structures by reference. Returns A copy of a structure, with the same keys and values; if structure does not exist, throws an exception.
  • Page 694 Variable type Assigned by structure.object Reference structure.query Reference Example <!--- This code shows assignment by-value and by-reference. ---> // This script creates a structure that StructCopy copies by value. <br> <cfscript> // Create elements. s = StructNew(); s.array = ArrayNew(2); // Assign simple values to original top-level structure fields.
  • Page 695 copied.string = #copied.string#<br> // Array value <br> copied.array[1][1] = #copied.array[1][1]#<br> copied.array[1][2] = #copied.array[1][2]#<br> </cfoutput> // This script creates a structure that StructCopy copies by reference. <cfscript> // Create elements. s = StructNew(); s.nested = StructNew(); s.nested.array = ArrayNew(2); // Assign simple values to nested structure fields. s.nested.number = 99;...
  • Page 696 copied.nested.number = #copied.nested.number#<br> copied.nested.string = #copied.nested.string#<br> // Array values <br> copied.nested.array[1][1] = #copied.nested.array[1][1]#<br> copied.nested.array[1][2] = #copied.nested.array[1][2]#<br> </cfoutput> <hr> <b>Duplicated structure values should remain unchanged.</b><br> <cfoutput> // Simple values <br> duplicated.nested.number = #duplicated.nested.number#<br> duplicated.nested.string = #duplicated.nested.string#<br> // Array value <br> duplicated.nested.array[1][1] = #duplicated.nested.array[1][1]#<br> duplicated.nested.array[1][2] = #duplicated.nested.array[1][2]#<br>...
  • Page 697: Structcount

    StructCount Description Counts the keys in a structure. Returns A number; if structure does not exist, throws an exception. Category Structure functions Function syntax StructCount(structure) See also Structure functions History ColdFusion MX: Changed behavior: this function can be used on XML objects. Parameters Parameter Description...
  • Page 698: Structdelete

    StructDelete Description Removes an element from a structure. Returns Boolean value. The value depends on the parameter value. indicatenotexisting Category Structure functions Function syntax StructDelete(structure, key [, indicatenotexisting ]) See also Structure functions History ColdFusion MX: Changed behavior: this function can be used on XML objects. Parameters Parameter Description...
  • Page 699 <cfset rc = StructDelete(employee, "#form.field#", "True")> <cfoutput> Did I delete the field "#form.field#"? The code indicates: #rc#<br> The structure now looks like this:<br> <cfdump var="#employee#"> <br> </cfoutput> </cfif> <br><br> <form method="post" action = "#CGI.Script_Name#"> <p>Select the field to be deleted:&nbsp; <select name = "field">...
  • Page 700: Structfind

    StructFind Description Determines the value associated with a key in a structure. Returns The value associated with a key in a structure; if structure does not exist, throws an exception. Category Structure functions Function syntax StructFind(structure, key) See also Structure functions Parameters Parameter Description...
  • Page 701: Structfindkey

    StructFindKey Description Searches recursively through a substructure of nested arrays, structures, and other elements, for structures whose values match the search key in the value parameter. Returns An array that contains structures with values that match value. Category Structure functions Function syntax StructFindKey(top, value, scope) See also...
  • Page 702: Structfindvalue

    StructFindValue Description Searches recursively through a substructure of nested arrays, structures, and other elements for structures with values that match the search key in the parameter. value Returns An array that contains structures with values that match the search key value. If none are found, returns an array of size 0.
  • Page 703: Structget

    StructGet Description Gets a structure(s) from a specified path. Returns An alias to the variable in the pathDesired parameter. If necessary, creates structures or StructGet arrays to make pathDesired a valid variable "path." Category Structure functions Function syntax StructGet(pathDesired) See also Structure functions History ColdFusion MX:...
  • Page 704 </cfoutput> <cfset test = StructGet( "request.myscope[1].test" )> <cfset test.foo = 2> <cfoutput> #request.myscope[1].test.foo#<br> </cfoutput> <cfset test = StructGet( "request.myscope[1].test[2]" )> <cfset test.foo = 3> <cfoutput> #request.myscope[1].test[2].foo#<br> </cfoutput> Chapter 3: ColdFusion Functions...
  • Page 705: Structinsert

    StructInsert Description Inserts a key-value pair into a structure. Returns True, upon successful completion. If does not exist, or if exists and structure , ColdFusion throws an exception. allowoverwrite = "False" Category Structure functions Function syntax StructInsert(structure, key, value [, allowoverwrite ]) See also Structure functions History...
  • Page 706 <p>First name is #StructFind(employee, "firstname")#</p> <p>Last name is #StructFind(employee, "lastname")#</p> <p>EMail is #StructFind(employee, "email")#</p> <p>Phone is #StructFind(employee, "phone")#</p> <p>Department is #StructFind(employee, "department")#</p> </cfoutput> <!--- Call the custom tag that adds employees ---> <CF_ADDEMPLOYEE EMPINFO = "#employee#"> </cfif> <Hr> <form action = "structinsert.cfm"> <p>First Name:&nbsp;...
  • Page 707: Structisempty

    StructIsEmpty Description Determines whether a structure contains data. Returns True, if structure is empty; if structure does not exist, ColdFusion throws an exception. Category Decision functions, Structure functions Function syntax StructIsEmpty(structure) See also Structure functions History ColdFusion MX: Changed behavior: this function can be used on XML objects. Parameters Parameter Description...
  • Page 708: Structkeyarray

    StructKeyArray Description Finds the keys in a ColdFusion structure. Returns An array of keys; if structure does not exist, ColdFusion throws an exception. Category Structure functions Function syntax StructKeyArray(structure) See also Structure functions Parameters Parameter Description structure Structure from which to extract a list of keys Usage A structure’s keys are unordered.
  • Page 709 value = "" hspace = "30" maxlength = "30"></td> </tr> <tr> <td>Last Name:</td> <td><input name = "lastname" type = "text" value = "" hspace = "30" maxlength = "30"></td> </tr> <tr> <td>EMail</td> <td><input name = "email" type = "text" value = "" hspace = "30" maxlength = "30"></td> </tr>...
  • Page 710: Structkeyexists

    StructKeyExists Description Determines whether a specific key is present in a structure. Returns True, if key is in structure; if structure does not exist, ColdFusion throws an exception. Category Decision functions, Structure functions Function syntax StructKeyExists(structure, "key") See also Structure functions Parameters Parameter Description...
  • Page 711: Structkeylist

    StructKeyList Description Extracts keys from a ColdFusion structure. Returns A list of keys; if structure does not exist, ColdFusion throws an exception. Category Structure functions Function syntax StructKeyList(structure [, delimiter]) See also Structure functions Parameters Parameter Description structure Structure from which to extract a list of keys. delimiter Optional.
  • Page 712 <p>After you enter employee information into structure, example uses <b>StructKeyList</b> function to list keys in structure.</p> <p>This code does not show how to insert information into a database. See cfquery for more information about database insertion. <hr size = "2" color = "#0000A0"> <form action = "structkeylist.cfm">...
  • Page 713: Structnew

    StructNew Description Creates a structure. Returns A structure. Category Structure functions Function syntax StructNew() See also Structure functions Parameters None Example <!--- Shows StructNew. Calls CF_ADDEMPLOYEE, which uses the | addemployee.cfm file to add employee record to database. ---> <h1>Add New Employees</h1> <cfparam name = "FORM.firstname"...
  • Page 714: Structsort

    StructSort Description Returns a sorted array of the top level keys in a structure. Sorts using alphabetic or numeric sorting, and can sort based on the values of any structure element. Returns An array of top-level key names (strings), sorted by the value of the specified subelement. Category Structure functions Function syntax...
  • Page 715 departments["department#i#"] = StructNew() ; departments["department#i#"].boss = employee ; </cfscript> <cfoutput> <p>list of employees based on the salary (text search): <br> 1) #ArrayToList( StructSort( salaries ) )#<br> 2) #ArrayToList( StructSort( salaries, "text", "ASC" ) )#<br> 3) #ArrayToList( StructSort( salaries, "textnocase", "ASC" ) )#<br> 4) #ArrayToList( StructSort( salaries, "text", "DESC"...
  • Page 716: Structupdate

    StructUpdate Description Updates a key with a value. Returns True, on successful execution; if the structure does not exist, ColdFusion throws an error. Category Structure functions Function syntax StructUpdate(structure, key, value) See also Structure functions History ColdFusion MX: Changed behavior: this function can be used on XML objects. Parameters Parameter Description...
  • Page 717 Description Calculates the tangent of an angle that is entered in radians. Returns A number; the tangent of an angle. Category Mathematical functions Function syntax Tan(number) See also Atn, Cos, ACos, Sin, ASin, Parameters Parameter Description number Angle, in radians, for which to calculate the tangent. Usage To convert degrees to radians, multiply degrees by /180.
  • Page 718 <br><input type = "Text" name = "tanNum" size = "15"> <br><br> <input type = "Submit" name = "">&nbsp;&nbsp; <input type = "RESET" </form> Chapter 3: ColdFusion Functions...
  • Page 719: Timeformat

    TimeFormat Description Formats a time value using US English time formatting conventions. Returns A custom-formatted time value. If no mask is specified, returns a time value using the hh:mm tt format. For international time formatting, see LSTimeFormat Category Date and time functions, Display and formatting functions Function syntax...
  • Page 720 To ensure that dates and times display with appropriate formatting, and that users of your ColdFusion application are not confused by dates and times displayed, Macromedia recommends that you use the functions to DateFormat TimeFormat format date and time values from queries.
  • Page 721: Tobase64

    ToBase64 Description Calculates the Base64 representation of a string or binary object. The Base64 format uses printable characters, allowing binary data to be sent in forms and e-mail, and stored in a database or file. The Base64 representation of a string or binary object. Category Conversion functions,...
  • Page 722 Base64 lets you store binary objects in a database. Note: To reverse Base64 encoding of a string, you can convert it to a binary object, then convert the binary object to a string, using the toString function. Example <h3>ToBase64 Example</h3> <!--- Initialize data.
  • Page 723: Tobinary

    ToBinary Description Calculates the binary representation of Base64-encoded data. Returns The binary representation of Base64-encoded data. Category Conversion functions, Other functions, String functions Function syntax ToBinary(string_in_Base64 or binary_value) See also • for information about loading and reading binary data cffile •...
  • Page 724 <cfelse> <h3>Conversion error.</h3> </cfif> Chapter 3: ColdFusion Functions...
  • Page 725 ToString Description Converts a value to a string. Returns A string. Category Conversion functions, Other functions, String functions Function syntax ToString(any_value[, encoding]) See also ToBase64, ToBinary History ColdFusion MX: • Changed Unicode support: ColdFusion supports the Java UCS-2 representation of Unicode character values 0–65535.
  • Page 726 Example <h3>ToString Example</h3> <!---- Initialize data. ------> <cfset charData = ""> <!----- Create string of ASCII characters (32-255) and concatenate them. ----> <cfloop index = "data" from = "32" to = "255"> <cfset ch = chr(data)> <cfset charData = charData & ch> </cfloop>...
  • Page 727: Trim

    Trim Description Removes leading and trailing spaces from a string. Returns A copy of string, after removing leading and trailing spaces. Category String functions Function syntax Trim(string) See also LTrim, RTrim Parameters Parameter Description string A string or a variable that contains one Example <h3>Trim Example</h3>...
  • Page 728: Ucase

    UCase Description Converts the alphabetic characters in a string to uppercase. Returns A copy of a string, converted to uppercase. Category String functions Function syntax UCase(string) See also LCase Parameters Parameter Description string A string or a variable that contains one Example <h3>UCase Example</h3>...
  • Page 729: Urldecode

    URLDecode Description Decodes a URL-encoded string. Returns A copy of a string, decoded. Category Conversion functions, Other functions, String functions Function syntax URLDecode(urlEncodedString[, charset]) See also URLEncodedFormat History ColdFusion MX 6.1: Changed the default charset: the default charset is the character encoding of the URL scope.
  • Page 730 Query strings in HTTP are always URL-encoded. Example This example creates, encodes, and decodes a string that contains ASCII character codes. <cfscript> // Build string s = ""; for (c = 1; c lte 256; c = c + 1) s = s &...
  • Page 731: Urlencodedformat

    URLEncodedFormat Description Generates a URL-encoded string. For example, it replaces spaces with , and non- alphanumeric characters with equivalent hexadecimal escape sequences. Passes arbitrary strings within a URL (ColdFusion automatically decodes URL parameters that are passed to a page). Returns A copy of a string, URL-encoded.
  • Page 732 <cfif IsDefined("url.myExample")> <p>The url variable url.myExample was passed from the previous link ... its value is: <br><b>"<cfoutput>#url.myExample#</cfoutput>"</b> </cfif> <p>This function returns a URL encoded string. <cfset s = "My url-encoded string has special characters & other stuff"> <p> <A HREF = "urlencodedformat.cfm?myExample=<cfoutput>#URLEncodedFormat(s)# </cfoutput>">Click me</A>...
  • Page 733: Urlsessionformat

    URLSessionFormat Description Depending on whether a client computer accepts cookies, this function does the following: • If the client does not accept cookies: automatically appends all required client identification information to a URL • If the client accepts cookies: does not append information This function automatically determines which identifiers are required, and sends only the required information.
  • Page 734 Description Converts numeric characters that occur at the beginning of a string to a number. Returns A number. If conversion fails, returns zero. Category Conversion functions, String functions Function syntax Val(string) See also IsNumeric Parameters Parameter Description string A string or a variable that contains one Usage This function works as follows: •...
  • Page 735: Valuelist

    ValueList Description Inserts a delimiter between each value in an executed query. ColdFusion does not evaluate the arguments. Returns A delimited list of the values of each record returned from an executed query. Category Other functions, Query functions Function syntax ValueList(query.column [, delimiter ]) See also QuotedValueList...
  • Page 736: Week

    Week Description From a date/time object, determines the week number within the year. Returns An integer in the range 1–53; the ordinal of the week, within the year. Category Date and time functions Function syntax Week(date) See also DatePart Parameters Parameter Description date...
  • Page 737: Wrap

    Wrap Description Wraps text so that each line has a specified maximum number of characters. Returns String containing the wrapped text. Category String functions Function syntax Wrap(string, limit[, strip]) See also cfmail History ColdFusion MX 6.1: Added this function Parameters Parameter Description string...
  • Page 738: Writeoutput

    WriteOutput Description Appends text to the page-output stream. This function writes to the page-output stream regardless of conditions established by the tag. cfsetting Category Other functions Function syntax WriteOutput(string Parameters Parameter Description string A string or a variable that contains one Usage Within the tags, this function does not output to the current page;...
  • Page 739: Xmlchildpos

    XmlChildPos Description Gets the position of a child element within an XML document object. Returns The position, in an XmlChildren array, of the Nth child that has the specified name. Category Extensibility functions, XML functions Function syntax XmlChildPos(elem, childName, N) See also cfxml, IsXmlDoc, XmlChildPos, XmlFormat, XmlNew, XmlParse, XmlSearch, XmlTransform...
  • Page 740: Xmlelemnew

    XmlElemNew Description Creates an XML document object element. Returns An XML document object element. Category Extensibility functions, XML functions Function syntax XmlElemNew(xmlObj, childName) See also cfxml, IsXmlDoc, XmlChildPos, XmlFormat, XmlNew, XmlParse, XmlSearch, XmlTransform History ColdFusion MX: Added this function. Parameters Parameter Description xmlObj...
  • Page 741: Xmlformat

    XmlFormat Description Escapes special XML characters in a string, so that the string is safe to use with XML. Returns A copy of string that is safe to use with XML. Category Extensibility functions, String functions, XML functions Function syntax XmlFormat(string) See also cfxml, IsXmlDoc, XmlChildPos, XmlChildPos, XmlNew, XmlParse, XmlSearch,...
  • Page 742: Xmlnew

    XmlNew Description Creates an XML document object. Returns An empty XML document object. Category Extensibility functions, XML functions Function syntax XmlNew([caseSensitive]) See also cfxml, IsXmlDoc, XmlChildPos, XmlChildPos, XmlFormat, XmlParse, XmlSearch, XmlTransform History ColdFusion MX: Added this function. Parameters Parameter Description caseSensitive Determines how ColdFusion processes the case of XML document object component identifiers...
  • Page 743 </cfscript> <cfdump var=#MyDoc#> XmlNew...
  • Page 744: Xmlparse

    XmlParse Description Converts an XML document that is represented as a string variable into an XML document object. Returns An XML document object. Category Conversion functions, Extensibility functions, XML functions Function syntax XmlParse(xmlString [, caseSensitive ] ) See also cfxml, IsXmlDoc, XmlChildPos, XmlChildPos, XmlFormat, XmlNew, XmlSearch, XmlTransform History ColdFusion MX: Added this function.
  • Page 745: Xmlsearch

    XmlSearch Description Uses an XPath language expression to search an XML document that is represented as a string variable. Returns An array of XML object nodes that match the search criteria. Category Extensibility functions, XML functions Function syntax XmlSearch(xmlDoc, xPathString) See also cfxml, IsXmlDoc, XmlChildPos, XmlChildPos, XmlFormat, XmlNew, XmlParse, XmlTransform...
  • Page 746: Xmltransform

    XmlTransform Description Applies an Extensible Stylesheet Language Transformation (XSLT) to an XML document object that is represented as a string variable. An XSLT converts an XML document to another format or representation by applying an Extensible Stylesheet Language (XSL) stylesheet to it. For more information, see Chapter 31, “Using XML and WDDX,”...
  • Page 747: Year

    Year Description From a date/time object, gets the year value. Returns The year value of date. Category Date and time functions Function syntax Year(date) See also DatePart, IsLeapYear Parameters Parameter Description date A date/time object in the range 100 AD–9999 AD. Usage When passing a date as a string, enclose it in quotation marks.
  • Page 748: Yesnoformat

    YesNoFormat Description Evaluates a number or Boolean value. Returns Yes, for a non-zero value; No, otherwise. Category Decision functions, Display and formatting functions Function syntax YesNoFormat(value) See also IsBinary, IsNumeric Parameters Parameter Description value A number or Boolean value Example <h3>YesNoFormat Example</h3>...
  • Page 749 CHAPTER 4 ColdFusion C++ CFX Reference This chapter describes the CFXAPI classes and members. Contents C++ class overview ............750 Deprecated class members .
  • Page 750: C++ Class Overview

    C++ class overview A list of CFXAPI classes and members follows. Class Member CCFXException class CCFXException::GetError CCFXException::GetDiagnostics CCFXQuery class CCFXQuery::AddRow CCFXQuery::GetColumns CCFXQuery::GetData CCFXQuery::GetName CCFXQuery::GetRowCount CCFXQuery::SetData CCFXRequest class CCFXRequest::AddQuery CCFXRequest::AttributeExists CCFXRequest::CreateStringSet CCFXRequest::Debug CCFXRequest::GetAttribute CCFXRequest::GetAttributeList CCFXRequest::GetCustomData CCFXRequest::GetQuery CCFXRequest::ReThrowException CCFXRequest::SetCustomData CCFXRequest::SetVariable CCFXRequest::ThrowException CCFXRequest::Write CCFXRequest::WriteDebug CCFXStringSet class CCFXStringSet::AddString...
  • Page 751: Ccfxexception Class

    CCFXException class An abstract class that represents an exception thrown during processing of a ColdFusion Extension (CFX) procedure. Exceptions of this type can be thrown by , and CCFXRequest class CCFXQuery class . Your ColdFusion Extension code must be written to handle exceptions CCFXStringSet class of this type.
  • Page 752 // Write output back to the user here... pRequest->Write( "Hello from CFX_FOO2!" ) ; pRequest->ThrowException("User Error", "You goof'd..."); // Output optional debug info if ( pRequest->Debug() ) pRequest->WriteDebug( "Debug info..." ) ; // Catch ColdFusion exceptions & re-raise them catch( CCFXException* e ) // This is how you would pull the error information LPCTSTR strError = e->GetError();...
  • Page 753: Ccfxquery Class

    CCFXQuery class An abstract class that represents a query used or created by a ColdFusion Extension (CFX). Queries contain one or more columns of data that extend over a varying number of rows. Class members adds a row to a query. virtual int AddRow() CCFXQuery::AddRow virtual CCFXStringSet* GetColumns...
  • Page 754: Ccfxquery::getcolumns

    CCFXQuery::GetColumns Syntax CCFXStringSet* CCFXQuery::GetColumns(void) Description Retrieves a list of the column names contained in a query. Returns Returns an object of that contains a list of the columns in the query. CCFXStringSet class ColdFusion automatically frees the memory that is allocated for the returned string set, after the request is completed.
  • Page 755: Ccfxquery::getname

    Example The following example iterates over the elements of a query and writes the data in the query back to the user in a simple, space-delimited format: int iRow, iCol ; int nNumCols = pQuery->GetColumns()->GetCount() ; int nNumRows = pQuery->GetRowCount() ; for ( iRow=1;...
  • Page 756: Ccfxquery::setdata

    CCFXQuery::SetData Syntax void CCFXQuery::SetData(int iRow, int iColumn, LPCSTR lpszData) Description Sets a data element within a row and column of a query. Row and column indexes begin with 1. Before calling for a given row, call and use the return value as the SetData CCFXQuery::AddRow row index for your call to...
  • Page 757: Ccfxrequest Class

    CCFXRequest class Abstract class that represents a request made to a ColdFusion Extension (CFX). An instance of this class is passed to the main function of your extension DLL. The class provides interfaces that can be used by the custom extension for the following actions: •...
  • Page 758: Ccfxrequest::addquery

    sets virtual void SetCustomData( LPVOID lpvData ) CCFXRequest::SetCustomData custom (tag specific) data to carry with a request. gets virtual LPVOID GetCustomData() CCFXRequest::GetCustomData custom (tag specific) data for a request. CCFXRequest::AddQuery Syntax CCFXQuery* CCFXRequest::AddQuery(LPCSTR lpszName, CCFXStringSet* pColumns) Description Adds a query to the calling template. The query can be accessed by CFML tags (for example, ) within the template.
  • Page 759: Ccfxrequest::attributeexists

    CCFXRequest::AttributeExists Syntax BOOL CCFXRequest::AttributeExists(LPCSTR lpszName) Description Checks whether the attribute was passed to the tag. Returns True if the attribute is available; False, otherwise. Parameters Parameter Description lpszName Name of the attribute to check (case insensitive) Example The following example checks whether the user passed an attribute named DESTINATION to the tag, and throws an exception if the attribute was not passed: if ( pRequest->AttributeExists("DESTINATION")==FALSE ) pRequest->ThrowException(...
  • Page 760: Ccfxrequest::debug

    CCFXRequest::Debug Syntax BOOL CCFXRequest::Debug(void) Description Checks whether the tag contains the attribute. Use this function to determine whether to DEBUG write debug information for a request. For more information, see CCFXRequest::WriteDebug Returns Returns True if the tag contains the DEBUG attribute; False, otherwise. Example The following example checks whether the attribute is present, and if it is, it writes a brief...
  • Page 761: Ccfxrequest::getattributelist

    CCFXRequest::GetAttributeList Syntax CCFXStringSet* CCFXRequest::GetAttributeList(void) Description Gets an array of attribute names passed to the tag. To get the value of one attribute, use CCFXRequest::GetAttribute Returns Returns an object of class that contains a list of attributes passed to the CCFXStringSet class tag.
  • Page 762: Ccfxrequest::getquery

    CCFXRequest::GetQuery Syntax CCFXQuery* CCFXRequest::GetQuery(void) Description Retrieves a query that was passed to a tag. To pass a query to a custom tag, you use the QUERY attribute. This attribute should be set to the name of a query (created using the CFQUERY tag or another custom tag).
  • Page 763: Ccfxrequest::setcustomdata

    Example The following code demonstrates how to handle exceptions in ColdFusion Extension DLL procedures: ...Code that could throw an exception... catch( CCFXException* e ) ...Do appropriate resource cleanup here... // Re-throw the exception pRequest->ReThrowException( e ) ; catch( ... ) // Something nasty happened pRequest->ThrowException( "Unexpected error occurred in CFX tag", ""...
  • Page 764: Ccfxrequest::setvariable

    CCFXRequest::SetVariable Syntax void CCFXRequest::SetVariable(LPCSTR lpszName, LPCSTR lpszValue) Description Sets a variable in the calling template. If the variable name already exists in the template, its value is replaced. If it does not exist, a variable is created. The values of variables created using can be accessed in the same manner as other template variables (for example, SetVariable #MessageSent#...
  • Page 765: Ccfxrequest::write

    Example The following example throws an exception indicating that an unexpected error occurred while processing a request: char buffError[512] ; wsprintf( buffError, "Unexpected Windows NT error number %ld " "occurred while processing request.", GetLastError() ) ; pRequest->ThrowException( "Error occurred", buffError ) ; CCFXRequest::Write Syntax void CCFXRequest::Write(LPCSTR lpszOutput)
  • Page 766: Ccfxstringset Class

    CCFXStringSet class Abstract class that represents a set of ordered strings. Strings can be added to a set and can be retrieved by a numeric index (index values for strings are 1-based). To create a string set, use CCFXRequest::CreateStringSet Class members virtual int AddString( LPCSTR lpszString ) adds a string to CCFXStringSet::AddString...
  • Page 767: Ccfxstringset::getindexforstring

    Returns Returns the number of strings contained in the string set. Example The following example demonstrates using with GetCount CCFXStringSet::GetString iterate over a string set and write the contents of the list back to the user: int nNumItems = pStringSet->GetCount() ; for ( int i=1;...
  • Page 768 Returns Returns the string located at the passed index. Parameters Parameter Description iIndex Index of string to retrieve Example The following example demonstrates with to iterate over GetString CCFXStringSet::GetCount a string set and write the contents of a list back to the user: int nNumItems = pStringSet->GetCount() ;...
  • Page 769 CHAPTER 5 ColdFusion Java CFX Reference This chapter describes the Java interfaces available for building ColdFusion custom CFXs in Java. Contents Overview class libraries ........... . . 770 CustomTag interface .
  • Page 770: Overview Class Libraries

    Overview class libraries The following Java interfaces are available for building ColdFusion custom CFXs in Java. Interface Methods CustomTag interface processRequest Query interface addRow getColumnIndex getColumns getData getName getRowCount setData Request interface attributeExists debug getAttribute getAttributeList getIntAttribute getQuery getSetting Response interface addQuery setVariable write...
  • Page 771 Category CustomTag interface Syntax public void processRequest(Request request, Response response) Throws If an unexpected error occurs while processing the request. Exception Parameters Parameter Description request Parameters (attributes, query, and so on.) for this request response Interface for generating response to request (output, variables, queries, and so on) CustomTag interface...
  • Page 772: Query Interface

    Query interface public abstract interface Query Interface to a query used or created by a custom tag. A query contains tabular data organized by named columns and rows. Methods Returns Method Description addRow() Adds a row to the query Gets the index of a column given its name getColumnIndex(String name) String[] Gets a list of the column names in a query...
  • Page 773: Getcolumnindex

    query.setData( iRow, iState, "MN" ) ; query.setData( iRow, iZip, "55105" ) ; getColumnIndex Description Returns the index of the column, or 0 if no such column exists. Category Query interface Syntax public int getColumnIndex(String name) See also getColumns getData Parameters Parameter Description name...
  • Page 774: Getdata

    // Print the list of columns to the user response.write( "Columns in query: " ) ; for( int i=0; i<nNumColumns; i++ ) response.write( columns[i] + " " ) ; getData Description Retrieves a data element from a row and column of a query. Row and column indexes begin with 1.
  • Page 775: Getname

    getName Description Returns the name of a query. Category Query interface Syntax public String getName() Example The following example retrieves the name of a query and writes it back to the user: Query query = request.getQuery() ; response.write( "The query name is: " + query.getName() ) ; getRowCount Description Retrieves the number of rows in a query.
  • Page 776 See also getData addRow Parameters Parameter Description iRow Row of data element to set (1-based) iCol Column of data element to set (1-based) data New value for data element Example The following example demonstrates the addition of two rows to a query that has three columns, City, State, and Zip: // Define column indexes int iCity = 1, iState = 2, iZip = 3 ;...
  • Page 777: Request Interface

    Request interface public abstract interface Request Interface to a request made to a CustomTag. The interface includes methods for retrieving attributes passed to the tag (including queries) and reading global tag settings. Methods Returns Syntax Description boolean attributeExists(String name) Checks whether the attribute was passed to this tag.
  • Page 778: Debug

    "Missing DESTINATION parameter", "You must pass a DESTINATION parameter in " "order for this tag to work correctly." ) ; debug Description Checks whether the tag contains the debug attribute. Use this method to determine whether to write debug information for this request. For more information, see writeDebug Returns True if the tag contains the debug attribute;...
  • Page 779: Getattributelist

    Example The following example retrieves an attribute named DESTINATION and writes its value back to the user: String strDestination = request.getAttribute("DESTINATION") ; response.write( "The destination is: " + strDestination ) ; getAttributeList Description Retrieves a list of attributes passed to the tag. To retrieve the value of one attribute, use the member function.
  • Page 780: Getquery

    Throws If the attribute is not a valid number. NumberFormatException See also attributeExists getAttributeList getIntAttribute Parameters Parameter Description name The attribute to retrieve (case-insensitive) Example The following example retrieves an attribute named PORT and writes its value back to the user: int nPort = request.getIntAttribute("PORT") ;...
  • Page 781 Returns the value of the custom tag setting. If no setting of that name exists, an empty string is returned. Category Request interface Syntax public String getSetting(String name) Parameters Parameter Description name The name of the setting to retrieve (case-insensitive) Usage All custom tags implemented in Java share a registry key for storing settings.
  • Page 782: Response Interface

    Response interface public abstract interface Response Interface to response generated from a custom tag. This interface includes methods for writing output, generating queries, and setting variables in the calling page. Methods Returns Syntax Description Query addQuery(String name, String[] columns) Adds a query to the calling template. void Sets a variable in the calling template.
  • Page 783: Setvariable

    // Add data to the query int iRow = query.addRow() ; query.setData( iRow, iFirstName, "John" ) ; query.setData( iRow, iLastName, "Smith" ) ; iRow = query.addRow() ; query.setData( iRow, iFirstName, "Jane" ) ; query.setData( iRow, iLastName, "Doe" ) ; setVariable Description Sets a variable in the calling template.
  • Page 784: Write

    write Description Outputs text back to the user. Category Response interface Syntax public void write(String output) Parameters Parameter Description output Text to output Example The following example outputs the value of the DESTINATION attribute: response.write( "DESTINATION = " + request.getAttribute("DESTINATION") ) ; writeDebug Description Writes text output into the debug stream.
  • Page 785: Debugging Classes Reference

    Debugging classes reference The constructors and methods supported by the , and DebugRequest DebugResponse classes are as follows. These classes also support the other methods of the DebugQuery Request , and interfaces, respectively. Response Query DebugRequest // initialize a debug request with attributes public DebugRequest( Hashtable attributes ) ;...
  • Page 786 Chapter 5: ColdFusion Java CFX Reference...
  • Page 787 CHAPTER 6 WDDX JavaScript Objects This chapter provides information about JavaScript objects and functions used to WDDX in a ColdFusion application. Contents JavaScript object overview ........... 788 WddxSerializer object.
  • Page 788: Javascript Object Overview

    JavaScript object overview These are the JavaScript objects and functions. Class Members WddxSerializer object serialize serializeVariable serializeValue write WddxRecordset object addColumn addRows getField getRowCount setField wddxSerialize WDDX JavaScript objects are defined in the wddx.js file; this file is installed in the webroot/ cfide/scripts directory.
  • Page 789: Wddxserializer Object

    WddxSerializer object The WddxSerializer object includes functions that serialize any JavaScript data structure. Functions The only function that developers typically call is serialize Function syntax Description Creates a WDDX packet for a passed WddxRecordset object.serialize(rootobj) instance. Serializes a property of a structure. If an object is not a object.serializeVariable(name, obj) string, number, array, Boolean, or a date, WddxSerializer treats it as a structure.
  • Page 790: Serializevariable

    alert("Couldn't serialize data"); serializeVariable Description Serializes a property of a structure. If an object is not a string, number, array, Boolean, or date, WddxSerializer treats it as a structure. Syntax object.serializeVariable( name, obj ) Parameters Parameter Description object Instance name of a WddxSerializer object name Property to serialize Instance name of the value to serialize...
  • Page 791: Write

    • Recordset • Any JavaScript object This function serializes null values as empty strings. Syntax object.serializeValue( obj ) Parameters Parameter Description object Instance name of the WddxSerializer object Instance name of the WddxRecordset object to serialize Return value Returns a Boolean True if obj was serialized successfully; or False if an error occurs. Usage This is an internal function;...
  • Page 792 Usage This is an internal function; you do not typically call it. Example This example is from the WddxSerializer function: serializeValue else if (typeof(obj) == "number") // Number value this.write("<number>" + obj + "</number>"); else if (typeof(obj) == "boolean") // Boolean value this.write("<boolean value='"...
  • Page 793: Wddxrecordset Object

    WddxRecordset object Includes functions that you call as needed when constructing a WDDX record set. Functions Function syntax Description Adds a column to all rows in a WddxRecordset instance. object.addColumn(name) Adds rows to all columns in a WddxRecordset instance. object.addRows(n) object.dump(escapeStrings) Displays WddxRecordset object data.
  • Page 794: Addrows

    Parameters Parameter Description object Instance name of the WddxRecordset object name Name of the column to add Return value None. Usage Adds a column to every row of the WDDX record set. Initially the new column’s values are set to NULL.
  • Page 795: Getfield

    // create a new record set rs = new WddxRecordset(); // add a new column rs.addColumn("NewColumn"); // extend the record set by 3 rows rs.addRows(3); // set an element in the first row // newValue is a previously defined variable rs.setField(0, "NewColumn", newValue);...
  • Page 796: Getrowcount

    getRowCount Description Indicates the number of rows in a WddxRecordset instance. Syntax object.getRowCount( ) Parameters Parameter Description object Instance name of a WddxRecordset object Return value Integer. Returns the number of rows in the WddxRecordset instance. Usage Call this function before a looping construct to determine the number of rows in a record set. Example This example calls the function:...
  • Page 797: Wddxserialize

    Example This example calls the function: setField // create a new recordset rs = new WddxRecordset(); // add a new column rs.addColumn("NewColumn"); // extend the record set by 3 rows rs.addRows(3); // set an element in the first row // newValue is a previously defined variable rs.setField(0, "NewColumn", newValue);...
  • Page 798 Chapter 6: WDDX JavaScript Objects...
  • Page 799 CHAPTER 7 ColdFusion ActionScript Functions This chapter explains the syntax and usage of the two server-side ActionScript functions, CF.query CF.http Contents CF.query ..............800 CF.http .
  • Page 800: Cf.query

    CF.query Description Performs queries against ColdFusion data sources. Return value Returns a RecordSet object.W Syntax CF.query datasource:"data source name", sql:"SQL stmts", username:"username", password:"password", maxrows:number, timeout:milliseconds Arguments Arguments Req/Opt Description datasource Required Name of the data source from which the query retrieves data. Required SQL statement.
  • Page 801: Cf.http

    • RecordSet.getColumnnames • RecordSet.getLength • RecordSet.getItemAt • RecordSet.getItemID • RecordSet.sortItemsBy • RecordSet.getNumberAvailable • RecordSet.filter • RecordSet.sort For more information on using server-side ActionScript, see Chapter 30, “Using Server-Side ActionScript,” of Developing ColdFusion MX Applications. For more detailed information about the RecordSet ActionScript class, see Using Flash Remoting. Example // Define a function to do a basic query // Note use of positional arguments...
  • Page 802 Syntax CF.http method:"get or post", url:"URL", username:"username", password:"password", resolveurl:"yes or no", params:arrayvar, path:"path", file:"filename" Arguments Arguments Req/Opt Description method Required One of two arguments: • get: downloads a text or binary file or creates a query from the contents of a text file. •...
  • Page 803 Arguments Req/Opt Description path Optional The path to the directory in which to store files. When using the path argument, the argument is required. file file Optional Name of the file that is accessed. For GET operations, defaults to the name specified in the argument.
  • Page 804 Property Description Header Raw response header. For example, macromedia.com returns the following header: HTTP/1.1 200 OK Date: Mon, 04 Mar 2002 17:27:44 GMT Server: Apache/1.3.22 (Unix) mod_perl/1.26 Set-Cookie: MM_cookie=207.22.48.162.4731015262864476; path=/; expires=Wed, 03-Mar-04 17:27:44 GMT; domain=.macromedia.com Connection: close Content-Type: text/html Filecontent File contents, for text and MIME files.
  • Page 805 result = CF.http({method:"post", url:url, username:"karl", password:"salsa", resolveurl:true, params:params, path:path, file:file}); if (result) return result.get("Statuscode"); return null; // Example of a basic HTTP GET operation // Shows that HTTP GET is the default function basicGet() url = "http://localhost:8100/"; // Invoke with just the url. This is an HTTP GET. result = CF.http(url);...
  • Page 806 Chapter 7: ColdFusion ActionScript Functions...

This manual is also suitable for:

Coldfusion mx

Table of Contents