MACROMEDIA COLDFUSION 5 - CFML Reference

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

Advertisement

Quick Links

CFML Reference
ColdFusion 5
Macromedia® Incorporated

Advertisement

Table of Contents
loading

Summary of Contents for MACROMEDIA COLDFUSION 5 - CFML

  • Page 1 CFML Reference ColdFusion 5 Macromedia® Incorporated...
  • Page 2 The content of this manual is furnished for informational use only, is subject to change without notice, and should not be construed as a commitment by Macromedia Incorporated. Macromedia Incorporated assumes no responsibility or liability for any errors or inaccuracies that may appear in this book.
  • Page 3: Table Of Contents

    Contacting Macromedia ........
  • Page 4 Contents Function syntax ........... 19 Optional function arguments .
  • Page 5 Contents How data is returned from cfgrid ........124 Using the href attribute .
  • Page 6 Contents cftextinput ............278 cfthrow .
  • Page 7 Contents ..............342 AuthenticatedContext .
  • Page 8 viii Contents ..............413 ExpandPath .
  • Page 9 Contents IsNumericDate ........... . . 471 IsProtected .
  • Page 10 Contents ..............542 Minute .
  • Page 11 Contents StructFind ............609 StructFindKey .
  • Page 12 Contents CCFXRequest::AddQuery ......... 656 CCFXRequest::AttributeExists .
  • Page 13 Contents xiii Methods ............680 addQuery .
  • Page 14 Contents...
  • Page 15: About This Book

    ColdFusion expressions, using JavaScript objects for WDDX in ColdFusion. You can also find detailed references for Java and C++ CFX interfaces. Contents Intended Audience....................xvi Developer Resources....................xvi About ColdFusion Documentation ............... xvii Getting Answers ..................... xviii Contacting Macromedia..................xviii...
  • Page 16: Intended Audience

    CFML code. Developer Resources Macromedia Corporation is committed to setting the standard for customer support in developer education, technical support, and professional services. The Web site is designed to give you quick access to the entire range of online resources, as the following table describes.
  • Page 17: About Coldfusion Documentation

    About ColdFusion Documentation xvii About ColdFusion Documentation ColdFusion documentation is designed to provide support for the complete spectrum of participants. The print and online versions are organized to allow you to quickly locate the information that you need. The ColdFusion online documentation is provided in HTML and Adobe Acrobat formats.
  • Page 18: Getting Answers

    12 months, allowing you to learn how others have solved a problem that you might be facing. The Forums is a great resource for learning ColdFusion, but it is also a great place to see the ColdFusion developer community in action. Contacting Macromedia Corporate Macromedia, Inc.
  • Page 19: Chapter 1 Coldfusion Expressions: Operands, Operators And Other Constructs

    Chapter 1 ColdFusion Expressions: Operands, Operators and Other Constructs This chapter describes ColdFusion expressions — language constructs that let you create sophisticated applications. Contents Elements of ColdFusion Expressions ................ 2 Variables........................6 CGI Environment Variables..................13 Operators ........................16 Functions as Operators..................... 19 Pound Signs .......................
  • Page 20: Elements Of Coldfusion Expressions

    Chapter 1 ColdFusion Expressions: Operands, Operators and Other Constructs Elements of ColdFusion Expressions ColdFusion expressions consist of operands and operators. Operands are comprised of constants and variables. Operators are the verbs that act on the operands; functions are a form of operator. This chapter first describes the operands and then describes the operators.
  • Page 21 Elements of ColdFusion Expressions Type Description String Text values, which can be enclosed in single (’) or double (") quotes. String length is limited only by the amount of available memory on the ColdFusion server. To use a single quote inside a string that is single quoted, escape, or repeat, the single quote by using two single quotes.
  • Page 22 Chapter 1 ColdFusion Expressions: Operands, Operators and Other Constructs Type Description List Lists are a kind of string made up of elements separated by delimiters. The default delimiting character used by list processing functions is a comma. A list can have more than one delimiting character. You specify the allowable delimiters for a list in the delimiters parameter of ColdFusion list processing functions.
  • Page 23: Notes On Date-And-Time Values

    Elements of ColdFusion Expressions Notes on date-and-time values This section contains information about how date and time variables are handled by ColdFusion. How date and time values are stored ColdFusion represents date-and-time values internally on a time line as a subset of the real numbers.
  • Page 24: Variables

    Chapter 1 ColdFusion Expressions: Operands, Operators and Other Constructs Variables Variables are the most frequently used operands. Variable values can be set and reset, and passed as attributes to CFML tags and JRun servlets. They can be passed as parameters to functions, and can replace most constants. For a list of the variables associated with ColdFusion, see the CFML Quick Reference.
  • Page 25 Variables Variable Type Description Form Field The most common way of passing parameters to a page. When a user enters data in a form field, a parameter with the name of the form field is passed to the action page. Form fields are stored in structures.
  • Page 26: Cgi Environment Variables

    Chapter 1 ColdFusion Expressions: Operands, Operators and Other Constructs Variable Type Description Application Variables tied to an application as defined in the CFAPPLICATION NAME attribute, typically used in the file. Application.cfm Application variables work only if an application name is defined. Application variables are stored in structures.
  • Page 27 Variables Although you are not required to use the scope prefix unless two variables in different scopes have the same name, it is recommended for readability and processing speed that you use prefixes. For example, the variable Form.lastname clearer than a variable called simply lastname Specify the variable’s scope prefix for all Application, Session, Server, and Request variables.
  • Page 28 Chapter 1 ColdFusion Expressions: Operands, Operators and Other Constructs Prefix Required Availability Comment Request On the creating page and in any tags, Created by the cfset cfparam including nested tags, called after the by using a Request prefix variable is created On any page;...
  • Page 29 Variables Note ColdFusion does not attempt to automatically find Application, Session, Server, Request, or CFML tag variables (except File variables). You must use prefixes with these variables. The following scopes are exposed as ColdFusion structures: Form Attributes Request Cookie Session Application Note Variables on one application page can be used on any other application page that is...
  • Page 30 Chapter 1 ColdFusion Expressions: Operands, Operators and Other Constructs Note When variables are available to several application pages, keep track of your variable names. For more information, see “Variable naming conventions” on page For information on setting up client state management using the clientManagement attribute in the tag, see the description of...
  • Page 31: Cgi Environment Variables

    CGI Environment Variables CGI Environment Variables When a browser makes a request to a server, environment variables are created by the Web server and by the browser. In ColdFusion, these variables are referred to as CGI environment variables and they use the "CGI" prefix (even if your server uses a server API instead of CGI to communicate with the ColdFusion Server).
  • Page 32: Cgi Client Variables

    Chapter 1 ColdFusion Expressions: Operands, Operators and Other Constructs CGI Server Variable Description REQUEST_METHOD Method with which the request was made. For HTTP, this is Get, Head, Post, and so on. PATH_INFO Extra path information, as given by the client. Scripts can be accessed by their virtual pathname, followed by extra information at the end of this path.
  • Page 33: Cgi Client Certificate 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 34: Operators

    Chapter 1 ColdFusion Expressions: Operands, Operators and Other Constructs Operators Operators combine subexpressions to create complex expressions. Operators act on the operands. The general syntax for using operators is: Expression Operator Expression ColdFusion has four types of operators: Arithmetic Boolean Decision (or comparison) String Functions also can be viewed as operators because they act on operands.
  • Page 35: Decision Operators

    Operators Operator Description Exclusive or—either, or, but not both. Returns TRUE if the truth values of both arguments are different; returns FALSE otherwise. For example, TRUE XOR TRUE is FALSE, but TRUE XOR FALSE is TRUE. Equivalence both true or both false. The EQV operator is the opposite of the XOR operator.
  • Page 36: String Operators

    Chapter 1 ColdFusion Expressions: Operands, Operators and Other Constructs Operator Alternative name(s) GREATER THAN LESS THAN GREATER THAN OR EQUAL TO GTE, GE LESS THAN OR EQUAL TO LTE, LE String operators There is one string operator, which is the concatenation operator. Operator Description &...
  • Page 37: Functions As Operators

    Functions as Operators Functions as Operators Functions are a form of operator. Because ColdFusion functions return basic objects, such as numbers, strings, Boolean values, date-and-time objects, lists, arrays, structures, queries, and COM objects, function results can be used as operands. The following sections describe: function syntax optional function arguments...
  • Page 38: Pound Signs

    Chapter 1 ColdFusion Expressions: Operands, Operators and Other Constructs Pound Signs Pound signs (#) have a special meaning in CFML. ColdFusion treats text delimited by pound signs differently from plain text. When ColdFusion processes an expression, it replaces the text of the expression and the two pound signs around it with its resulting value.
  • Page 39: Pound Signs In Strings

    Pound Signs Complex expressions and cfoutput tags Complex expressions, which contain more that one variable or function, cannot be inserted inside tags. The following example produces an error: cfoutput <cfoutput>1 + 1 is #1 + 1#</cfoutput> To insert the value of a complex expression in the output generated by a cfoutput statement, use to set a variable to the value of the expression, and use the...
  • Page 40: Pound Signs In Tag Attribute Values

    Chapter 1 ColdFusion Expressions: Operands, Operators and Other Constructs To insert the value of a complex expression inside a string, do one of the following: to set a variable to the value of the expression and use that variable cfset inside the string Use the string concatenation operator Both techniques are shown in the following example;...
  • Page 41: Pound Signs In General Expressions

    These statements result in errors. As a general rule, never put pound signs around function arguments. Pound signs in general expressions Macromedia recommends that you use pound signs only when necessary. The following example shows the preferred method for referencing variables. <cfset SomeVar = Var1 + Max(Var2, 10 * Var3) + Var4>...
  • Page 42 Chapter 1 ColdFusion Expressions: Operands, Operators and Other Constructs...
  • Page 43: Chapter 2 Coldfusion Tags

    Chapter 2 ColdFusion Tags This chapter describes the ColdFusion Markup Language (CFML) tags. The introduction contains an alphabetical summary of ColdFusion tags, a list of new tags in ColdFusion 5, and a list of tags by category. The rest of this chapter describes each tag in detail.
  • Page 44: Alphabetical List Of Coldfusion Tags

    Chapter 2 ColdFusion Tags Alphabetical List of ColdFusion Tags ColdFusion Markup Language (CFML) consists of a set of tags you use in ColdFusion pages to interact with data sources, manipulate data, and display output. Using CFML tags is very simple; tag syntax is much like HTML element syntax. The following table provides brief descriptions of the CFML tags.
  • Page 45 Alphabetical List of ColdFusion Tags CFML Tag Category Description cfflush Data output Flushes currently available data to the client. cfform Form Builds an input form; performs client-side input validation. cfftp Internet Permits FTP file operations. protocol cfgraph Data output Displays a graphical representation of data. cfgraphdata Data output Specifies a data point to be displayed by a...
  • Page 46 Chapter 2 ColdFusion Tags CFML Tag Category Description cfloop Flow-control Repeats a set of instructions based on a set of conditions. cfmail Internet Assembles and posts an e-mail message. protocol cfmailparam Internet Attaches a file or adds a header to an e-mail protocol message.
  • Page 47 Alphabetical List of ColdFusion Tags CFML Tag Category Description cfselect Form Used in cfform to create a drop-down list box form element. cfservlet extensibility, Executes a Java servlet on a JRun engine. Java cfservletparam extensibility, Passes data to a Java servlet. A child tag of Java cfservlet cfset...
  • Page 48: New Tags In Coldfusion 5

    Chapter 2 ColdFusion Tags New tags in ColdFusion 5 cfflush cfgraph cfgraphdata cflog cfsavecontent cfdump Forms tags cfapplet cfgridrow cfslider cfform cfgridupdate cftextinput cfgrid cfinput cftree cfgridcolumn cfselect cftreeitem Database manipulation tags cfinsert cfqueryparam cfprocparam cfstoredproc cfprocresult cftransaction cfquery cfupdate Data output tags cfcol cfoutput...
  • Page 49: Extensibility Tags

    Alphabetical List of ColdFusion Tags Extensibility tags cfcollection cfreport cfexecute cfsearch cfgraph cfservlet cfindex cfservletparam cfobject cfwddx File management tags cfdirectory cffile Flow-control tags cfabort cfloop cfbreak cfrethrow cfexecute cfswitch/cfcase/cfdefaultcase cfexit cfthrow cfif/cfelseif/cfelse cftry cfcatch cflocation Internet Protocol tags cfftp cfmail cfhttp cfmailparam...
  • Page 50: Variable Manipulation Tags

    Chapter 2 ColdFusion Tags cfheader cfsilent cfhtmlhead Variable manipulation tags cfcookie cfsavecontent cfdump cfschedule cfparam cfset cfregistry Web application framework tags cfapplication cflock cfassociate cfmodule cfauthenticate cfscript cfimpersonate...
  • Page 51: Cfabort

    Alphabetical List of ColdFusion Tags cfabort Description Stops processing of a page at the tag location. ColdFusion returns everything that was processed before the tag. The tag is often used with conditional cfabort cfabort logic to stop processing a page when a condition occurs. Category Flow-control tags Syntax...
  • Page 52 Chapter 2 ColdFusion Tags <cfoutput> <P>The value of myVariable after incrementing through the loop #Counter# times is: #myVariable# </cfoutput> <!--- reset the variable and show the use of cfabort ---> <H3>Example B: Use cfabort to halt the instruction</H3> <cfset myVariable = 3> <!--- now, perform a loop that increments this value --->...
  • Page 53: Cfapplet

    Alphabetical List of ColdFusion Tags cfapplet Description Used in a tag, lets you reference custom Java applets that you have cfform cfapplet registered using the ColdFusion Administrator. To register a Java applet, open the ColdFusion Administrator and click Applets. Category Forms tags Syntax <cfapplet appletSource = "applet_name"...
  • Page 54 Chapter 2 ColdFusion Tags Attribute Description notSupported Optional. The text to display if a page containing a Java applet-based control is opened by a browser that does not support Java or cfform has Java support disabled. For example: notSupported = "<B>Browser must support Java to view ColdFusion Java Applets</B>"...
  • Page 55: Cfapplication

    Alphabetical List of ColdFusion Tags cfapplication Description Defines scoping for a ColdFusion application, enables or disables storing client variables, and specifies a client variable storage mechanism. By default, client variables are disabled. Also, enables session variables and sets timeouts for session and application variables.
  • Page 56 Chapter 2 ColdFusion Tags Attribute Description sessionManagement Optional. Yes or No. Yes enables session variables. Default is sessionTimeout Optional. Enter the CreateTimeSpan function and values in days, hours, minutes, and seconds, separated by commas, to specify the lifespan of session variables. The default value is specified in the Variables page of the ColdFusion Administrator.
  • Page 57 Alphabetical List of ColdFusion Tags <H3>cfapplication Example</H3> <P>cfapplication defines scoping for a ColdFusion application and enables or disables the storing of application and/or session variables. This tag is placed in a special file called Application.cfm that is run before any other CF template in a directory where the Application.cfm file appears.
  • Page 58: Cfassociate

    Chapter 2 ColdFusion Tags cfassociate Description Allows subtag data to be saved with the base tag. Applies only to custom tags. Category Web application framework tags Syntax <cfassociate baseTag = "base_tag_name" dataCollection = "collection_name"> See also cfapplication, cfauthenticate, cferror, cflock, cfmodule Attributes Attribute...
  • Page 59: Cfauthenticate

    Alphabetical List of ColdFusion Tags cfauthenticate Description Authenticates a user, setting a security context for the application. For more information, see the descriptions of IsAuthenticated AuthenticatedContext Category Web application framework tags Syntax <cfauthenticate securityContext = "security_context" username = "user_ID" password = "password" setCookie = "Yes"...
  • Page 60 Chapter 2 ColdFusion Tags <cfcatch type = "Security"> <!--- the message to display ---> <H3>Authentication error</H3> <cfoutput> <!--- Display the message. Alternatively, you might place code here to define the user to the security domain. ---> <P>#cfcatch.message# </cfoutput> </cfcatch> </cftry> </cfif>...
  • Page 61: Cfbreak

    Alphabetical List of ColdFusion Tags cfbreak Description Used to break out of a cfloop Category Flow-control tags Syntax <cfbreak> See also cfabort, cfexecute, cfif/cfelseif/cfelse, cflocation, cfloop, cfswitch/ cfcase/cfdefaultcase, cfthrow, cftry cfcatch Example <!--- This example shows the use of cfbreak to exit a loop when a condition is met --->...
  • Page 62: Cfcache

    Chapter 2 ColdFusion Tags cfcache Description Speeds up page rendering when dynamic content does not have to be retrieved each time a user accesses the page. To accomplish this, creates temporary files cfcache that contain the static HTML returned from a ColdFusion page. You can use for simple URLs and URLs that contain URL parameters.
  • Page 63 Alphabetical List of ColdFusion Tags Attribute Description directory Optional. Used with action = "flush" . Specifies the fully qualified path of a directory that contains the cfcache.map be used when . The default is the directory action = "flush" of the current page. cacheDirectory Optional.
  • Page 64 Chapter 2 ColdFusion Tags file in a directory stores mappings for that directory only. If the cfcache.map timestamp of the underlying page changes, ColdFusion updates the cache file for that URL. ColdFusion uses the SourceTimeStamp field to determine whether the currently cached file is up to date.
  • Page 65: Cfcol

    Alphabetical List of ColdFusion Tags cfcol Description Defines table column header, width, alignment, and text. Used only inside a cftable Category Data output tags Syntax <cfcol header = "column_header_text" width = "number_indicating_width_of_column" align = "Left" or "Right" or "Center" text = "double_quote_delimited_text_indicating_type_of_text"> See also cfcontent, cfoutput, cftable...
  • Page 66 Chapter 2 ColdFusion Tags <cftable query = "GetEmployees" startRow = "1" colSpacing = "3" HTMLTable> <!--- each cfcol tag sets the width of a column in the table, as well as specifying the header information and the text/CFML with which to fill the cell ---> <cfcol header = "<B>ID</B>"...
  • Page 67: Cfcollection

    Alphabetical List of ColdFusion Tags cfcollection Description Allows you to create and administer Verity collections. Category Extensibility tags Syntax <cfcollection action = "create" or "repair" or "delete" or "optimize" or "map" collection = "collection_name" path = "path_of_verity_directory" language = "English" or "German" or "Finnish" or "French" or "Danish" or "Dutch"...
  • Page 68 Chapter 2 ColdFusion Tags Attribute Description language Optional for create . To use the language attribute you must have the ColdFusion International Search Pack installed. Options are: English (default) German Finnish French Danish Dutch Italian Norwegian Portuguese Spanish Swedish works only at the collection level. To add content to a collection, use Usage cfcollection cfindex...
  • Page 69 Alphabetical List of ColdFusion Tags <cfcase value = "Repair"> <cfcollection action = "repair" collection = "#form.CollectionName#"> <H3>Collection repaired.</H3> </cfcase> <cfcase value = "Optimize"> <cfcollection action = "optimize" collection = "#form.CollectionName#"> <H3>Collection optimized.</H3> </cfcase> <cfcase value = "delete"> <cfcollection action = "delete" collection = "#form.CollectionName#">...
  • Page 70: Cfcontent

    Chapter 2 ColdFusion Tags cfcontent Description Defines the MIME type returned by the current page. Optionally, lets you specify the name of a file to be returned with the page. Category Data output tags Note In the ColdFusion Administrator, the security settings on the Tag Restrictions page under ColdFusion Basic Security may prevent from executing.
  • Page 71 Alphabetical List of ColdFusion Tags </title> </head> <body> <H3>cfcontent Example</H3> <!--- Files may be set to delete after downloading, allowing for the posting of changing content. ---> <cfcontent type = "text/html" file = "c:\inetpub\wwwroot\cfdocs\main.htm" deleteFile = "No"> </body> </html> <!--- This example shows how the reset attribute changes textual output.
  • Page 72: Cfcookie

    ), the subdomain specification must contain at least three periods; for example, .mongo.stateu.us . For special top level domains, only two periods are needed, as in .macromedia.com When specifying a value, you must include a valid path domain Separate multiple entries with a semicolon.
  • Page 73 Alphabetical List of ColdFusion Tags Warning Do not set a cookie variable on the same page that you use the tag. If you cflocation do, the cookie is never saved on the browser; therefore, it is of no value. Example <!--- This example shows how to set a cfcookie variable, and also how to delete that variable --->...
  • Page 74 Chapter 2 ColdFusion Tags </cfif> <!--- show the most recent cookie set ---> <cfif IsDefined("Cookie.LastAOLVisitor") is "True"> <P>The last AOL visitor to view this site was <cfoutput>#Cookie.LastAOLVisitor#</cfoutput>, on <cfoutput>#DateFormat(COOKIE.TimeVisited)#</cfoutput> <!--- use this link to reset the cookies ---> <P><a href = "cfcookie.cfm?delcookie = yes">Hide my tracks</A> <cfelse>...
  • Page 75: Cfdirectory

    Alphabetical List of ColdFusion Tags cfdirectory Description Handles interactions with directories. Category File management tags Note In the ColdFusion Administrator, the security settings on the Tag Restrictions page under ColdFusion Basic Security may prevent from executing. In order cfdirectory to execute, it needs to be enabled. For more information, see cfdirectory Advanced ColdFusion Administration.
  • Page 76 Chapter 2 ColdFusion Tags Attribute Description mode Optional. Used with action = "Create" to define the permissions for a directory on UNIX and Linux platforms. Ignored on Windows. Options correspond to the octal values of the UNIX command. chmod From left to right, permissions are assigned for owner, group, and other.
  • Page 77 Alphabetical List of ColdFusion Tags ----------------------------------------------------------------------> <html> <head> <title> cfdirectory Example </title> </head> <body> <H3>cfdirectory Example</H3> <!--- use cfdirectory to give the contents of the snippets directory, order by name and size (you may need to modify this path) ---> <cfdirectory directory = "c:\inetpub\wwwroot\cfdocs\snippets"...
  • Page 78: Cfdump

    Chapter 2 ColdFusion Tags cfdump Description utputs variables for debugging purposes. Using , you can display the cfdump contents of simple variables, queries, arrays, structures, and WDDX variables created with cfwddx Category Variable manipulation tags Syntax <cfdump var = #variable_name#> See also cfcookie, cfdump, cfparam, cfregistry, cfsavecontent, cfschedule, cfset, cfwddx...
  • Page 79: Cferror

    Alphabetical List of ColdFusion Tags cferror Description Enables the display of customized HTML pages when errors occur. This lets you maintain a consistent look and feel within your application, even when errors occur. Category Exception handling tags Syntax <cferror type = "request" or "validation" or "monitor"...
  • Page 80 Chapter 2 ColdFusion Tags Templates The following table describes the template to use for each type of error. Template type Description Exception Dynamically invoked by the CFML Uses the full range of CFML language processor when it detects tags, making it more powerful an unhandled exception condition.
  • Page 81 Alphabetical List of ColdFusion Tags The following table lists the error variables: Template type Error variable Description error.diagnostics Exception Detailed error diagnostics from ColdFusion Server. Request error.mailTo Monitor E-mail address of administrator notified (corresponds to the value set in the attribute of mailTo cferror...
  • Page 82 Chapter 2 ColdFusion Tags handle your CF errors within a CF template than cferror, but cferror is still a good safeguard against general errors. <P>You can also use cferror within the Application.cfm to specify error handling responsibilities for an entire application.
  • Page 83: Cfexecute

    Alphabetical List of ColdFusion Tags cfexecute Description Enables ColdFusion developers to execute a process on a server computer. Category Extensibility tags Syntax <cfexecute name = " ApplicationName " arguments = "CommandLine Arguments" outputFile = "Output file name" timeout = "Timeout interval in seconds"> </cfexecute>...
  • Page 84 Chapter 2 ColdFusion Tags Usage is available on Windows NT 4.0 and UNIX platforms. Do not put other cfexecute ColdFusion tags or functions between the start and the end tags of . The cfexecute tags cannot be nested. cfexecute Exception throws the following exceptions: cfexecute If the application name is not found: Application File Not Found exception...
  • Page 85: Cfexit

    Alphabetical List of ColdFusion Tags cfexit Description Used to: Abort the processing of the currently executing CFML custom tag. Exit the template within the currently executing CFML custom tag Reexecute a section of code within the currently executing CFML custom tag Flow-control tags Category Syntax...
  • Page 86 Chapter 2 ColdFusion Tags Example <!--- This read-only example shows the use of cfexit ---> <html> <head> <title>cfexit Example</title> </head> <body> <H3>cfexit Example</H3> <P>cfexit can be used to abort the processing of the currently executing CFML custom tag. Execution resumes following the invocation of the custom tag in the page that called the tag.
  • Page 87 Alphabetical List of ColdFusion Tags <cfexit> <P>This text will not be executed due to the existence of the cfexit tag above it. </body> </html>...
  • Page 88: Cffile

    Chapter 2 ColdFusion Tags cffile Description Handles all interactions with files. The attributes you use with depend on the cffile value of the attribute. For example, if the , use the action action = "write" attributes associated with writing a text file. Note In the ColdFusion Administrator, the security settings on the Tag Restrictions page under ColdFusion Basic Security may prevent...
  • Page 89 Alphabetical List of ColdFusion Tags cffile action = "upload" Description Uploads upload a file specified in a form field to a directory on the Web server. Note attribute applies only to ColdFusion on Solaris and HP-UX. mode Category File management tags Syntax <cffile action = "upload"...
  • Page 90 Chapter 2 ColdFusion Tags Attribute Description mode Optional. Defines permissions for an uploaded file on UNIX and Linux platforms. Ignored in Windows. Option values correspond to the octal values (not symbolic) of the UNIX command. Permissions are chmod assigned for owner, group, and other, respectively. For example: Assigns read/write permissions for the owner, and mode = "644"...
  • Page 91 Alphabetical List of ColdFusion Tags Note Although the prefix is still supported, it has been deprecated in favor of the file prefix. cffile The following file upload status parameters are available after an upload. Parameter Description attemptedServerFile Initial name ColdFusion used when attempting to save a file clientDirectory Directory location of the file uploaded from the client’s system...
  • Page 92 Chapter 2 ColdFusion Tags Use the prefix to refer to these parameters; for example, cffile #cffile.fileExisted# Note File status parameters are read-only. They are set to the results of the most recent operation. (If two tags execute, the results of the first are overwritten cffile cffile by the subsequent...
  • Page 93 Alphabetical List of ColdFusion Tags cffile action = "move" Description Moves a file from one location on the server to another. Category File management tags Syntax <cffile action = "move" source = "full_path_name" destination = "full_path_name" attributes = "file_attributes"> See also cfdirectory Attributes Attribute...
  • Page 94 Chapter 2 ColdFusion Tags cffile action = "rename" Description with the action to rename a file on the server. cffile rename Category File management tags Syntax <cffile action = "rename" source = "full_path_name" destination = "full_path_name" attributes = "file_attributes"> See also cfdirectory Attributes Attribute...
  • Page 95 Alphabetical List of ColdFusion Tags cffile action = "copy" Description Copies a file from one directory to another on the server. Category File management tags Syntax <cffile action = "copy" source = "full_path_name" destination = "full_path_name" attributes = "file_attributes"> See also cfdirectory Attributes Attribute...
  • Page 96 Chapter 2 ColdFusion Tags cffile action = "delete" Description Deletes a file on the server. Category File management tags Syntax <cffile action = "delete" file = "full_path_name"> See also cfdirectory Attributes Attribute Description file Required. The full pathname of the file to delete. The following example deletes the specified file: Example <cffile action = "delete"...
  • Page 97 Alphabetical List of ColdFusion Tags cffile action = "read" Description Reads a text file. The file is read into a dynamic parameter that you can use anywhere in the page, like any other dynamic parameter. For example, you could read a text file and then insert its contents into a database, or you could read a text file and then use the find and replace functions to modify its contents.
  • Page 98 Chapter 2 ColdFusion Tags cffile action = "readBinary" Description Read a binary file, such as an executable or image file. The file is read into a binary object parameter you can use anywhere in the page, like any other parameter. To send it through a Web protocol, such as HTTP or SMTP , or store it in a database, first convert it to Base64 (see “ToBase64”...
  • Page 99 Alphabetical List of ColdFusion Tags cffile action = "write" Description Writes a text file based on dynamic content. For example, you could create static HTML files from this content, or log actions in a text file. Category File management tags Syntax <cffile action = "write"...
  • Page 100 Chapter 2 ColdFusion Tags Attribute Description attributes Optional. A comma-delimited list of file attributes to be set on the file being written. The following file attributes are supported: readOnly temporary archive hidden system normal is not used, the file’s attributes are maintained. If attributes is specified with any other attributes, is overridden by...
  • Page 101 Alphabetical List of ColdFusion Tags 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>...
  • Page 102 Chapter 2 ColdFusion Tags cffile action = "append" Appends text to the end of an existing text file; for example, when creating log files. Description Category File management tags Syntax <cffile action = "append" file = "full_path_name" output = "string" attributes = "file_attributes">...
  • Page 103: Cfform

    Alphabetical List of ColdFusion Tags cfform Description uilds a form with CFML custom control tags that provide more functionality than standard HTML form input elements. Category Forms tags Note tag requires the client to download a Java applet. Downloading an applet cfform takes time, so using may be slightly slower than using a simple HTML form.
  • Page 104 Chapter 2 ColdFusion Tags Attribute Description onSubmit Optional. JavaScript function to execute after other input validation returns. Use this attribute to execute JavaScript for preprocessing data before the form is submitted. For more information, see Developing ColdFusion Applications. target Optional. The name of the window or window frame to which the form output is sent.
  • Page 105 Alphabetical List of ColdFusion Tags By placing HTML tags that can ordinarily be placed within the regular HTML tag between tags. form <cfform> </cfform> For example, you use a standard HTML tag to create a submit button in a input cfform <cfform>...
  • Page 106 Chapter 2 ColdFusion Tags No <cfinput type = "Radio" name = "TestVal1" value = "No"> </TD> </TR> <TR> <TD> <H4>This example displays the checkbox input type for cfinput.</H4> <cfinput type = "Checkbox" name = "ChkTest2" value = "Yes"> </TD> </TR> <TR>...
  • Page 107: Cfflush

    Alphabetical List of ColdFusion Tags cfflush Description Flushes currently available data to the client. Category Page processing tags Syntax <cfflush interval = integer number of bytes> See also cfcache, cfheader, cfinclude, cfsetting, cfsilent Attributes Attribute Description interval Optional. Flush the output each time at least the specified number of bytes become available.
  • Page 108 Chapter 2 ColdFusion Tags page is slow to retrieve its first data, and in which additional information is generated slowly, and can be displayed incrementally. <html> <head> <title>Your Magic numbers</title> </head> <body> <H1>Your Magic numbers</H1> <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.
  • Page 109: Cfftp

    Alphabetical List of ColdFusion Tags cfftp Description Lets users implement File Transfer Protocol (FTP) operations. Category Internet Protocol tags Use the tag to move files between a ColdFusion server and an FTP server. The Usage cfftp tag cannot move files between a ColdFusion server and a browser (client). To cfftp do this, use to transfer files from the client to a...
  • Page 110 Chapter 2 ColdFusion Tags Connecting to an FTP server Description Use the attribute of the tag to establish a connection with an FTP connection cfftp server. Category Internet Protocol tags Syntax <cfftp action = "action" username = "name" password = "password" server = "server"...
  • Page 111 Alphabetical List of ColdFusion Tags Attribute Description stopOnError Optional. Yes or No. When Yes, halts all processing and displays an appropriate error. Default is Yes. When No, three variables are populated: – Yes or No. cfftp.succeeded – Error number. See the IETF Network Working cfftp.errorCode Group RFC 959: File Transfer Protocol (FTP) for information about FTP error codes: http://www.ietf.org/rfc/rfc0959.txt.
  • Page 112 Chapter 2 ColdFusion Tags server = "ftp.tucows.com" stopOnError = "Yes"> <P>Did it succeed? <cfoutput>#cfftp.succeeded#</cfoutput> <P>List the files in a directory: <cfftp action = "LISTDIR" stopOnError = "Yes" name = "ListFiles" directory = "/" connection = "my_query"> <cfoutput query = "ListFiles"> #name#<BR>...
  • Page 113 Alphabetical List of ColdFusion Tags cfftp: Connection caching Usage After you establish a connection with , you can reuse it to perform additional cfftp FTP operations. To do this, you use the attribute to define and name an connection FTP connection object that stores information about the connection. Any additional FTP operations that use the same name automatically make use of the connection...
  • Page 114 Chapter 2 ColdFusion Tags Connection: File and directory operations Description Use this form of the tag to perform file and directory operations with cfftp cfftp If you use connection caching to an active FTP connection, you do not have to respecify the connection attributes: username password...
  • Page 115 Alphabetical List of ColdFusion Tags Attribute Description username Required if the FTP connection is not cached. If connection caching is used, the attribute is not required. User username name to pass in the FTP operation. name Required for . Specifies the query name action = "listDir"...
  • Page 116 Chapter 2 ColdFusion Tags Attribute Description username Required if the FTP connection is not cached. If connection caching is used, the attribute is not required. User username name to pass in the FTP operation. name Required for . Specifies the query name action = "listDir"...
  • Page 117 Alphabetical List of ColdFusion Tags Attribute Description retryCount Optional. Number of retries until failure is reported. Default is one (1). stopOnError Optional. Yes or No. If Yes, halts processing and displays an appropriate error. Default is No. When No, three variables are populated: cfftp.succeeded –...
  • Page 118 Chapter 2 ColdFusion Tags cfftp Action Value of cfftp.returnValue existsFile Yes or No exists Yes or No...
  • Page 119 Alphabetical List of ColdFusion Tags cfftp action = "listDir" Description Use the tag with the attribute set to the value to access the cfftp action listDir columns in a query object. Category Internet Protocol tags Usage When you use with the action, you must specify a value for the cfftp listDir...
  • Page 120: Cfgraph

    To use the cfgraph tag, you must have Macromedia Generator running on a JRun server. If the JRun server is not listening on the default port on your localhost, you must use ColdFusion Administrator to specify the host address and port. For more information, see Installing and Configuring ColdFusion Server.
  • Page 121 Alphabetical List of ColdFusion Tags cfgraph type = "bar" or type = "horizontalBar" Description Use this form of the tag to generate bar and horizontal bar graphs. cfgraph Syntax <cfgraph type = "bar" or "horizontalBar" query = "query name" valueColumn = "query column" itemColumn = "query column"...
  • Page 122 Chapter 2 ColdFusion Tags Basic attributes These attributes provide basic information about the graph. Attribute Description type Required. Type of chart to display. Must be one of the following: HorizontalBar Line query Name of the query that contains the data to graph. Required if you do not use tags in the tag body to specify...
  • Page 123 Alphabetical List of ColdFusion Tags Bar chart value display attributes These attributes determine how data point values are displayed on the graph and the values on the vertical axes. Attribute Description showValueLabel Optional. Specifies whether values are displayed for the data points.
  • Page 124 Chapter 2 ColdFusion Tags Attribute Description itemLabelSize The size of the item labels, in points. Default is 12. itemLabelOrientation Optional. Orientation of item labels.This option has an effect only if the data includes a label column. Valid values are: horizontal (default for HorizontalBar) vertical (default for Bar) Bar chart title attributes These attributes determine how the title and legend appear.
  • Page 125 Alphabetical List of ColdFusion Tags Attribute Description borderColor Optional. The color used to draw borders and grid lines. Can be any of the 256 standard web colors, in any valid HTML color format. Default is black. borderWidth Optional. Border thickness, in pixels. Setting this attribute to 0 removes the border.
  • Page 126 Chapter 2 ColdFusion Tags <!--- Reformat the generated numbers to show only thousands ---> <cfloop index = "i" from = "1" to = "#DataTable.RecordCount#"> <cfset DataTable.SumSal[i] = Round(DataTable.SumSal[i]/1000)*1000> <cfset DataTable.AvgSal[i] = Round(DataTable.AvgSal[i]/1000)*1000> </cfloop> <html> <head> <title>Employee Salary Analysis</title> </head> <body> <h1>Employee Salary Analysis</h1>...
  • Page 127 Alphabetical List of ColdFusion Tags cfgraph type = "line" Use this form of the tag to generate line graphs and area graphs. An area cfgraph graph is a line graph with the attribute set to "Yes". fill Syntax <cfgraph type = "line" query = "query name"...
  • Page 128 Chapter 2 ColdFusion Tags Attribute Description valueColumn Query column that contains the data values. Required if you do not use tags in the cfgraphdata cfgraph body to specify the data values. itemColumn Optional. Query column that contains the item label for the corresponding data point.
  • Page 129 Alphabetical List of ColdFusion Tags Line graph title attributes These attributes determine how the title appears on the graph. Attribute Description title Optional. Title to display centered above the chart, or below the chart if the legend is above the chart. If unspecified, no title displays. titleFont Optional.
  • Page 130 Chapter 2 ColdFusion Tags Attribute Description borderWidth Optional. Border thickness, in pixels. Setting this attribute to 0 removes the border. Default is 1. depth Optional. Depth of 3D chart appearance, in pixels. Default is 0, no 3D appearance. gridLines Optional. An integer specifying the number of grid lines to display on the chart between the top and bottom lines.
  • Page 131 Alphabetical List of ColdFusion Tags cfgraph type = "pie" Use this form of the tag to generate pie charts. cfgraph Syntax <cfgraph type = "pie" query = "query name" valueColumn = "query column" itemColumn = "query column" <!--- data drill down attributes ---> URL = "URL string"...
  • Page 132 Chapter 2 ColdFusion Tags Attribute Description valueColumn Query column that contains the data values. Required if you do not use tags in the cfgraphdata cfgraph body to specify the data values. itemColumn Optional. Query column that contains the item label for the corresponding data point.
  • Page 133 Alphabetical List of ColdFusion Tags Attribute Description valueLabelSize Optional. The size the value text, in points. Default value: 12. valueLocation Optional. Where value labels are placed. Valid values are: inside (default) outside Pie chart legend and title attributes These attributes determine how the title and legend appear. Attribute Description title...
  • Page 134 Chapter 2 ColdFusion Tags Attribute Description graphWidth Optional. Width of the graph, in pixels. Default is 320. backgroundColor Optional. Color of the chart background. Can be any of the 256 standard web colors, in any valid HTML color format. Default is white. borderColor Optional.
  • Page 135 Alphabetical List of ColdFusion Tags <!--- Reformat the generated numbers to show only thousands ---> <cfloop index="i" from="1" to="#DataTable.RecordCount#"> <cfset DataTable.SumSal[i]=Round(DataTable.SumSal[i]/1000)*1000> <cfset DataTable.AvgSal[i]=Round(DataTable.AvgSal[i]/1000)*1000> </cfloop> <html> <head> <title>Employee Salary Analysis</title> </head> <body> <h1>Employee Salary Analysis</h1> <!--- Pie graph, from Query of Queries ---> <cfgraph type="pie"...
  • Page 136: Cfgraphdata

    Chapter 2 ColdFusion Tags cfgraphdata Description Specifies a data point to be displayed by a tag. cfgraph Category Extensibility tags Syntax <cfgraphdata item = "data item" value = data value item = "label string" color = "Web color" URL = "URL string"> See also cfgraph, cfcollection, cfexecute, cfindex, cfobject, cfreport, cfsearch, cfservlet,...
  • Page 137: Cfgrid

    Alphabetical List of ColdFusion Tags cfgrid Description Used inside lets you place a grid control in a ColdFusion form. A grid cfform cfgrid control is a table of data divided into rows and columns. The tag column data cfgrid is specified with tags.
  • Page 138 Chapter 2 ColdFusion Tags notSupported = "text" pictureBar = "Yes" or "No" insertButton = "text" deleteButton = "text" sortAscendingButton = "text" sortDescendingButton = "text"> </cfgrid> See also cfapplet, cfform, cfinput, cfselect, cfslider, cftextinput, cftree, cfgridcolumn, cfgridrow, cfgridupdate Attributes Attribute Description name Required.
  • Page 139 Alphabetical List of ColdFusion Tags Attribute Description italic Optional. Yes or No. Yes displays grid control text in italic. Default is No. bold Optional. Yes or No. Yes displays grid control text in boldface. Default is No. textColor Optional. Color value for text in the grid control. Options are: black (default), magenta, cyan, orange, darkgray, pink, gray, white, lightgray, yellow.
  • Page 140 Chapter 2 ColdFusion Tags Attribute Description rowHeaders Optional. Yes or No. Yes displays a column of numeric row labels in the grid control. Defaults to Yes. rowHeaderAlign Optional. Enter Left, Right, or Center to position data within a row header. Default is Left. rowHeaderFont Optional.
  • Page 141 Alphabetical List of ColdFusion Tags Attribute Description bgColor Optional. Background color value for the grid control. Entries are: black, magenta, cyan, orange, darkgray, pink, gray, white, lightgray, yellow. A hex value can be entered in the form: bgColor = "##xxxxxx" where x is 0-9 or A-F.
  • Page 142: How Data Is Returned From Cfgrid

    Chapter 2 ColdFusion Tags Usage You can populate a with data from a . If you do not specify any cfgrid cfquery entries, a default set of columns is generated. Each column in the cfgridcolumn query is included in the default column list. In addition, a default header for each column is created by replacing any hyphen (-) or underscore (_) characters in the table column name with spaces.
  • Page 143 Alphabetical List of ColdFusion Tags Update data (SelectMode = Edit) attribute is , the grid returns a great deal of data in order to inform SelectMode Edit the ACTION page of any inserts, updates or deletes that the user has made to the grid.
  • Page 144: Using The Href Attribute

    Chapter 2 ColdFusion Tags <CFSET Val_Orig = Array_Orig[#LoopCount#]> <CFSET Val_New = Array_New[#LoopCount#]> <CFSET Val_Action = rray_Action[#LoopCount#]> <CFOUTPUT> <TR> <TD>#LoopCount#</TD> <TD>#Val_Action#</TD> <TD>#Val_Orig#</TD> <TD>#Val_New#</TD> </TR> </CFOUTPUT> </CFLOOP> </TABLE> </CFIF> </CFIF> <CFELSE> <CFOUTPUT>form.#GridName#.#ColName#: NotSet!</cfoutput><BR> </CFIF> </CFLOOP> Using the href attribute When specifying a URL with grid items using the attribute, the value of the href attribute determines whether the appended key value is limited to a...
  • Page 145 Alphabetical List of ColdFusion Tags <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> <title> cfgrid Example </title> </head> <body> <H3>cfgrid Example</H3> <I>Try adding a course to the database, and then deleting it.</I> <!--- call the cfform to allow us to use cfgrid controls --->...
  • Page 146 Chapter 2 ColdFusion Tags <cfgridcolumn name = "CorName" header = "Name" headerAlign = "LEFT" dataAlign = "LEFT" font = "Times" bold = "No" italic = "No" select = "Yes" display = "Yes" headerBold = "No" headerItalic = "No"> <cfgridcolumn name = "CorLevel" header = "Level" headerAlign = "LEFT"...
  • Page 147: Cfgridcolumn

    Alphabetical List of ColdFusion Tags cfgridcolumn Description Used with in a , you use to specify column data in a cfgrid cfform cfgridcolumn control. Font and alignment attributes used in override any cfgrid cfgridcolumn global font or alignment settings defined in cfgrid Category Forms tags...
  • Page 148 Chapter 2 ColdFusion Tags Attribute Description fontSize Optional. Font size for text in the column. Default is the font specified by cfgrid italic Optional. Yes or No. Yes displays all grid control text in italic. Default is as specified by the corresponding attribute of cfgrid bold Optional.
  • Page 149 Alphabetical List of ColdFusion Tags Attribute Description href Optional. URL to associate with the grid item. You can specify a URL that is relative to the current page: ../mypage.cfm Or an absolute URL: http://myserver.com/mydir/mypage.cfm hrefKey Optional. The name of a query column when the grid uses a query.
  • Page 150 Chapter 2 ColdFusion Tags Attribute Description headerFontSize Optional. Font size to use for the column header, in pixels. Default is as specified by the corresponding attribute of cfgrid headerItalic Optional. Yes or No. Yes displays column header text in italic. Default is as specified by the corresponding attribute of cfgrid headerBold...
  • Page 151 Alphabetical List of ColdFusion Tags Using expressions in textColor and bgColor attributes attributes accept a color value literal or an expression textColor bgColor that lets you select a text color based on the evaluation of a simple boolean expression. The basic syntax for this expression is as follows: (CX operator string ? true_condition : false_condition) Where: The column containing the value you want to test.
  • Page 152 Chapter 2 ColdFusion Tags Character Meaning Places + in front of positive numbers, - in front of negative numbers. Place " " (space) in front of positive numbers, - in front of negative numbers. Separates thousands with commas. Specifies left-justify or center-justify a number within the width of the mask column.
  • Page 153 Alphabetical List of ColdFusion Tags headerItalic = "No"> <cfgridcolumn name = "CorLevel" header = "Level" headerAlign = "LEFT" dataAlign = "LEFT" bold = "No" italic = "No" select = "Yes" display = "Yes" headerBold = "No" headerItalic = "No">...
  • Page 154: Cfgridrow

    Chapter 2 ColdFusion Tags cfgridrow Description Lets you define a that does not use a query as source for row data. If a cfgrid query attribute is specified in , the tags are ignored. cfgrid cfgridrow Category Forms tags Syntax <cfgridrow data = "col1, col2, ...">...
  • Page 155: Cfgridupdate

    Alphabetical List of ColdFusion Tags cfgridupdate Description Used in a allows you to perform updates to data sources cfgrid cfgridupdate directly from edited grid data. The tag provides a direct interface with cfgridupdate your data source. tag applies row actions first, then INSERT row actions, cfgridupdate delete and then UPDATE row actions.
  • Page 156 Chapter 2 ColdFusion Tags Attribute Description dbType Optional. The database driver type: dynamic Connect to an ODBC data source that is not defined in the ColdFusion Administrator. When you use this attribute value, you must specify all the ODBC connection information using the connectstring attribute.
  • Page 157 Alphabetical List of ColdFusion Tags Attribute Description tableOwner Optional. For data sources that support table ownership (such as SQL Server, Oracle, and Sybase SQL Anywhere), use this field to specify the owner of the table. tableQualifier Optional. For data sources that support table qualifiers, use this field to specify the qualifier for the table.
  • Page 158: Cfheader

    Chapter 2 ColdFusion Tags cfheader Description Generates custom HTTP response headers to return to the client. Category Page processing tags Syntax <cfheader name = "header_name" value = "header_value"> <cfheader statusCode = "status_code" statusText = "status_text"> See also cfcache, cfflush, cfheader, cfhtmlhead, cfinclude, cfsetting, cfsilent Attributes Attribute...
  • Page 159: Cfhtmlhead

    Alphabetical List of ColdFusion Tags cfhtmlhead Description writes the text specified in the attribute to the <head> section of a cfhtmlhead text generated HTML page. The tag can be useful for embedding JavaScript cfhtmlhead code, or placing other HTML tags such, as META, LINK, TITLE, or BASE in an HTML page header.
  • Page 160: Cfhttp

    Chapter 2 ColdFusion Tags cfhttp Description Lets you execute HTTP POST and GET operations on files. Using , you can cfhttp execute standard GET operations and create a query object from a text file. POST operations lets you upload MIME file types to a server, or post cookie, formfield, URL, file, or CGI variables directly to a specified server.
  • Page 161 Alphabetical List of ColdFusion Tags Attribute Description password Optional. When required by a server, a valid password. name Optional. The name to assign to a query if the a query is constructed from a file. columns Optional. Specifies the column names for a query when creating a query as a result of a GET.
  • Page 162 Chapter 2 ColdFusion Tags Attribute Description resolveURL Optional. Yes or No. Default is No. For GET and POST operations, if Yes, page reference returned into the internal variable fileContent has its internal URLs fully resolved, including port number, so that links remain intact.
  • Page 163 Alphabetical List of ColdFusion Tags Attribute Description timeout Optional. A value, in seconds. When a URL timeout is specified in the browser, the attribute setting takes precedence over the timeout ColdFusion Administrator timeout. The ColdFusion server then uses the lesser of the URL timeout and the timeout passed in the timeout attribute, so that the request always times out before or at the same time as the page times out.
  • Page 164 Chapter 2 ColdFusion Tags inserted into the query header. The query has all of the functionality of a standard object. cfquery HTTP POST tags can be nested inside a tag in a POST cfhttpparam cfhttp operation. The browser can be pointed to a URL that specifies a CGI executable or a ColdFusion page.
  • Page 165 Alphabetical List of ColdFusion Tags <body> <H3>cfhttp Example</H3> <P>This example shows the ability of cfhttp to pull the contents of a web page from the Internet, and shows how you can get the following information by using cfhttp variables: </P> <UL>...
  • Page 166: Cfhttpparam

    Chapter 2 ColdFusion Tags cfhttpparam Description Required for POST operations, is used to specify the parameters cfhttp cfhttpparam necessary to build a POST. cfhttp Category Internet Protocol tags Syntax <cfhttpparam name = "name" type = "type" value = "transaction type" file = "filename">...
  • Page 167 Alphabetical List of ColdFusion Tags <body> <H3>Output the passed variables</H3> <cfoutput> Form variable: ##form.form_test## <br>URL variable: ##URL.url_test## <br>Cookie variable: ##Cookie.cookie_test## <br>CGI variable: ##CGI.cgi_test## </cfoutput> </body> </html> ")#</cfoutput> <H3>For cfhttpparam code, see right frame</H3> <!--- <P> <cfhttp method = "POST" url = "http://localhost/someotherfile.cfm"> <cfhttpparam name = "form_test"...
  • Page 168: Cfif/Cfelseif/Cfelse

    Chapter 2 ColdFusion Tags cfif/cfelseif/cfelse Description Used with lets you create simple and compound cfelse cfelseif cfif conditional statements in CFML. The value in the tag can be any expression. cfif Category Flow-control tags Syntax <cfif expression> HTML and CFML tags <cfelseif>...
  • Page 169 Alphabetical List of ColdFusion Tags <P>If you want more than one condition to be the case, ask for a list of the centers in San Diego <B>OR</B> Santa Ana. If the center does not follow this condition, use cfelse to show only the names and cities of the other centers.
  • Page 170: Cfimpersonate

    Chapter 2 ColdFusion Tags cfimpersonate Description Lets you impersonate a user defined in a security context that is defined in Advanced Security. ColdFusion Server enforces the privileges and restrictions configured for the user with the Advanced Security rules. Category Web application framework tags Syntax <cfimpersonate securityContext = "SecurityContext"...
  • Page 171 Alphabetical List of ColdFusion Tags of the ColdFusion Administrator. Therefore, there is no need to make multiple isAuthorized calls in the code to protect each resource. For more information, see Advanced ColdFusion Administration. Example <!--- This example shows the use of cfimpersonate to impersonate a person with the user name Bill and the password BJ4YE.--->...
  • Page 172: Cfinclude

    Chapter 2 ColdFusion Tags cfinclude Description Lets you embed references to ColdFusion pages in CFML. You can embed cfinclude tags recursively. For an additional method of encapsulating CFML, see cfmodule on page 197. Category Page processing tags Syntax <cfinclude template = "template_name"> See also cfcache, cfflush, cfheader, cfhtmlhead, cfsetting, cfsilent...
  • Page 173: Cfindex

    Alphabetical List of ColdFusion Tags cfindex Description Populates collections with indexed data. The tags cfindex cfsearch encapsulate the Verity indexing and searching utilities. Verity collections can be populated from text files in a directory you specify, or from a query generated by a ColdFusion query.
  • Page 174 Chapter 2 ColdFusion Tags Attribute Description type Optional. Specifies the type of entity being indexed. Default is CUSTOM. Valid entries are: file Indexes files. path Indexes all files in specified path that pass filter. extensions custom Indexes custom entities from a ColdFusion query. title Required if .
  • Page 175 Alphabetical List of ColdFusion Tags Attribute Description type Optional. Specifies the type of entity being indexed. Default is CUSTOM. Valid entries are: file Indexes files. path Indexes all files in specified path that pass filter. extensions custom Indexes custom entities from a ColdFusion query. title Required if .
  • Page 176 Chapter 2 ColdFusion Tags Attribute Description recurse Optional. Yes or No. Yes specifies, if type = "Path" , that directories below the path specified in are included in the indexing operation. external Optional. Yes or No. Yes indicates that the collection specified in was created outside of ColdFusion using native Verity collection indexing tools.
  • Page 177: Cfinput

    Alphabetical List of ColdFusion Tags cfinput Description Used inside to place radio buttons, checkboxes, or text boxes. Provides input cfform validation for the specified control type. Category Forms tags Syntax <cfinput type = "input_type" name = "name" value = "initial_value" required = "Yes"...
  • Page 178 Chapter 2 ColdFusion Tags Attribute Description validate Optional. Valid entries are: date Verifies US date entry in the form mm/dd/yyyy. eurodate Verifies European date entry in the form dd/mm/yyyy. time Verifies a time entry in the form hh:mm:ss. float Verifies a floating point entry. integer Verifies an integer entry.
  • Page 179 Alphabetical List of ColdFusion Tags Usage You can add standard and dynamic HTML tag attributes and values to the form tag by using the attribute. They are passed through cfinput passThrough ColdFusion to the browser in creating a form. If you specify a value in quotation marks, you must escape the quotation marks by doubling them, for example, passThrough = "readonly = "...
  • Page 180 Chapter 2 ColdFusion Tags validate = "integer" required = "No"> <!--- date validation ---> <P>Date Validation (enter a properly formatted date): <BR><cfinput type = "Text" name = "MyDate" message = "Please enter a correctly formatted date (dd/mm/yy)" validate = "date" required = "No">...
  • Page 181: Cfinsert

    Alphabetical List of ColdFusion Tags cfinsert Description Inserts records in data sources. Category Database manipulation tags Syntax <cfinsert dataSource = "ds_name" dbType = "type" dbServer = "dbms" dbName = "database name" tableName = "tbl_name" connectString = "connection string" tableOwner = "owner" tableQualifier = "tbl_qualifier"...
  • Page 182 Chapter 2 ColdFusion Tags Attribute Description dbServer Optional. For native database drivers and the SQLOLEDB provider, specifies the name of the database server computer. If specified, overrides the server specified in the data source. dbServer dbName Optional. The database name (Sybase System 11 driver and SQLOLEDB provider only).
  • Page 183 Alphabetical List of ColdFusion Tags tableName = "Comments" formFields = "Email,FromUser,Subject,MessText,Posted"> <H3><I>Your record was added to the database.</I></H3> </cfif> <!--- use a query to show the existing state of the database ---> <cfquery name = "GetComments" dataSource = "cfsnippets"> SELECT CommentID, EMail, FromUser, Subject, CommtType, MessText, Posted, Processed FROM Comments </cfquery>...
  • Page 184 Chapter 2 ColdFusion Tags <!--- dynamically determine today’s date ---> <input type = "hidden" name = "posted" value = "<cfoutput>#Now()#</ cfoutput>"> </PRE> <input type = "Submit" name = "" value = "insert my comment"> </form> </body> </html>...
  • Page 185: Cfldap

    Alphabetical List of ColdFusion Tags cfldap Description Provides an interface to LDAP (Lightweight Directory Access Protocol) directory servers like the Netscape Directory Server. For complete examples of usage, cfldap see Developing ColdFusion Applications. Category Internet Protocol tags Syntax <cfldap server = "server_name" port = "port_number"...
  • Page 186 Chapter 2 ColdFusion Tags Attribute Description action Optional. Specifies the LDAP action. Options : query (default) Returns LDAP entry information only. Requires name attributes. See Usage for more information. start attributes add Adds LDAP entries to the LDAP server. Requires attributes modify Modifies LDAP entries on an LDAP server, except the distinguished name...
  • Page 187 Alphabetical List of ColdFusion Tags Attribute Description filterFile Optional. Specifies the name of a filter file and of the stanza tag within the file that contains the LDAP filter string specification. You can specify an absolute pathname or a simple filename to identify the file. If you use a simple filename, looks for it in ColdFusion’s default LDAP cfldap...
  • Page 188 Chapter 2 ColdFusion Tags Attribute Description secure Optional. Identifies the type of security to employ, CFSSL_BASIC or CFSSL_CLIENT_AUTH, and additional information that is required by the specified security type. secure = "CFSSL_BASIC,certificate_db" secure = "CFSSL_CLIENT_AUTH, certificate_db,certificate_name, key_db,key_password" These fields have the following values: certificate_db The name of the certificate database file (in Netscape cert7.db format).
  • Page 189 Alphabetical List of ColdFusion Tags Usage If you use the Query creates a query object, allowing access to action cfldap information in the three query variables as described in the following table. Variable Names Description queryname.recordCount The number of records returned by the query. queryname.currentRow The current row of the query being processed by cfoutput...
  • Page 190 Chapter 2 ColdFusion Tags <!--- make the LDAP query ---> <cfldap server = "ldap.bigfoot.com" action = "query" name = "results" start = "cn = #name#,c = US" filter = "(cn = #name#)" attributes = "cn,o,l,st,c,mail,telephonenumber" sort = "cn ASC"> <!--- Display results ---> <CENTER>...
  • Page 191: Cflocation

    Alphabetical List of ColdFusion Tags cflocation Description Opens a ColdFusion page or HTML file. For example, you might use cflocation specify a standard message or response that you use in several ColdFusion applications. Use the attribute to verify client requests. addToken Category Flow-control tags...
  • Page 192: Cflock

    Chapter 2 ColdFusion Tags cflock Description Provides two types of locks to ensure the integrity of shared data: Exclusive lock Read-only lock An exclusive lock single-threads access to the CFML constructs in its body. Single-threaded access implies that the body of the tag can be executed by at most one request at a time.
  • Page 193 Alphabetical List of ColdFusion Tags Attribute Description throwOnTimeout Optional. Yes or No. Specifies how timeout conditions are handled. If the value is Yes, an exception is generated to provide notification of the timeout. If the value is No, execution continues past the tag.
  • Page 194 Chapter 2 ColdFusion Tags In the ColdFusion Administrator, the Locking page, under the Server section, lets you set characteristics of the locking schema according to scope. The following table shows which features are available for Server, Application, and Session scope. Feature Availability: Server Application Session...
  • Page 195 Alphabetical List of ColdFusion Tags occur. A deadlock is a state in which no request can execute the locked section of the page. All requests to the protected section of the page are blocked until there is a timeout. The following tables show two scenarios that cause deadlocks. Deadlock Scenario with Two Users User 1 User 2...
  • Page 196 Chapter 2 ColdFusion Tags Note You can take out any pair of lock/unlock steps if you do not have to lock a scope. For example, you can take out Steps 3 and 4 if you do not have to lock the server scope. Similar rules apply for named locks.
  • Page 197 Alphabetical List of ColdFusion Tags cfapplication tag. ----------------------------------------------------------------------> <cflock scope = "Application" Timeout = "30" type = "Exclusive"> <cfif NOT IsDefined("application.number")> <cfset application.number = 1> </cfif> </cflock> <cflock scope = "Application" timeout = "30" type = "readOnly"> <cfoutput> E-Turtleneck is proud to say that we have sold #application.number# turtlenecks to date.
  • Page 198 Chapter 2 ColdFusion Tags <P>Congratulations! You have just selected the longest wearing, most comfortable turtleneck in the world. Please indicate the color and size that you wish to buy.</P> <table cellspacing = "2" cellpadding = "2" border = "0"> <tr> <td>Select a color.</td>...
  • Page 199: Cflog

    Alphabetical List of ColdFusion Tags 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" thread = "thread ID yes or no" date = "date yes or no"...
  • Page 200 Chapter 2 ColdFusion Tags Attribute Description date Optional. Specifies whether to log the system date.Valid values are: (default) time Optional. Specifies whether to log the system time.Valid values are: (default) application Optional. Specifies whether to log the application name if one has been specified in a cfapplication tag.Valid values are: (default) Usage...
  • Page 201: Cfloop

    Alphabetical List of ColdFusion Tags cfloop Description Looping is a very powerful programming technique that lets you repeat a set of instructions or display output repeatedly until one or more conditions are met. supports five types of loops: cfloop Index Loop on page 184 Conditional Loop on page 186 Looping Over a Query on page 187 Looping Over a List on page 189...
  • Page 202 Chapter 2 ColdFusion Tags Index Loop Description An index loop repeats for a number of times determined by a range of numeric values. Index loops are known as FOR loops, as in "loop FOR this range of values. " Category Flow-control tags Syntax <cfloop index = "parameter_name"...
  • Page 203 Alphabetical List of ColdFusion Tags The result of this loop in a browser looks like this: The loop index is 1. The loop index is 2. The loop index is 3. The loop index is 4. The loop index is 5. Example 2 In this example, the variable is incremented for each iteration of the loop.
  • Page 204 Chapter 2 ColdFusion Tags Conditional Loop Description A conditional loop iterates over a set of instructions while 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 evaluates as FALSE. Conditional loops are known as WHILE loops, as in "loop WHILE this condition is true.
  • Page 205 Alphabetical List of ColdFusion Tags Looping Over a Query Description A loop over a query repeats for every record in the query record set. The cfloop results are just like a . During each iteration of the loop, the columns of the cfoutput current row are available for output.
  • Page 206 Chapter 2 ColdFusion Tags Example 3 The advantage of looping over a query is that you can use CFML tags that are not allowed in a . The following example combines the pages that are returned cfoutput by a query of a list of page names into one document, using the tag.
  • Page 207 Alphabetical List of ColdFusion Tags Looping Over a List Description Looping over a list lets you step through elements contained in a variable or value that is returned from an expression. In a list loop, the attribute specifies the index name of a variable to receive the next element of the list, and the attribute holds list...
  • Page 208 Chapter 2 ColdFusion Tags Looping Over a COM Collection or Structure Description attribute lets you loop over a structure or a COM/DCOM cfloop collection collection object: A COM/DCOM collection object is a set of similar items referenced as a group rather than individually.
  • Page 209 Alphabetical List of ColdFusion Tags <TD><B>Dept.</B></TD> </TR> <!--- In cfloop, use item to create a variable called person to hold value of key as loop runs ---> <cfloop collection = #Departments# item = "person "> <TR> <TD>#person#</TD> <TD>#StructFind(Departments, person)#</TD> </TR> </cfloop>...
  • Page 210: Cfmail

    Required. The sender of the e-mail message. This attribute may be either static ( ) or from = "support@macromedia.com" dynamic ( from = "#GetUser.EMailAddress#" Optional. Indicates addresses to copy the e-mail message to; "cc" stands for "carbon copy."...
  • Page 211 Alphabetical List of ColdFusion Tags Attribute Description type Optional. Specifies extended type attributes for the message. Currently, the only valid value for this attribute is "HTML". Specifying informs the receiving e-mail client type = "HTML" that the message has embedded HTML tags to be processed. This is only useful when sending messages to mail clients that support HTML.
  • Page 212 Chapter 2 ColdFusion Tags </head> <body bgcolor = silver> <H3>cfmail Example</H3> <P>This view-only example shows the use of cfmail. If your CFAS mail settings are configured successfully and the comments are removed, you will be able to use this code to send simple e-mail. <!--- <cfif IsDefined("form.mailto")>...
  • Page 213: Cfmailparam

    Alphabetical List of ColdFusion Tags cfmailparam Description Can either attach a file or add a header to a message. It is nested within a tag. cfmail You can use more than one tag within a tag. cfmailparam cfmail Category Internet Protocol tags Syntax <cfmail to = "recipient"...
  • Page 214 Chapter 2 ColdFusion Tags you think. <cfmailparam file = "c:\work\readme.txt"> <cfmailparam file = "c:\work\logo.gif"> </cfmail> </body> </html>...
  • Page 215: Cfmodule

    " " Identifies a subdirectory that Name.Name.Name... contains the custom tag page under the root directory for ColdFusion custom tags. For example: <cfmodule name = "macromedia.Forums40.GetUserOptions"> Identifies the page in the directory GetUserOptions.cfm under the root directory of CustomTags\macromedia\Forums40 the ColdFusion installation.
  • Page 216 Chapter 2 ColdFusion Tags Likewise, if the custom tag uses a tag to save its attributes, the cfassociate attributes passed with are saved as independent attribute attributeCollection values with no indication that the attributes are grouped into a structure by the custom tag’s caller.
  • Page 217 Alphabetical List of ColdFusion Tags x = 3 attributeCollection = ##attrcollection1## y = 4>")# </cfoutput> <p>The result: <cfoutput>#result#</cfoutput> </p> <!--- Call the tag with cfmodule with Name---> <cfmodule name = "myTag" x = "3" attributeCollection = #attrcollection1# y = "4"> <!--- show the code --->...
  • Page 218: Cfobject

    Chapter 2 ColdFusion Tags cfobject Description Lets you call methods in COM, CORBA, and JAVA objects. Note ColdFusion administrators can disable the tag using the Tag Restrictions cfobject page under ColdFusion Basic Security. On UNIX, does not support COM objects. cfobject cfobject types cfobject type = "com"...
  • Page 219 Alphabetical List of ColdFusion Tags cfobject type = "com" Description Lets you create and use Component Object Model (COM) objects. With this tag, you can invoke any automation server object type registered on a computer. You can use a utility like Microsoft’s OLEView to browse COM objects. OLEView, and information about COM and DCOM, can be found at Microsoft’s OLE Development web site http://www.microsoft.com.
  • Page 220 Chapter 2 ColdFusion Tags <body> <H3>cfobject (COM) Example</H3> <!--- Create a COM object as an inproc server (DLL). (class = prog-id) ---> <cfobject action = "Create" type = "COM" class = Allaire.DocEx1.1 name = "obj"> <!--- Call a method. Note that methods that expect no arguments should be called using empty parenthesis.
  • Page 221 NameService Specifies a period-delimited naming context context for the naming service, such as Macromedia.Department.Doc.empobject. name Required. Name for the object. An application uses it to reference the CORBA object’s methods and attributes. locale Optional.
  • Page 222 Chapter 2 ColdFusion Tags Example <cfobject type = "CORBA" context = "IOR" class = "c:\\myobject.ior" name = "GetName">...
  • Page 223 Alphabetical List of ColdFusion Tags cfobject type = "java" Description Lets you create and use JAVA objects, and by extension EJB objects. Category Extensibility tags Syntax <cfobject action = "Create" type = "Java" class = "Java class" name = "object name"> See also cfcollection, cfexecute, cfgraph, cfindex, cfreport, cfsearch, cfservlet,...
  • Page 224 Chapter 2 ColdFusion Tags Example 1 <!--------------------------------------------------------------------- Example of a Java Object This 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"...
  • Page 225: Cfoutput

    Alphabetical List of ColdFusion Tags cfoutput Description Displays the results of a database query or other operation. To nest tags, cfoutput see the "Usage" section. Category Data output tags Syntax <cfoutput query = "query_name" group = "query_column" groupCaseSensitive = "Yes" or "No" startRow = "start_row"...
  • Page 226 Chapter 2 ColdFusion Tags SELECT Dept_ID, CorName, CorLevel FROM courseList ORDER by Dept_ID, CorLevel, CorName </cfquery> <html> <head> <title>cfoutput</title> </head> <body> <H3>cfoutput Example</H3> <P>cfoutput simply tells ColdFusion Server to begin processing, and then to hand back control of page rendering to the web server. <P>For example, to show today’s date, you could write #DateFormat("#Now()#").
  • Page 227: Cfparam

    Alphabetical List of ColdFusion Tags cfparam Description Tests for a parameter’s existence, tests its data type, and provides a default value if one is not assigned. Category Variable manipulation tags Syntax <cfparam name = "param_name" type = "data_type"> default = "value"> See also cfcookie, cfregistry, cfsavecontent, cfschedule, cfset...
  • Page 228 Chapter 2 ColdFusion Tags continues and the value is not changed. If the variable does not exist, it is created and set to the value of the attribute. default Example <!--- This example shows how cfparam operates ---> <cfparam name = "storeTempVar" default = "my default value"> <cfparam name = "tempVar"...
  • Page 229: Cfpop

    Alphabetical List of ColdFusion Tags cfpop Description Retrieves and deletes e-mail messages from a POP mail server. Category Internet Protocol tags Syntax <cfpop server = "servername" port = "port_number" username = "username" password = "password" action = "action" name = "queryname" messageNumber = "number"...
  • Page 230 Chapter 2 ColdFusion Tags Attribute Description messageNumber Optional. Specifies the message number(s) for the given action. is required for messageNumber action = . If it is provided for "delete" action = , only "getHeaderOnly" action = "getAll" referenced messages are retrieved. If it is omitted for , all action = "getHeaderOnly"...
  • Page 231 Alphabetical List of ColdFusion Tags Message header and body columns The following table lists the message header and body columns returned by cfpop when you specify the attribute as either action getHeaderOnly getAll Column Name getHeaderOnly returns getAll returns queryname.date queryname.from queryname.messagenumber queryname.replyto...
  • Page 232 Chapter 2 ColdFusion Tags <P>Simply uncomment this code and run with a mail-enabled CF Server to see this feature in action. <!--- <cfif IsDefined("form.server ")> <!--- make sure server, username are not empty ---> <cfif form.server is not "" and form.username is not ""> <cfpop server = "#server# "...
  • Page 233: Cfprocessingdirective

    Alphabetical List of ColdFusion Tags cfprocessingdirective Description Suppresses extra white space and other output, produced by CFML within the tag’s scope. Category Data output tags Syntax <cfprocessingdirective suppressWhiteSpace = "Yes" or "No"> … any CFML tags here … </cfprocessingdirective> See also cfcol, cfcontent, cfoutput, cftable Attributes...
  • Page 234: Cfprocparam

    Chapter 2 ColdFusion Tags cfprocparam Description Specifies parameter information, including type, name, value, and length. The tag is nested within a tag. cfprocparam cfstoredproc Category Database manipulation tags Syntax <cfprocparam type = "IN or OUT or INOUT" variable = "variable name" dbVarName = "DB variable name"...
  • Page 235 Alphabetical List of ColdFusion Tags Attribute Description CFSQLType Required. The SQL type that the parameter (any type) is bound to. The CFSQLTypes are as follows: CF_SQL_BIGINT CF_SQL_BIT CF_SQL_CHAR CF_SQL_DATE CF_SQL_DECIMAL CF_SQL_DOUBLE CF_SQL_FLOAT CF_SQL_IDSTAMP CF_SQL_INTEGER CF_SQL_LONGVARCHAR CF_SQL_MONEY CF_SQL_MONEY4 CF_SQL_NUMERIC CF_SQL_REAL CF_SQL_REFCURSOR CF_SQL_SMALLINT CF_SQL_TIME CF_SQL_TIMESTAMP...
  • Page 236 Chapter 2 ColdFusion Tags Example This example shows an Oracle 8 PL/SQL stored procedure, and the CFML code used to invoke it. It makes use of Oracle 8’s support of the REFERENCE CURSOR type. The following package Foo_Data houses a procedure refcurproc that declares two output parameters as REFERENCE CURSORS.
  • Page 237 Alphabetical List of ColdFusion Tags </cfstoredproc> <b>The first result set:</b><br> <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"...
  • Page 238: Cfprocresult

    Chapter 2 ColdFusion Tags cfprocresult Description Specifies a result set name that other ColdFusion tags, such as cfoutput , use to access the result set. It also lets you optionally identify which of the cftable stored procedure’s result sets to return. The tag is nested within a cfprocresult tag.
  • Page 239 Alphabetical List of ColdFusion Tags <!--- Close the cfstoredproc tag ---> </cfstoredproc> <cfoutput> The output param value: ’#foo#’ <br> </cfoutput> <h3>The Results Information</h3> <cfoutput query = RS1>#name#,#DATE_COL# <br> </cfoutput> <P> <cfoutput> <hr> <P>Record Count: #RS1.recordCount# >p>Columns: #RS1.columnList# <hr> </cfoutput> <cfoutput query = RS3>#col1#,#col2#,#col3# <br>...
  • Page 240: Cfquery

    Chapter 2 ColdFusion Tags cfquery Description Passes SQL statements to a data source. Not limited to queries. Category Database manipulation tags Syntax <cfquery name = "query_name" dataSource = "ds_name" dbType = "type" dbServer = "dbms" dbName = "database name" connectString = "connection string" username = "username"...
  • Page 241 Alphabetical List of ColdFusion Tags Attribute Description dbType Optional. The database driver type: Connect to an ODBC data source that is not defined in the dynamic ColdFusion Administrator. When you use this attribute value, you must specify all the ODBC connection information using the connectstring attribute.
  • Page 242 Chapter 2 ColdFusion Tags Attribute Description dbType Optional. The database driver type: Connect to an ODBC data source that is not defined in the dynamic ColdFusion Administrator. When you use this attribute value, you must specify all the ODBC connection information using the connectstring attribute.
  • Page 243 Alphabetical List of ColdFusion Tags Attribute Description maxRows Optional. Specifies the maximum number of rows to return in the record set. attribute accepts an argument of , which causes maxRows cfquery to return all rows in the query object. blockFactor Optional.
  • Page 244 Chapter 2 ColdFusion Tags Usage In addition to returning data from a ColdFusion data source, the tag also cfquery returns information about the query. returns the time it cfquery.ExecutionTime took the query to execute in milliseconds. tag creates a query object, providing information in query variables as cfquery described in the following table.
  • Page 245 Alphabetical List of ColdFusion Tags <!--- 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#">...
  • Page 246: Cfqueryparam

    Chapter 2 ColdFusion Tags cfqueryparam Description Checks the data type of a query parameter. The tag is nested within a cfqueryparam tag. It is embedded within the query SQL statement. If you specify its cfquery optional parameters, also performs data validation. cfqueryparam Category Database manipulation tags...
  • Page 247 Alphabetical List of ColdFusion Tags Attributes Attribute Description value Required. Specifies the actual value that ColdFusion passes to the right of the comparison operator in a where clause. CFSQLType Optional. The SQL type that the parameter (any type) will be bound to.
  • Page 248 Chapter 2 ColdFusion Tags Usage Note For data, you must specify the attribute to ensure that maximum length maxlength validation is enforced. tag does the following: cfqueryparam Allows the use of SQL bind parameters Allows long text fields to be updated from an SQL statement Improves performance The ColdFusion ODBC, DB2, Informix, Oracle 7 and Oracle 8 drivers support SQL bind parameters.
  • Page 249 Alphabetical List of ColdFusion Tags <body> <h3>cfqueryparam Example</h3> <cfset Course_ID = 12> <cfquery name = "getFirst" dataSource = "cfsnippets"> SELECT * FROM courses WHERE Course_ID = <cfqueryPARAM value = "#Course_ID#" CFSQLType = "CF_SQL_INTEGER"> </cfquery> <cfoutput query = "getFirst"> <P>Course Number: #Course_Num#<br> Description: #descript# </P>...
  • Page 250 Chapter 2 ColdFusion Tags <html> <head> <title>cfqueryparam Example</title> </head> <body> <h3>cfqueryparam Example with Bad String Input</h3> <cfset LastName = "Peterson; DELETE employees WHERE LastName = ’Peterson’"> <---------------------------------------------------------------------- For string input, specify the maxLength attribute for validation. ----------------------------------------------------------------------> <cfquery name = "getFirst" dataSource = "cfsnippets"> SELECT * FROM employees WHERE LastName = <cfqueryPARAM value = "#LastName#"...
  • Page 251: Cfregistry

    Alphabetical List of ColdFusion Tags cfregistry Description Reads, writes, and deletes keys and values in the system registry. The cfregistry is supported on all platforms, including Linux, Solaris, and HP-UX. Note In the ColdFusion Administrator, the security settings on the Tag Restrictions page under ColdFusion Basic Security may prevent from executing.
  • Page 252 Chapter 2 ColdFusion Tags cfregistry action = "getAll" Description Used with the action to return all registry keys and values defined in a getAll branch. You can access the values as you would any record set. Category Variable manipulation tags Syntax <cfregistry action = "getAll"...
  • Page 253 Alphabetical List of ColdFusion Tags branch = "HKEY_LOCAL_MACHINE\Software\Microsoft\Java VM" type = "Any" name = "RegQuery"> <P> <H1>cfregistry action = "getAll"</H1> <cftable query = "RegQuery" colHeaders HTMLTable border = "Yes"> <cfcol header = "<B>Entry</b>" width = "35" text = "#RegQuery.Entry#"> <cfcol header = "<B>Type</b>" width = "10" text = "#RegQuery.type#"> <cfcol header = "<B>Value</b>"...
  • Page 254 Chapter 2 ColdFusion Tags cfregistry action = "get" Description Used with the Get action to access a registry value and store it in a ColdFusion variable. Category Variable manipulation tags Syntax <cfregistry action = "get" branch = "branch" entry = "key or value" variable = "variable"...
  • Page 255 Alphabetical List of ColdFusion Tags cfregistry action = "set" Description Used with the Set action to add a registry key, add a new value, or update value data. Category Variable manipulation tags Syntax <cfregistry action = "set" branch = "branch" entry = "key or value"...
  • Page 256 Chapter 2 ColdFusion Tags cfregistry action = "delete" Description Used with the action to delete a registry key or value. delete Category Variable manipulation tags Syntax <cfregistry action = "delete" branch = "branch" entry = "keyorvalue"> See also cfcookie, cfparam, cfsavecontent, cfschedule, cfset Attributes Attribute...
  • Page 257: Cfreport

    Alphabetical List of ColdFusion Tags cfreport Description Runs a predefined Crystal Reports report. Category Extensibility tags Syntax <cfreport report = "report_path" orderBy = "result_order" username = "username" password = "password" formula = "formula"> </cfreport> See also cfcollection, cfexecute, cfgraph, cfindex, cfobject, cfsearch, cfservlet, cfwddx Attributes...
  • Page 258 Chapter 2 ColdFusion Tags <P>This example would run a report called "monthlysales.rpt " and pass it an optional filter condition to show only the information for a certain subset of the report. <cfreport report = ’/reports/monthlysales.rpt’> {Departments.Department} = ‘International’ </cfreport> <P>Substitute your own report files and filters for this code and cfreport can place your existing Crystal Reports into web pages.
  • Page 259: Cfrethrow

    Alphabetical List of ColdFusion Tags cfrethrow Description Rethrows the currently active exception. Preserves the exception’s cfcatch type information. cfcatch.tagContext Category Exception handling tags Syntax <cfrethrow> See also cferror, cfthrow, cftry cfcatch Usage Use the tag within a block. This tag is useful in error handling cfrethrow cfcatch code when the error handler is not designed to handle an error that it catches.
  • Page 260 Chapter 2 ColdFusion Tags <cfloop collection = #cfcatch# item = "c"> <br><cfif IsSimpleValue(cfcatch[c])>#c# = #cfcatch[c]#</cfif> </cfloop> </cfoutput> </cfcatch> </cftry> </body> </html>...
  • Page 261: Cfsavecontent

    Alphabetical List of ColdFusion Tags cfsavecontent Description Saves the generated content inside the tag body in a variable. Category Variable manipulation tags Syntax <cfsavecontent variable = "variable name"> content </cfsavecontent> See also cfcookie, cfparam, cfregistry, cfschedule, cfset Attributes Attribute Description variable Required.
  • Page 262: Cfschedule

    Chapter 2 ColdFusion Tags cfschedule Description Provides a programmatic interface to the ColdFusion scheduling engine. You can run a specified page at scheduled intervals with the option to write out static HTML pages. This lets you offer users access to pages that publish data, such as reports, without forcing users to wait while a database transaction is performed in order to populate the data on the page.
  • Page 263 Alphabetical List of ColdFusion Tags Attributes Attribute Description action Required. Valid entries are: – Deletes task specified by delete task – Creates a task if one does not exist update – Executes task specified by task task Required. The name of the task to delete, update, or run. operation Required when creating tasks with action = "update"...
  • Page 264 Chapter 2 ColdFusion Tags Attribute Description port Optional. The port number on the server from which the task is being scheduled. Default is 80. When used with , the resolveURL URLs of retrieved documents that specify a port number are automatically resolved to preserve links in the retrieved document.
  • Page 265: Cfscript

    Alphabetical List of ColdFusion Tags cfscript Description Encloses a code segment containing cfscript Category Web application framework tags Syntax <cfscript> cfscript code goes here </cfscript> See also cfapplication, cflock, cfassociate, cfmodule, cfauthenticate, cfimpersonate Usage to perform processing in instead of CFML. Note the cfscript cfscript following:...
  • Page 266 Chapter 2 ColdFusion Tags <cfoutput> <P>twice #x# is #z#. <P>Your string value was: <B><I>#StringVar#</I></B> </cfoutput> <cfelse>...
  • Page 267: Cfsearch

    Alphabetical List of ColdFusion Tags cfsearch Description Executes searches against data indexed in Verity collections. Collections can be created by calling the tag, by using the ColdFusion Administrator, or cfcollection through native Verity indexing tools. Collections are populated with data either with tag, or externally, using native Verity indexing tools.
  • Page 268 Chapter 2 ColdFusion Tags Attribute Description external Optional. Yes or No. Yes indicates that the collection you are searching was created outside of ColdFusion using native Verity indexing tools. The default is No. language Optional. To use the attribute you must have the ColdFusion language International Search Pack installed.
  • Page 269 Alphabetical List of ColdFusion Tags Variable Description summary Returns the contents of the automatic summary generated by . The default summarization selects the best three cfindex matching sentences, up to a maximum of 500 characters. recordCount Returns the number of records returned in the record set. currentRow Returns the current row being processed by cfoutput...
  • Page 270 Chapter 2 ColdFusion Tags <!--- print out the search results ---> <cfoutput> <H2>#form.type# Search Results</H2> <P>#SearchSnippets.recordCount# "hit <cfif SearchSnippets.recordcount is not 1>s</cfif>" found out of #SearchSnippets.RecordsSearched# total record <cfif SearchSnippets.recordcount is not 1>s</cfif> searched. <P><I><B>#form.maxrows# records returned ...</B></I> <cftable query = "SearchSnippets" maxRows = "#maxrows#" startRow = "1"...
  • Page 271: Cfselect

    Alphabetical List of ColdFusion Tags cfselect Description Used inside lets you construct a drop-down list box form control. cfform cfselect You can populate the drop-down list box from a query, or using the tag. Use option elements to populate lists. The syntax for the tag is the same as for its option option...
  • Page 272 Chapter 2 ColdFusion Tags Attribute Description display Optional. The query column displayed. Defaults to the value of value Used with the attribute. query passThrough Optional. HTML attributes that are not explicitly supported by . If you specify an attribute and its value, the attribute and its cfselect value are passed to the HTML code that is generated for the tag.
  • Page 273 Alphabetical List of ColdFusion Tags <html> <head> <title> cfselect Example </title> </head> <body> <H3>cfselect Example</H3> <!--- Use cfform when using other cfinput tools ---> <cfform action = "cfselect.cfm" method = "POST" enableCAB = "Yes"> <!--- Use cfselect to present the contents of the query by column ---> <H3>cfselect Presentation of Data</H3>...
  • Page 274: Cfservlet

    Chapter 2 ColdFusion Tags cfservlet Description Executes a Java servlet on a JRun engine. This tag is used in conjunction with the tag, which passes data to the servlet. cfserletparam Category Java servlet and Java object tags Syntax <cfservlet code = "class name of servlet" jrunProxy = "proxy server"...
  • Page 275 Alphabetical List of ColdFusion Tags Usage The syntax of the tag is consistent with the HTML markup servlet and cfservlet param tags used by some Web servers to invoke Java servlets from .shtml pages in Server-Side Includes (SSI). Variable Name Description cfservlet.output Inline text output of the servlet is directed...
  • Page 276: Cfservletparam

    Chapter 2 ColdFusion Tags cfservletparam Description A child of . It passes data to the servlet. Each tag within cfservlet cfservletparam block passes a separate piece of data to the servlet. cfservlet Category Java servlet and Java object tags Syntax <cfservlet ...>...
  • Page 277 Alphabetical List of ColdFusion Tags reference to the servlet. Within the servlet, the variable data is made available as servlet attributes in the form of Java objects. On the Java side, the data can be manipulated, or changed, changing the value of the associated ColdFusion variable. When used in this mode, the attribute represents the name of the servlet name...
  • Page 278: Cfset

    Chapter 2 ColdFusion Tags cfset Description Define a ColdFusion variable. If the variable exists, resets it to the specified cfset value. Category Variable manipulation tags Syntax <cfset variable_name = expression> See also cfcookie, cfparam, cfregistry, cfsavecontent, cfschedule Arrays Usage The following example assigns a new array to the variable "months". <cfset months = ArrayNew(1)>...
  • Page 279 Alphabetical List of ColdFusion Tags Example <!--- This example shows how to use cfset ---> <cfquery name = "GetMessages" dataSource = "cfsnippets"> SELECT FROM Messages </cfquery> <html> <head> <title> cfset Example </title> </head> <body bgcolor = silver> <H3>cfset Example</H3> <P>cfset allows you to set and reassign values to local or global variables within a CF template.
  • Page 280: Cfsetting

    Chapter 2 ColdFusion Tags cfsetting Description Controls various aspects of page processing, such as the output of HTML code in pages. One benefit of this option is managing whitespace that can occur in output pages served by ColdFusion. Category Page processing tags Syntax <cfsetting enableCFoutputOnly = "Yes"...
  • Page 281 Alphabetical List of ColdFusion Tags <cfoutput> <P>Text within cfoutput is always shown </cfoutput> <cfsetting enableCFoutputOnly = "No"> <cfoutput> <P>Text within cfoutput is always shown </cfoutput> </body> </html>...
  • Page 282: Cfsilent

    Chapter 2 ColdFusion Tags cfsilent Description Suppresses all output that is produced by the CFML within the tag’s scope. Category Page processing tags Syntax <cfsilent> See also cfcache, cfflush, cfheader, cfhtmlhead, cfinclude, cfsetting Example <html> <head> <title>cfsilent</title> </head> <BASEFONT face = "Arial, Helvetica" size = 2> <body bgcolor = "#FFFFD5">...
  • Page 283: Cfslider

    Alphabetical List of ColdFusion Tags cfslider Description Used inside lets you place a slider control in a ColdFusion form. A cfform cfslider slider control is like a sliding volume control. The slider groove is the area over which the slider moves. Category Forms tags Syntax...
  • Page 284 Chapter 2 ColdFusion Tags Attribute Description refreshLabel Optional. Yes or No. If Yes, the label is not refreshed when the slider is moved. Default is Yes. This attribute has been deprecated and is non-functional. imgStyle This attribute has been deprecated and is non-functional. range Optional.
  • Page 285 Alphabetical List of ColdFusion Tags Attribute Description tickMarkMajor Optional. Yes to render major tickmarks in the slider scale. No for no major tickmarks. Default is No. Major tick marks are the marks that appear at the intervals specified by the Scale attribute. tickMarkMinor Optional.
  • Page 286 Chapter 2 ColdFusion Tags Attribute Description font Optional. Font name for label text. fontSize Optional. Font size for label text measured in points. italic Optional. Yes for italicized label text, No for normal text. Default is bold Optional. Enter Yes for bold label text, No for medium text. Default is notSupported Optional.
  • Page 287 Alphabetical List of ColdFusion Tags Try again! </cfif> <cfform action = "cfslider.cfm" method = "POST" enablecab = "Yes"> 1 <cfslider name = "mySlider" value = "12" label = "Actual Slider Value " range = "1,100" align = "BASELINE" message = "Slide the bar to get a value between 1 and 100" height = "20"...
  • Page 288: Cfstoredproc

    Chapter 2 ColdFusion Tags cfstoredproc Description Executes stored procedures by an ODBC or native connection to 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" dbType = "type"...
  • Page 289 Alphabetical List of ColdFusion Tags Attribute Description dbType Optional. The database driver type: Connect to an ODBC data source that is not defined in dynamic the ColdFusion Administrator. When you use this attribute value, you must specify all the ODBC connection information using the connectstring attribute.
  • Page 290 Chapter 2 ColdFusion Tags Attribute Description providerDSN Optional. Data source name for the COM provider (OLE-DB only). debug Optional. Yes or No. Specifies whether debug info will be listed on each statement. Default is No. returnCode Optional. Yes or No. Specifies whether the tag populates with the status code returned by the cfstoredproc statusCode...
  • Page 291 Alphabetical List of ColdFusion Tags <cfoutput> The output param value: ’#foo#’ <br> </cfoutput> <h3>The Results Information</h3> <cfoutput query = RS1>#name#,#DATE_COL# <br> </cfoutput> <P> <cfoutput> <hr> <P>Record Count: #RS1.recordCount# >p>Columns: #RS1.columnList# <hr> </cfoutput> <cfoutput query = RS3>#col1#,#col2#,#col3# <br> </cfoutput> <P> <cfoutput> <hr>...
  • Page 292: Cfswitch/Cfcase/Cfdefaultcase

    Chapter 2 ColdFusion Tags cfswitch/cfcase/cfdefaultcase Description Used with . Evaluates a passed expression and passes cfcase cfdefaultcase control to the tag that matches the expression result. You can optionally code cfcase tag, which receives control if there is no matching tag value.
  • Page 293 Alphabetical List of ColdFusion Tags <!--- query to get some information ---> <cfquery name = "GetEmployees" dataSource = "cfsnippets"> SELECT Emp_ID, FirstName, LastName, EMail, Phone, Department FROM Employees </cfquery> <html> <head> <title> cfswitch Example </title> </head> <body bgcolor = silver> <H3>cfswitch Example</H3>...
  • Page 294: Cftable

    Chapter 2 ColdFusion Tags cftable Description Builds a table in a ColdFusion page. Use the tag to define table column and cfcol row characteristics. The tag renders data either as preformatted text, or, with cftable attribute, as an HTML table. Use to create tables if you don’t HTMLTable cftable...
  • Page 295 Alphabetical List of ColdFusion Tags <!--- This query selects employee information from the cfsnippets datasource ---> <cfquery name = "GetEmployees" dataSource = "cfsnippets"> SELECT Emp_ID, FirstName, LastName, EMail, Phone, Department FROM Employees </cfquery> <html> <head> <title>cftable Example</title> </head> <body> <H3>cftable Example</H3> <!--- Note the use of the HTMLTable attribute to display the cftable as an HTML table, rather simply as PRE formatted information --->...
  • Page 296: Cftextinput

    Chapter 2 ColdFusion Tags cftextinput Description Lets you place a single-line text entry box in a . The tag also gives you control cfform over font characteristics. Category Forms tags Syntax <cftextinput name = "name" value = "text" required = "Yes" or "No" range = "min_value, max_value"...
  • Page 297 Alphabetical List of ColdFusion Tags Attribute Description validate Optional. Valid entries are: date Verifies US date entry in the form mm/dd/yy. eurodate Verifies valid European date entry in the form dd/mm/ yyyy. time Verifies a time entry in the form hh:mm:ss. float Verifies a floating point entry.
  • Page 298 Chapter 2 ColdFusion Tags Attribute Description align Optional. Alignment value. Valid entries are: Left Bottom Baseline TextTop AbsBottom Middle AbsMiddle Right bgColor Optional. Background color of the control. Valid entries are: black magenta cyan orange darkgray pink gray white lightgray yellow A hex value can also be entered in the form: bgColor = "##xxxxxx"...
  • Page 299 Alphabetical List of ColdFusion Tags Example <!--- This example shows the use of cftextinput ---> <html> <head> <title> cftextinput Example </title> </head> <body bgcolor = silver> <H3>cftextinput Example</H3> cftextinput can be used to provide simple validation for text fields in cfform and to have control over font information displayed in cfform input boxes for text.
  • Page 300: Cfthrow

    Chapter 2 ColdFusion Tags cfthrow Description tag raises a developer-specified exception that can be caught with cfthrow tag having any of the following type specifications: cfcatch cfcatch type = "custom_type" cfcatch type = "Application" cfcatch type = "Any" Category Exception handling tags Syntax <cfthrow type = "exception_type "...
  • Page 301 Alphabetical List of ColdFusion Tags Example <!--- This example shows the use of cfthrow. ---> <html> <head> <title> cfthrow Example </title> </head> <BASEFONT face = "Arial, Helvetica" size = 2> <body bgcolor = "#FFFFD5"> <H3>cfthrow Example</H3> <!--- open a cftry block ---> <cftry>...
  • Page 302: Cftransaction

    Chapter 2 ColdFusion Tags cftransaction Description Groups multiple queries into a single unit. The tag provides commit cftransaction and rollback processing. See Usage for details. Category Database manipulation tags Syntax <cftransaction action = "begin" or "commit" or "rollback" isolation = "Read_Uncommitted" or "Read_Committed"...
  • Page 303 Alphabetical List of ColdFusion Tags Example <!--- This example shows the use of cftransaction ---> <html> <head> <title>cftransaction Example</title> </head> <body> <H3>cftransaction Example</H3> <P>cftransaction can be used to group multiple queries using cfquery into a single business event. Changes to data requested by these queries can be committed on the basis of the success or failure of the query by using the actions commit and rollback, respectively.
  • Page 304 Chapter 2 ColdFusion Tags <cfquery name = ’insertNewCourseToList’ dataSource = ’cfsnippets’> INSERT INTO CourseList (CorNumber, CorDesc, Dept_ID, CorName, CorLevel, LastUpdate) VALUES (’#myNumber#’, ’#myDescription#’, ’#myDepartment#’, ’#myDescription#’, ’#myCorLevel#’, #Now()#) </cfquery> <!------------------------------------------------------------------ Rolls back the pending insertion if database exception is caught. -------------------------------------------------------------------> <cfcatch type = "DATABASE">...
  • Page 305: Cftree

    Alphabetical List of ColdFusion Tags cftree Description Lets you put a tree control in a . Validates user selections. Tree items are cfform created with tags inside the tag block. You can use a ColdFusion cftreeitem cftree query to supply data to the tree. Category Forms tags Syntax...
  • Page 306 Chapter 2 ColdFusion Tags Attribute Description appendKey Optional. Yes or No. When used with href , Yes passes the CFTREEITEMKEY variable along with the value of the selected tree item in the URL to the application page specified in the attribute.
  • Page 307 Alphabetical List of ColdFusion Tags Attribute Description align Optional. Alignment value. Options are: Left Bottom Baseline TextTop AbsBottom Middle AbsMiddle Right border Optional. Places a border around the tree. Default is Yes. hScroll Optional. Permits horizontal scrolling. Default is Yes vScroll Optional.
  • Page 308 Chapter 2 ColdFusion Tags <cfif #employeeNames# is not ""> = ’#employeeNames#’</cfif> </cfquery> <html> <head> <title> cftree Example </title> </head> <body> <H3>cftree Example</H3> <!--- Use cfform when using other cfinput tools ---> <cfform action = "cftree.cfm" method = "POST" enableCAB = "Yes"> <!--- Use cfselect to present the contents of the query by column --->...
  • Page 309 Alphabetical List of ColdFusion Tags <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"...
  • Page 310: Cftreeitem

    Chapter 2 ColdFusion Tags cftreeitem Description Populates a tree control, created with , with elements. You can use the cftree values supplied with ColdFusion or reference your own icons. Category Forms tags Syntax <cftreeitem value = "text" display = "text" parent = "parent_name"...
  • Page 311 Alphabetical List of ColdFusion Tags Attribute Description Optional. Image name or filename for the tree item. When populating with data from a , images or filenames for each cftree cfquery level of the tree are specified in a comma-separated list. The default image name is "Folder.
  • Page 312 Chapter 2 ColdFusion Tags Attribute Description queryAsRoot Optional. Yes or No. Defines specified query as the root level. As in Example 1, this option avoids having to create an additional parent cftreeitem If you specify a text string other than "Yes" or "No", the tag uses the text as the root text.
  • Page 313 Alphabetical List of ColdFusion Tags <!--- Use cfselect to present the contents of the query by column ---> <H3>cfselect Presentation of Data</H3> <H4>Click on an employee’s last name and hit "see information for this employee" to see expanded information.</H4> <cfselect name = "EmployeeNames" message = "Select an Employee Name" size = "#getEmployees.recordcount#"...
  • Page 314: Cftry Cfcatch

    Chapter 2 ColdFusion Tags cftry cfcatch Description Used with one or more tags, the tag lets you catch and process cfcatch cftry exceptions in ColdFusion pages. Exceptions include events that disrupt the normal flow of instructions in a ColdFusion page, such as failed database operations, missing include files, and developer-specified events.
  • Page 315 Alphabetical List of ColdFusion Tags Applications can optionally use the tag to raise custom exceptions. Such cfthrow exceptions are caught with any of the following type specifications: type = "custom_type" type = "Application" type = "Any" The custom_type type designates the name of a user-defined type specified with a tag.
  • Page 316 Chapter 2 ColdFusion Tags SQLSTATE only. The SQLState associated with this type = "database" exception. Database drivers typically provide error codes to assist diagnosis of failing database operations. If no SQLState value was provided, the value of SQLSTATE is -1. ErrNumber only.
  • Page 317 Alphabetical List of ColdFusion Tags ColdFusion Advanced Exception Types (continued) COM.Allaire.ColdFusion.HTTPGatewayTimeout COM.Allaire.ColdFusion.HTTPGone COM.Allaire.ColdFusion.HTTPMethodNotAllowed COM.Allaire.ColdFusion.HTTPMovedPermanently COM.Allaire.ColdFusion.HTTPMovedTemporarily COM.Allaire.ColdFusion.HTTPMultipleChoices COM.Allaire.ColdFusion.HTTPNoContent COM.Allaire.ColdFusion.HTTPNonAuthoritativeInfo COM.Allaire.ColdFusion.HTTPNotAcceptable COM.Allaire.ColdFusion.HTTPNotFound COM.Allaire.ColdFusion.HTTPNotImplemented 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...
  • Page 318 Chapter 2 ColdFusion Tags Note To see the tag stack displayed by TagContext, use the ColdFusion Administrator to enable the CFML stack trace. Under Debugging in the ColdFusion Administrator, select the checkbox next to "Enable CFML stack trace. " Example <!--- cftry example, using TagContext to display the tag stack.
  • Page 319: Cfupdate

    Alphabetical List of ColdFusion Tags cfupdate Description Updates existing records in data sources. Category Database manipulation tags Syntax <cfupdate dataSource = "ds_name" dbType = "type" dbServer = "dbms" dbName = "database name" connectString = "connection string" tableName = "table_name" tableOwner = "name" tableQualifier = "qualifier"...
  • Page 320 Chapter 2 ColdFusion Tags Attribute Description dbServer Optional. For native database drivers and the SQLOLEDB provider, specifies the name of the database server computer. If specified, overrides the server specified in the data source. dbServer dbName Optional. The database name (Sybase System 11 driver and SQLOLEDB provider only).
  • Page 321 Alphabetical List of ColdFusion Tags <cfupdate dataSource = "cfsnippets" tableName = "courses" formFields = "course_ID,Course_Num,Descript"> </cfif> <!--- perform a query to reflect any updated information if course_ID is passed through a url, we are selecting a record to update ... select only that record with the WHERE clause --->...
  • Page 322 Chapter 2 ColdFusion Tags <cfcol text = "#Course_Num#" width = "4" header = "Course Number"> <cfcol text = "#Descript#" width = 100 header = "Course Description"> </cftable> </cfif> </body> </html>...
  • Page 323: Cfwddx

    Alphabetical List of ColdFusion Tags cfwddx Description Serializes and de-serializes CFML data structures to the XML-based WDDX format. Generates JavaScript statements to instantiate JavaScript objects equivalent to the contents of a WDDX packet or some CFML data structures. Category Extensibility tags Syntax <cfwddx action = "action"...
  • Page 324 Chapter 2 ColdFusion Tags Attribute Description For the actions, validate WDDX2CFML WDDX2JS validate = "Yes" specifies that to process the WDDX input by a validating XML parser using the WDDX DTD (Document Type Definition). If the parser processes the WDDX input without error, the packet is deserialized.
  • Page 325: Chapter 3 Coldfusion Functions

    Chapter 3 ColdFusion Functions This chapter describes the functions in ColdFusion Markup Language (CFML). The introduction of this chapter includes: A summary of ColdFusion functions A list of new functions in ColdFusion 5 A list of functions by category The rest of this chapter provides descriptions of each function. Contents Alphabetical List of ColdFusion Functions ............
  • Page 326: Alphabetical List Of Coldfusion Functions

    Chapter 3 ColdFusion Functions Alphabetical List of ColdFusion Functions DecimalFormat IsStruct QuotedValueList ACos DecrementValue IsWDDX Rand ArrayAppend Decrypt JavaCast Randomize ArrayAvg DeleteClientVariable JSStringFormat RandRange ArrayClear DirectoryExists LCase REFind ArrayDeleteAt DollarFormat Left REFindNoCase ArrayInsertAt Duplicate RemoveChars ArrayIsEmpty Encrypt ListAppend RepeatString ArrayLen Evaluate ListChangeDelims Replace...
  • Page 327 Alphabetical List of ColdFusion Functions BitMaskSet GetHttpRequestData LJustify StripCR BitNot GetHttpTimeString StructAppend BitOr GetMetricData Log10 StructClear BitSHLN GetProfileString LSCurrencyFormat StructCopy BitSHRN GetTempDirectory LSDateFormat StructCount BitXor GetTempFile LSEuroCurrencyFormat StructDelete Ceiling GetTemplatePath LSIsCurrency StructFind GetTickCount LSIsDate StructFindKey CJustify GetTimeZoneInfo LSIsNumeric StructFindValue Compare GetToken LSNumberFormat StructGet...
  • Page 328: New Functions In Coldfusion 5

    Chapter 3 ColdFusion Functions DayOfYear IsNumericDate QueryAddColumn WriteOutput DaysInMonth IsProtected QueryAddRow XMLFormat DaysInYear IsQuery QueryNew Year DE (Delay Evaluation) IsSimpleValue QuerySetCell YesNoFormat New functions in ColdFusion 5 GetHttpRequestData Array functions ArrayAppend ArrayIsEmpty ArrayPrepend ArraySwap ArrayAvg ArrayLen ArrayResize ArrayToList ArrayClear ArrayMax ArraySet IsArray ArrayDeleteAt...
  • Page 329: Date And Time Functions

    Alphabetical List of ColdFusion Functions Date and time functions CreateDate DateDiff GetHttpTimeString Minute CreateDateTime DateFormat GetTimeZoneInfo Month CreateODBCDate DatePart Hour MonthAsString CreateODBCDateTime IsDate CreateODBCTime DayOfWeek IsLeapYear ParseDateTime CreateTime DayOfWeekAsString IsNumericDate Quarter CreateTimeSpan DayOfYear LSDateFormat Second DateAdd DaysInMonth LSIsDate TimeFormat DateCompare DaysInYear LSParseDateTime Week...
  • Page 330: Dynamic Evaluation Functions

    Chapter 3 ColdFusion Functions Dynamic evaluation functions DE (Delay Evaluation) Evaluate SetVariable International functions DateConvert LSEuroCurrencyFormat LSParseDateTime GetHttpTimeString LSIsCurrency LSParseEuroCurrency GetLocale LSIsDate LSParseNumber GetTimeZoneInfo LSIsNumeric LSTimeFormat LSCurrencyFormat LSNumberFormat SetLocale LSDateFormat LSParseCurrency List functions ArrayToList ListFindNoCase ListQualify ListAppend ListFirst ListRest ListChangeDelims ListGetAt ListSetAt ListContains...
  • Page 331: Query Functions

    Alphabetical List of ColdFusion Functions BitAnd Ceiling Log10 BitMaskClear BitMaskRead DecrementValue BitMaskSet BitNot Rand Query functions IsQuery QuerySetCell QueryAddColumn QuotedValueList QueryAddRow ValueList QueryNew String functions Insert LSParseNumber REReplace JavaCast LTrim REReplaceNoCase CJustify JSStringFormat Reverse Compare LCase MonthAsString Right CompareNoCase Left ParseDateTime RJustify DayOfWeekAsString...
  • Page 332: Structure Functions

    Chapter 3 ColdFusion Functions Structure functions Duplicate StructCount StructGet StructKeyList IsStruct StructDelete StructInsert StructNew StructAppend StructFind StructIsEmpty StructSort StructClear StructFindKey StructKeyArray StructUpdate StructCopy StructFindValue StructKeyExists System functions DirectoryExists GetException GetProfileString ExpandPath GetFileFromPath GetTempDirectory FileExists GetFunctionList GetTempFile GetCurrentTemplatePath GetHttpRequestData GetTemplatePath GetDirectoryFromPath GetMetricData SetProfileString Other functions...
  • Page 333 Alphabetical List of ColdFusion Functions Description Returns the absolute value of a number. The absolute value of a number is the number without its sign. Category Mathematical functions Abs(number Syntax See also Parameters Parameter Description number A number Example <!--- This example shows how to use the ABS function ---> <html>...
  • Page 334: Acos

    Chapter 3 ColdFusion Functions ACos Description Returns the arc cosine of a number, in radians. The arc cosine is the angle whose cosine is number. Category Mathematical functions ACos(number) Syntax See also Cos, Sin, ASin, Tan, Parameters Parameter Description number Cosine of the angle to calculate.
  • Page 335 Alphabetical List of ColdFusion Functions <cfelse> <!--- if it is empty, output an error message ---> <H4>Please enter a number between -1 and 1</H4> </cfif> </cfif> </cfif> <form action = "acos.cfm" method = "POST"> <P>Type in a number to get its arccosine in Radians and Degrees. <BR><input type = "Text"...
  • Page 336: Arrayappend

    Chapter 3 ColdFusion Functions ArrayAppend Description Appends an array index to an array. Returns a Boolean TRUE on successful completion. Category Array functions ArrayAppend(array, value) Syntax See also ArrayPrepend Parameters Parameter Description array Name of an array to which to append an index. value The value to place into an array in the last index position.
  • Page 337: Arrayavg

    Alphabetical List of ColdFusion Functions ArrayAvg Description Returns the average of the values in an array. Category Array functions ArrayAvg(array) Syntax Parameters Parameter Description array Name of an array that contains values to average. Example <!--- This example shows the use of ArrayAvg ---> <!--------------------------------------------------------------------- This following six lines of code keep track of the form fields that can be dynamically generated on the screen.
  • Page 338 Chapter 3 ColdFusion Functions <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>...
  • Page 339: Arrayclear

    Alphabetical List of ColdFusion Functions ArrayClear Description Deletes all data in an array. Returns a Boolean TRUE on successful completion. Category Array functions ArrayClear(array) Syntax See also ArrayDeleteAt Parameters Parameter Description array Name of an array from which to delete data Example <!--- This example shows ArrayClear --->...
  • Page 340: Arraydeleteat

    Chapter 3 ColdFusion Functions ArrayDeleteAt Description Deletes data from an array at an index position. When an array index is deleted, index positions are recalculated. For example, in an array that contains the months of the year, deleting index position [5] removes the entry for May. To then delete the entry for November, you delete index position [10], not [11], since the index positions were recalculated after index position [5] was removed.
  • Page 341: Arrayinsertat

    Alphabetical List of ColdFusion Functions ArrayInsertAt Description Inserts data in an array at an index position. Array elements with indexes greater than the new position are shifted right by one. The length of the array increases by one index. Returns a Boolean TRUE on successful completion. Category Array functions ArrayInsertAt(array, position, value)
  • Page 342: Arrayisempty

    Chapter 3 ColdFusion Functions ArrayIsEmpty Description Determines whether an array is empty of data. Returns a Boolean TRUE if the array is empty; otherwise FALSE. Category Array functions ArrayIsEmpty(array) Syntax See also ArrayLen Parameters Parameter Description array Name of an array to check for data Example <!--- This example shows ArrayIsEmpty --->...
  • Page 343: Arraylen

    Alphabetical List of ColdFusion Functions ArrayLen Description Returns the length of an array. Category Array functions ArrayLen(array) Syntax See also ArrayIsEmpty Parameters Parameter Description array Name of an array whose length to return Example <!--- This example shows ArrayLen ---> <html>...
  • Page 344: Arraymax

    Chapter 3 ColdFusion Functions ArrayMax Description Returns the largest numeric value in an array. Category Array functions ArrayMax(array) Syntax Parameters Parameter Description array Name of an array from which to return the largest numeric value Example <!--- This example shows the use of ArrayMax ---> <html>...
  • Page 345 Alphabetical List of ColdFusion Functions <input type = "text" name = "number2"> <BR> <input type = "submit" name = "submit" value = "Maximum Value"> </FORM> </body> </html>...
  • Page 346: Arraymin

    Chapter 3 ColdFusion Functions ArrayMin Description Returns the smallest numeric value in an array. Category Array functions ArrayMin(array) Syntax Parameters Parameter Description array Name of an array from which to return the smallest numeric value Example <!--- This example shows the use of ArrayMin ---> <html>...
  • Page 347 Alphabetical List of ColdFusion Functions <BR> <input type = "text" name = "number2"> <BR> <input type = "submit" name = "submit" value = "Minimum Value"> </FORM> </body> </html>...
  • Page 348: Arraynew

    Chapter 3 ColdFusion Functions ArrayNew Description Creates an array of 1 to 3 dimensions. Array elements are indexed with square brackets: [ ]. ColdFusion arrays expand dynamically as data is added. Category Array functions ArrayNew(dimension) Syntax Parameters Parameter Description dimension 1, 2, or 3 Example <!--- This example shows ArrayNew --->...
  • Page 349: Arrayprepend

    Alphabetical List of ColdFusion Functions ArrayPrepend Description Adds an array element to the beginning of an array. Returns a Boolean TRUE on successful completion. Category Array functions ArrayPrepend(array, value) Syntax See also ArrayAppend Parameters Parameter Description array Name of an array to which to prepend data. value The value to add to the beginning of the array.
  • Page 350: Arrayresize

    Chapter 3 ColdFusion Functions ArrayResize Description Resets an array to a specified minimum number of elements. ArrayResize provide some performance gains if used to size an array to its expected maximum. For arrays greater than 500 elements, use immediately after creating an ArrayResize array with ArrayNew...
  • Page 351: Arrayset

    Alphabetical List of ColdFusion Functions ArraySet Description In a one-dimensional array, sets the elements in a specified range to a value. Useful in initializing an array after a call to ArrayNew Returns a Boolean TRUE on successful completion. Category Array functions ArraySet(array, start_pos, end_pos, value) Syntax See also...
  • Page 352: Arraysort

    Chapter 3 ColdFusion Functions ArraySort Description Sorts array elements numerically or alphanumerically. Note If the sort is successful, returns "Yes". If not, returns "No". ArraySort ArraySort Array functions Category ArraySort(array, sort_type [, sort_order ]) Syntax Parameters Parameter Description array Name of an array to sort sort_type The type of sort to execute: numeric numerically...
  • Page 353: Arraysum

    Alphabetical List of ColdFusion Functions ArraySum Description Returns the sum of values in an array. Category Array functions ArraySum(array) Syntax Parameters Parameter Description array Name of an array that contains values to add Example <!--- This example shows the use of ArraySum ---> <html>...
  • Page 354 Chapter 3 ColdFusion Functions <input type = "text" name = "number1"> <BR> <input type = "text" name = "number2"> <BR> <input type = "submit" name = "submit" value = "Add"> </FORM> </body> </html>...
  • Page 355: Arrayswap

    Alphabetical List of ColdFusion Functions ArraySwap Description Swaps array values of an array at specified positions. can be used with ArraySwap greater efficiency than multiple tags. cfset Returns a Boolean TRUE on successful completion. Category Array functions ArraySwap(array, position1, position2) Syntax Parameters Parameter...
  • Page 356: Arraytolist

    Chapter 3 ColdFusion Functions ArrayToList Description Converts a one dimensional array to a list, delimited with the character you specify. Category Array functions ArrayToList(array [, delimiter ]) Syntax Parameters Parameter Description array Name of an array that contains elements to use to build a list. delimiter Specify the character(s) to use to delimit elements in the list.
  • Page 357 Alphabetical List of ColdFusion Functions Description Returns the ASCII value (character code) of the first character of a string. Returns 0 if string is empty. Category String functions Asc(string) Syntax See also Parameters Parameter Description string A string Example <!--- This code illustrates ASC ---> <html>...
  • Page 358: Asin

    Chapter 3 ColdFusion Functions ASin Description Returns the arcsine of a number, in radians. The arcsine is the angle whose sine is number. Category Mathematical functions ASin(number) Syntax See also Sin, Cos, Pi, Parameters Parameter Description number Sine of the angle to calculate. The value must be between 1 and -1. The range of the result is - /2 to /2 radians.
  • Page 359 Alphabetical List of ColdFusion Functions </cfif> <cfelse> <!--- if it is empty, output an error message ---> <H4>Please enter the sine of the angle that is to be calculated in degrees and radians. The value must be between 1 and -1,inclusive.</H4> </cfif>...
  • Page 360 Chapter 3 ColdFusion Functions Description Returns the arctangent of a number. The arctangent is the angle whose tangent is number. Category Mathematical functions Atn(number) Syntax See also Tan, Sin, Cos, Parameters Parameter Description number Tangent of an angle The range of the result is - /2 to /2 radians. To convert degrees to radians, multiply Usage degrees by /180.
  • Page 361: Authenticatedcontext

    Alphabetical List of ColdFusion Functions AuthenticatedContext Description Returns the name of the security context. See also IsAuthenticated, AuthenticatedUser, IsAuthorized, cfauthenticate AuthenticatedContext() Syntax Example <!--- This snippet shows how to use AuthenticatedContext ---> <html> <head> <title> AuthenticatedContext Example </title> </head> <body bgcolor = silver> <H3>AuthenticatedContext Example</H3>...
  • Page 362: Authenticateduser

    Chapter 3 ColdFusion Functions AuthenticatedUser Description Returns the name of an authenticated user. See also IsAuthenticated, AuthenticatedContext, cfauthenticate AuthenticatedUser() Syntax Example <!--- This snippet shows how to use AuthenticatedUser ---> <html> <head> <title> AuthenticatedUser Example </title> </head> <body bgcolor = silver> <H3>AuthenticatedUser Example</H3>...
  • Page 363: Bitand

    Alphabetical List of ColdFusion Functions BitAnd Description Returns the bitwise AND of two long integers. Category Mathematical functions BitAnd(number1, number2) Syntax See also BitNot, BitOr, BitXor Parameters Parameter Description number1, number2 A 32-bit signed integer Usage Bit functions operate on 32-bit signed integers, in the range -2147483648 to 2147483647.
  • Page 364: Bitmaskclear

    Chapter 3 ColdFusion Functions BitMaskClear Description Returns number bitwise, cleared, with length bits beginning from start. Category Mathematical functions BitMaskClear(number, start, length) Syntax See also BitMaskRead, BitMaskSet Parameters Parameter Description number 32-bit signed integer to mask start 32-bit signed integer; the starting bit for masking length 32-bit signed integer;...
  • Page 365: Bitmaskread

    Alphabetical List of ColdFusion Functions BitMaskRead Description Returns the integer created from length bits of number beginning from start. Category Mathematical functions BitMaskRead(number, start, length) Syntax See also BitMaskClear, BitMaskSet Parameters Parameter Description number 32-bit signed integer to mask start 32-bit signed integer;...
  • Page 366: Bitmaskset

    Chapter 3 ColdFusion Functions BitMaskSet Description Returns number bitwise masked with length bits of mask beginning from start. Category Mathematical functions BitMaskSet(number, mask, start, length) Syntax See also BitMaskClear, BitMaskRead Parameters Parameter Description number 32-bit signed integer to mask mask 32-bit signed integer;...
  • Page 367: Bitnot

    Alphabetical List of ColdFusion Functions BitNot Description Returns the bitwise NOT of a long integer. Category Mathematical functions BitNot(number) Syntax 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 to 2147483647.
  • Page 368: Bitor

    Chapter 3 ColdFusion Functions BitOr Description Returns the bitwise OR of two long integers Category Mathematical functions BitOr(number1, number2) Syntax See also BitAnd, BitNot, BitXor Parameters Parameter Description number1, number2 32-bit signed integers Usage Bit functions operate on 32-bit integers, in the range -2147483648 to 2147483647. Example <!--- This example shows BitOr --->...
  • Page 369: Bitshln

    Alphabetical List of ColdFusion Functions BitSHLN Description Returns number bitwise shifted without rotation to the left by count bits. Category Mathematical functions BitSHLN(number, count) Syntax See also BitSHRN Parameters Parameter Description number 32-bit signed integer to shift to the left count Integer;...
  • Page 370: Bitshrn

    Chapter 3 ColdFusion Functions BitSHRN Description Returns number bitwise shifted without rotation to the right by count bits. Category Mathematical functions BitSHRN(number, count) Syntax See also BitSHLN Parameters Parameter Description number 32-bit signed integer to shift to the right count Integer;...
  • Page 371: Bitxor

    Alphabetical List of ColdFusion Functions BitXor Description Returns bitwise XOR of two long integers. Category Mathematical functions BitXor(number1, number2) Syntax See also BitAnd, BitNot, BitOr Parameters Parameter Description number1, number2 32-bit signed integers Usage Bit functions operate on 32-bit signed integers, in the range -2147483648 to 2147483647.
  • Page 372: Ceiling

    Chapter 3 ColdFusion Functions Ceiling Description Returns the closest integer greater than a given number. Category Mathematical functions Ceiling(number) Syntax See also Int, Fix, Round Parameters Parameter Description number A real number Example <!--- This example illustrates the CF function ceiling ---> <html>...
  • Page 373 Alphabetical List of ColdFusion Functions Description Returns a character of a given ASCII value (character code). Category String functions Chr(number) Syntax Parameters Parameter Description number A ASCII value (a number in the range 0 to 255 inclusive) Numbers 0–31 are the standard, nonprintable, ASCII codes. For example, Usage Chr(10) returns a linefeed character and...
  • Page 374: Cjustify

    Chapter 3 ColdFusion Functions CJustify Description Centers a string in a field length. Category String functions Cjustify(string, length) Syntax See also LJustify, RJustify Parameters Parameter Description string A string to center length Length of field Example <!--- This example shows how to use CJustify ---> <CFPARAM name = "jstring"...
  • Page 375: Compare

    Alphabetical List of ColdFusion Functions 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 String functions Category Compare(string1, string2) Syntax See also CompareNoCase,...
  • Page 376 Chapter 3 ColdFusion Functions <I>The strings are not equal</I> </cfcase> <CFDEFAULTCASE> <H3>This is the default case</H3> </CFDEFAULTCASE> </cfswitch> </cfif> <form action = "compare.cfm" method = "POST"> <P>String 1 <BR><input type = "Text" name = "string1"> <P>String 2 <BR><input type = "Text" name = "string2"> <P><input type = "Submit"...
  • Page 377: Comparenocase

    Alphabetical List of ColdFusion Functions CompareNoCase Description Performs a case-insensitive comparison of two strings. Returns: 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 String functions Category CompareNoCase(string1, string2)
  • Page 378 Chapter 3 ColdFusion Functions Description Returns the cosine of an angle, in radians. Category Mathematical functions Cos(number) Syntax See also Sin, Tan, Parameters Parameter Description number Angle, in radians, for which you want the cosine Usage The range of the result is - to . To convert degrees to radians, multiply degrees by /180.
  • Page 379: Createdate

    Alphabetical List of ColdFusion Functions CreateDate Description Returns a valid date/time object. Category Date and time functions CreateDate(year, month, day) Syntax See also CreateDateTime, CreateODBCDate Parameters Parameter Description year Number in the range 100 - 9999. Year values 0–29 are interpreted as 21 century dates.
  • Page 380 Chapter 3 ColdFusion Functions <P>The same value can be formatted with dateFormat: <UL> <LI>Built with CreateDate: #DateFormat(CreateDate(FORM.year, FORM.month, FORM.day), "mmm-dd-yyyy")# <LI>Built with CreateDateTime: #DateFormat(CreateDateTime(FORM.year, FORM.month, FORM.day, 12,13,0))# <LI>Built with CreateODBCDate: #DateFormat(CreateODBCDate(yourDate), "mmmm d, yyyy")# <LI>Built with CreateODBCDateTime: #DateFormat(CreateODBCDateTime(yourDate), "d/m/yy")# </UL> </cfoutput>...
  • Page 381: Createdatetime

    Alphabetical List of ColdFusion Functions CreateDateTime Description Returns a valid date/time object. Category Date and time functions CreateDateTime(year, month, day, hour, minute, second) Syntax See also CreateDate, CreateTime, CreateODBCDateTime, Parameters Parameter Description year Number in the range 100–9999 month Number in the range 1 (January)–12 (December) Number in the range 1–31 hour Number in the range 0–23...
  • Page 382 Chapter 3 ColdFusion Functions <P>The same value can be formatted with dateFormat: <UL> <LI>Built with CreateDate: #DateFormat(CreateDate (form.year,form.month,form.day), "mmm-dd-yyyy")# <LI>Built with CreateDateTime: #DateFormat(CreateDateTime (form.year, form.month, form.day, form.hour, form.minute, form.second))# <LI>Built with CreateODBCDate: #DateFormat(CreateODBCDate(yourDate), "mmmm d, yyyy")# <LI>Built with CreateODBCDateTime: #DateFormat(CreateODBCDateTime(yourDate), "d/m/yy")# </UL>...
  • Page 383: Createobject

    Alphabetical List of ColdFusion Functions CreateObject Description Lets you create COM, CORBA, and JAVA objects. Note ColdFusion administrators can disable the tag using the Tag Restrictions cfobject page under the ColdFusion Basic Security page, which also disables this function. CreateObject object types Refer to the following sections for more details about using CreateObject to create COM, CORBA, and Java objects.
  • Page 384 Chapter 3 ColdFusion Functions Description lets you create and use Component Object Model (COM) objects. An CreateObject automation server object type that is currently registered on a computer can be invoked. You can use a utility like Microsoft’s utility to browse COM objects. OLEView , and information about COM and DCOM, can be found at Microsoft’s OLE OLEView...
  • Page 385 Alphabetical List of ColdFusion Functions CORBA Description lets you call methods in CORBA objects. The objects must have CreateObject already been defined and registered for use. Category Other functions CreateObject("CORBA", class, context, locale ) Syntax Parameters Parameter Description class Required. Specifies, depending on the CONTEXT specification: If CONTEXT is IOR the name of a file that contains the string version of the IOR.
  • Page 386 Chapter 3 ColdFusion Functions CreateObject Description Lets you create and use Java objects, and, by extension, EJB objects. Category Other functions CreateObject("Java", class) Syntax Parameters Parameter Description class Required. A Java class To call Java CFXs or Java objects, ColdFusion uses a JVM embedded in the process. Usage The loading, location, and settings for the JVM are configurable in the ColdFusion Administrator pages.
  • Page 387: Createodbcdate

    Alphabetical List of ColdFusion Functions CreateODBCDate Description Returns a date in ODBC date format. Category Date and time functions CreateODBCDate(date) Syntax See also CreateDate, CreateODBCDateTime Parameters Parameter Description date Date/time object in the range 100 AD - 9999 AD. Year values 0–29 are interpreted as 21 century dates.
  • Page 388 Chapter 3 ColdFusion Functions <P>The same value can be formatted with dateFormat: <UL> <LI>Built with CreateDate: #DateFormat(CreateDate (FORM.year, FORM.month, FORM.day), "mmm-dd-yyyy")# <LI>Built with CreateDateTime: #DateFormat(CreateDateTime (FORM.year, FORM.month, FORM.day, FORM.hour, FORM.minute,FORM.second))# <LI>Built with CreateODBCDate: #DateFormat(CreateODBCDate(yourDate), "mmmm d, yyyy")# <LI>Built with CreateODBCDateTime: #DateFormat(CreateODBCDateTime(yourDate), "d/m/yy")# </UL>...
  • Page 389: Createodbcdatetime

    Alphabetical List of ColdFusion Functions CreateODBCDateTime Description Returns a date/time object in ODBC timestamp format. Category Date and time functions CreateODBCDateTime(date) Syntax See also CreateDateTime, CreateODBCDate, CreateODBCTime, Parameters Parameter Description date Date/time object in the range 100 AD–9999 AD. Year values 0–29 are interpreted as 21 century dates.
  • Page 390 Chapter 3 ColdFusion Functions (FORM.year, FORM.month, FORM.day), "mmm-dd-yyyy")# <LI>Built with CreateDateTime: #DateFormat(CreateDateTime (FORM.year, FORM.month, FORM.day, FORM.hour, FORM.minute, FORM.second))# <LI>Built with CreateODBCDate: #DateFormat(CreateODBCDate(yourDate), "mmmm d, yyyy")# <LI>Built with CreateODBCDateTime: #DateFormat(CreateODBCDateTime(yourDate), "d/m/yy")# </UL> </cfoutput> </cfif> <cfform action = "createODBCdatetime.cfm" method = "POST"> <P>Please enter the year, month and day in integer format for the date value you would like to view: <PRE>...
  • Page 391: Createodbctime

    Alphabetical List of ColdFusion Functions CreateODBCTime Description Returns a time object in ODBC time format. Category Date and time functions CreateODBCTime(date) Syntax See also CreateODBCDateTime, CreateTime Parameters Parameter Description date Date/time object in the period 100 AD–9999 AD Usage When passing a date/time value as a string, enclose it in quotes. Otherwise, it is interpreted as a number representation of a date/time object.
  • Page 392 Chapter 3 ColdFusion Functions message = "You must enter a minute value (0-59)" validate = "integer" required = "Yes"> Second<cfinput type = "Text" name = "second" value = "0" RANGE = "0,59" message = "You must enter a value for seconds (0-59)" validate = "integer"...
  • Page 393: Createtime

    Alphabetical List of ColdFusion Functions CreateTime Description Returns a time variable in ColdFusion. Category Date and time functions CreateTime(hour, minute, second) Syntax 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...
  • Page 394: Createtimespan

    Chapter 3 ColdFusion Functions 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 Category Date and time functions CreateTimeSpan(days, hours, minutes, seconds) Syntax See also CreateDateTime, DateAdd,...
  • Page 395 Alphabetical List of ColdFusion Functions </cfquery> </cfoutput> <!--- 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>...
  • Page 396: Createuuid

    Chapter 3 ColdFusion Functions CreateUUID Description Returns a Universally Unique Identifier (UUID) in the format ‘XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXXXXX’ where ‘X’ stands for a hexadecimal digit (0-9 or A-F). Category Other functions CreateUUID() Syntax A UUID, returned by , is a 35-character string representation of a unique Usage CreateUUID 128-bit integer.
  • Page 397: Dateadd

    Alphabetical List of ColdFusion Functions DateAdd Description Returns a date to which a time interval has been added. Category Date and time functions DateAdd(datepart, number, date) Syntax See also DateConvert, DatePart, CreateTimeSpan Parameters Parameter Description datepart One of the following strings: yyyy Year Quarter...
  • Page 398 Chapter 3 ColdFusion Functions <cfcase value = "yyyy">years</cfcase> <cfcase value = "q">quarters</cfcase> <cfcase value = "m">months</cfcase> <cfcase value = "y">days of year</cfcase> <cfcase value = "w">weekdays</cfcase> <cfcase value = "ww">weeks</cfcase> <cfcase value = "h">hours</cfcase> <cfcase value = "n">minutes</cfcase> <cfcase value = "s">seconds</cfcase> <CFDEFAULTCASE>years</CFDEFAULTCASE>...
  • Page 399: Datecompare

    Alphabetical List of ColdFusion Functions 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 Date and time functions Category DateCompare(date1, date2 [, datePart]) Syntax...
  • Page 400 Chapter 3 ColdFusion Functions <cfset comparison = DateCompare(FORM.date1, FORM.date2, FORM.precision)> <!--- switch on the variable to give various responses ---> <cfswitch expression = #comparison#> <cfcase value = "-1"> <H3><cfoutput>#DateFormat(FORM.date1)# #TimeFormat(FORM.date1)#</cfoutput> (Date 1) is earlier than <cfoutput>#DateFormat(FORM.date2)# #TimeFormat(FORM.date2)#</cfoutput> (Date 2)</H3> <I>The dates are not equal</I> </cfcase>...
  • Page 401 Alphabetical List of ColdFusion Functions Second </OPTION> <option value = "n"> Minute </OPTION> <option value = "h"> Hour </OPTION> <option value = "d"> </OPTION> <option value = "m"> Month </OPTION> <option value = "yyyy"> Year </OPTION> </select> <P><input type = "Submit" value = "Compare these dates" name = ""> <input type = "RESET">...
  • Page 402: Dateconvert

    Chapter 3 ColdFusion Functions DateConvert Description Converts local time to Universal Coordinated Time (UTC) or UTC to local time, based on parameters. The function uses the daylight savings settings in the executing computer to compute daylight savings time, if required. Category Date and time functions DateConvert(conversion-type, date)
  • Page 403 Alphabetical List of ColdFusion Functions <!--- This code checks whether the form was submitted. If it was submitted the code generates the CFML date with the CreateDateTime function. ---> <cfif IsDefined("FORM.submit")> <cfset yourDate = CreateDateTime(FORM.year, FORM.month, FORM.day, FORM.hour,FORM.minute, FORM.second)> <P><cfoutput>Your date value, presented as a ColdFusion date/time string:#yourdate#.</cfoutput></P>...
  • Page 404 Chapter 3 ColdFusion Functions <td><input type = "Text" name = "minute" value = "12" RANGE = "0,59" message = "You must enter a minute value (0-59)" validate = "integer" required = "Yes"></td> </tr> <tr> <td>Second</td> <td><input type = "Text" name = "second" value = "0" RANGE = "0,59"...
  • Page 405: Datediff

    Alphabetical List of ColdFusion Functions DateDiff Description Returns the number of intervals, in units of type datepart, by which date1 is less than date2. Category Date and time functions DateDiff(datepart, date1, date2) Syntax See also DateAdd, DatePart, CreateTimeSpan Parameters Parameter Description datepart One of the following strings:...
  • Page 406 Chapter 3 ColdFusion Functions <P>This example uses DateDiff to determine the difference in <cfswitch expression = #type#> <cfcase value = "yyyy">years</cfcase> <cfcase value = "q">quarters</cfcase> <cfcase value = "m">months</cfcase> <cfcase value = "y">days of year</cfcase> <cfcase value = "d">days</cfcase> <cfcase value = "w">weekdays</cfcase> <cfcase value = "ww">weeks</cfcase>...
  • Page 407: Dateformat

    Alphabetical List of ColdFusion Functions DateFormat Description Returns a formatted date/time value. If no mask is specified, returns the DateFormat date value in the dd-mmm-yy format. supports dates that have the U.S. DateFormat date format. For international date support, use LSDateFormat Category Date and time functions...
  • Page 408 Chapter 3 ColdFusion Functions </title> </head> <cfset todayDate = Now()> <body> <H3>DateFormat Example</H3> <P>Today’s date is <cfoutput>#todayDate#</cfoutput>. <P>Using DateFormat, we can display that date in different ways: <cfoutput> <UL> <LI>#DateFormat(todayDate)# <LI>#DateFormat(todayDate, "mmm-dd-yyyy")# <LI>#DateFormat(todayDate, "mmmm d, yyyy")# <LI>#DateFormat(todayDate, "mm/dd/yyyy")# <LI>#DateFormat(todayDate, "d-mmm-yyyy")# <LI>#DateFormat(todayDate, "ddd, mmmm dd, yyyy")# <LI>#DateFormat(todayDate, "d/m/yy")# </UL>...
  • Page 409: Datepart

    Alphabetical List of ColdFusion Functions DatePart Description Returns part of a date as an integer. Category Date and time functions DatePart(datepart, date) Syntax See also DateAdd DateConvert Parameters Parameter Description datepart One of the following strings: yyyy Year Quarter Month Day of year Weekday Week...
  • Page 410 Chapter 3 ColdFusion Functions <LI>quarter: #DatePart("q", todayDate)# <LI>month: #DatePart("m", todayDate)# <LI>day of year: #DatePart("y", todayDate)# <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> </body> </html>...
  • Page 411 Alphabetical List of ColdFusion Functions Description Returns the ordinal for the day of the month, ranging from 1 to 31. Category Date and time functions Day(date) Syntax See also DayOfWeek, DayOfWeekAsString, DayOfYear, DaysInMonth, DaysInYear, FirstDayOfMonth Parameters Parameter Description date A date/time object. Year values 0–29 are interpreted as 21 century dates.
  • Page 412 Chapter 3 ColdFusion Functions <cfelse>This is not a leap year</cfif> </cfoutput> </cfif>...
  • Page 413: Dayofweek

    Alphabetical List of ColdFusion Functions DayOfWeek Description Returns the ordinal for the day of the week. The day is given as an integer in the range 1 (Sunday) to 7 (Saturday). Category Date and time functions See also Day, DayOfWeekAsString, DayOfYear, DaysInMonth, DaysInYear, FirstDayOfMonth DayOfWeek(date) Syntax...
  • Page 414 Chapter 3 ColdFusion Functions <BR><cfif IsLeapYear(Year(yourDate))>This is a leap year <cfelse>This is not a leap year</cfif> </cfoutput> </cfif>...
  • Page 415: Dayofweekasstring

    Alphabetical List of ColdFusion Functions DayOfWeekAsString Description Returns the day of the week corresponding to day_of_week, an integer in the range 1 (Sunday) to 7 (Saturday). Category Date and time functions DayOfWeekAsString(day_of_week) Syntax See also Day, DayOfWeek, DayOfYear, DaysInMonth, DaysInYear, FirstDayOfMonth Parameters Parameter...
  • Page 416: Dayofyear

    Chapter 3 ColdFusion Functions DayOfYear Description Returns the ordinal for the day of the year. Category Date and time functions DayOfYear(date) Syntax See also Day, DayOfWeek, DayOfWeekAsString, DaysInMonth, DaysInYear, FirstDayOfMonth Parameters Parameter Description date A date/time object accounts for leap years. Usage DayofYear Year values 0–29 are interpreted as 21...
  • Page 417 Alphabetical List of ColdFusion Functions <BR>We are in week #Week(yourDate)# of #Year(yourDate)# (day #DayofYear(yourDate)# of #DaysinYear(yourDate)#). <BR><cfif IsLeapYear(Year(yourDate))>This is a leap year <cfelse>This is not a leap year</cfif> </cfoutput>...
  • Page 418: Daysinmonth

    Chapter 3 ColdFusion Functions DaysInMonth Description Returns the number of days in a month (Date). Category Date and time functions DaysInMonth(date) Syntax See also Day, DayOfWeek, DayOfWeekAsString, DayOfYear, DaysInYear, FirstDayOfMonth Parameters Parameter Description date A date/time object Year values 0–29 are interpreted as 21 century dates.
  • Page 419: Daysinyear

    Alphabetical List of ColdFusion Functions DaysInYear Description Returns the number of days in a year. Category Date and time functions DaysInYear(date) Syntax See also Day, DayOfWeek, DayOfWeekAsString, DayOfYear, DaysInMonth, DaysInYear, FirstDayOfMonth, IsLeapYear Parameters Parameter Description date A date/time object. See the Note under Usage. DaysInYear accounts for leap years.
  • Page 420: De (Delay Evaluation)

    Chapter 3 ColdFusion Functions DE (Delay Evaluation) Description Returns its argument wrapped in double quotes, and inner double quotes escaped. prevents evaluation of a string as an expression when it is passed as an argument Evaluate Category Dynamic evaluation functions DE(string) Syntax See also...
  • Page 421: Decimalformat

    Alphabetical List of ColdFusion Functions DecimalFormat Description Returns number as a string formatted with two decimal places and a thousands separator. Category Display and formatting functions DecimalFormat(number) Syntax See also DollarFormat, NumberFormat Parameters Parameter Description number Number to format Example <!--- This code shows the use of DecimalFormat --->...
  • Page 422: Decrementvalue

    Chapter 3 ColdFusion Functions DecrementValue Description Returns integer part of number decremented by one. Category Mathematical functions DecrementValue(number) Syntax See also IncrementValue Parameters Parameter Description number Number to decrement Example <!--- This shows the use of DecrementValue ---> <html> <head> <title>...
  • Page 423: Decrypt

    Alphabetical List of ColdFusion Functions Decrypt Description Decrypts an encrypted string. Category String functions Decrypt(encrypted_string, seed) Syntax See also Duplicate, Encrypt Parameters Parameter Description encrypted_string String to decrypt seed String that specifies the seed used to generate the 32-bit key Example <!--- This example shows the use of Encrypt and Decrypt --->...
  • Page 424: Deleteclientvariable

    Chapter 3 ColdFusion Functions DeleteClientVariable Description Deletes the client variable specified by name. Returns a Boolean TRUE when variable is successfully deleted, even if variable did not previously exist. To test for the existence of a variable, use IsDefined Category Other functions DeleteClientVariable("name") Syntax...
  • Page 425: Directoryexists

    Alphabetical List of ColdFusion Functions DirectoryExists Description Returns YES if the directory specified in the argument exists; otherwise, returns NO. Category System functions DirectoryExists(absolute_path) Syntax See also FileExists Parameters Parameter Description absolute_path A absolute path Example <!--- This example shows the use of DirectoryExists ---> <html>...
  • Page 426: Dollarformat

    Chapter 3 ColdFusion Functions DollarFormat Description Returns number as a string formatted with two decimal places, thousands separator, and dollar sign. If number is negative, parentheses are used. Returns strings in U.S. format. For other currencies, use LSCurrencyFormat LSEuroCurrencyFormat. Category Display and formatting functions DollarFormat(number) Syntax...
  • Page 427: Duplicate

    Alphabetical List of ColdFusion Functions Duplicate Description Returns a clone, also known as a deep copy, of a variable. Unlike StructCopy copies the variable, so there is no reference to the original variable. Duplicate Category Structure functions Duplicate(variable_name) Syntax See also StructCopy Parameters Parameter...
  • Page 428: Encrypt

    Chapter 3 ColdFusion Functions Encrypt Description Encrypts a string. Encrypt 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. Encrypt uses an XOR-based algorithm that uses a pseudo-random 32-bit key based on a seed passed by the user as a parameter to the function.
  • Page 429 Alphabetical List of ColdFusion Functions This string will be encrypted (try typing some more) </textArea> <input type = "Submit" value = "Encrypt my String"> </FORM> </body> </html>...
  • Page 430: Evaluate

    Chapter 3 ColdFusion Functions Evaluate Description Evaluates arguments, left to right; returns the result of evaluating the last argument. Category Dynamic evaluation functions Evaluate(string_expression1 [, string_expression2 [, … ] ] ) Syntax See also DE (Delay Evaluation), Parameters Parameter Description string_expression1, Expressions to evaluate string_expression2...
  • Page 431 Alphabetical List of ColdFusion Functions Description Returns e raised to the power of number. The constant e equals 2.71828182845904, the base of the natural logarithm. Category Mathematical functions Exp(number) Syntax See also Log, Log10 Parameters Parameter Description number Exponent applied to the base e To calculate powers of other bases, use ^ (the exponentiation operator).
  • Page 432: Expandpath

    Chapter 3 ColdFusion Functions ExpandPath Description Returns a path equivalent to the relative_path appended to the base template path. Note: creates a platform-appropriate path. You can use a slash (/) or ExpandPath backslash (\) in a relative path. The return value contains a trailing slash (or backslash) if the relative path contains a trailing slash (or backslash).
  • Page 433: Fileexists

    Alphabetical List of ColdFusion Functions FileExists Description Returns YES if the file specified in the argument exists; otherwise, returns NO. Category System functions FileExists(absolute_path) Syntax See also DirectoryExists, ExpandPath, GetTemplatePath Parameters Parameter Description absolute_path A absolute path Example <!--- This example shows the use of FileExists ---> <html>...
  • Page 434: Find

    Chapter 3 ColdFusion Functions Find Description Returns the first index of an occurrence of a substring in a string from a specified starting position. Returns 0 if substring is not in string. The search is case-sensitive. Category String functions Find(substring, string [, start ]) Syntax See also FindNoCase, Compare, FindOneOf, REFind,...
  • Page 435: Findnocase

    Alphabetical List of ColdFusion Functions FindNoCase Description Returns the first index of an occurrence of a substring in a string from a specified starting position. Returns 0 if substring is not in string. The search is case-insensitive. Category String functions FindNoCase(substring, string [, start ]) Syntax See also...
  • Page 436: Findoneof

    Chapter 3 ColdFusion Functions FindOneOf Description Return the first index of the occurrence of a character from set in string. Returns 0 if no characters are found. The search is case-sensitive. Category String functions FindOneOf(set, string [, start ]) Syntax See also Find, Compare, REFind...
  • Page 437: Firstdayofmonth

    Alphabetical List of ColdFusion Functions FirstDayOfMonth Description Returns the ordinal (the day’s number in the year) for the first day of a month. Category Date and time functions FirstDayOfMonth(date) Syntax See also Day, DayOfWeek, DayOfWeekAsString, DayOfYear, DaysInMonth, DaysInYear Parameters Parameter Description date A date...
  • Page 438 Chapter 3 ColdFusion Functions Description Returns the closest integer less than number, if number is greater than or equal to 0. Returns the closest integer greater than number, if number is less than 0. Category Mathematical functions Fix(number) Syntax See also Ceiling, Int, Round Parameters...
  • Page 439: Formatbasen

    Alphabetical List of ColdFusion Functions FormatBaseN Description Converts number to a string in the base specified by radix. Category Mathematical functions FormatBaseN(number, radix) Syntax See also InputBaseN Parameters Parameter Description number Number to convert radix Base of the result Example <!--- This example shows FormatBaseN and InputBaseN--->...
  • Page 440: Getbasetagdata

    Chapter 3 ColdFusion Functions GetBaseTagData Description Returns an object that contains data (variables, scopes, and so on) from an ancestor tag. By default, returns the closest ancestor. If there is no ancestor by the specified name, or if the ancestor does not expose data (for example, ), an exception is cfif thrown.
  • Page 441: Getbasetaglist

    Alphabetical List of ColdFusion Functions GetBaseTagList Description Returns a comma-delimited list of uppercase ancestor tag names. The first element of the list is the parent tag. If you call for a top-level tag, it returns an GetBaseTagList empty string. Category Other functions GetBaseTagList() Syntax...
  • Page 442: Getbasetemplatepath

    Chapter 3 ColdFusion Functions GetBaseTemplatePath Description Returns the fully specified path of the base template. Category System functions GetBaseTemplatePath() Syntax See also GetCurrentTemplatePath, FileExists, ExpandPath Example <!--- This example uses GetBaseTemplatePath to show the template path of the current page ---> <html>...
  • Page 443: Getclientvariableslist

    Alphabetical List of ColdFusion Functions GetClientVariablesList Description Returns a list of non-read-only client variables available to a template. Category Other functions GetClientVariablesList() Syntax See also DeleteClientVariable Usage You can use the list of variables returned by with GetClientVariablesList ColdFusion list functions, because the returned list is comma-delimited, so it is compatible with ColdFusion list functions.
  • Page 444: Getcurrenttemplatepath

    Chapter 3 ColdFusion Functions GetCurrentTemplatePath Description Returns the fully specified path of the template that contains the call to this function. Category System functions GetCurrentTemplatePath() Syntax See also GetBaseTemplatePath, FileExists, ExpandPath Usage This function differs from in that it returns the template path GetBaseTemplatePath of an included template, if the call is made from a template included with a tag;...
  • Page 445: Getdirectoryfrompath

    Alphabetical List of ColdFusion Functions GetDirectoryFromPath Description Extracts the directory (with a backslash) from a fully specified path. Category System functions GetDirectoryFromPath(path) Syntax See also ExpandPath, GetFileFromPath Parameters Parameter Description path Fully specified path (drive, directory, filename, and extension) Example <!--- This example shows the use of GetDirectoryFromPath --->...
  • Page 446: Getexception

    Chapter 3 ColdFusion Functions GetException Description Used with cftry and cfcatch, this function allow you to retrieve a Java exception object from a Java object. Returns any Java exception object raised by the previous method call on the Java object. Category System functions getException(object)
  • Page 447: Getfilefrompath

    Alphabetical List of ColdFusion Functions GetFileFromPath Description Extracts a filename from a fully specified path. Category System functions GetFileFromPath(path) Syntax See also ExpandPath, GetCurrentTemplatePath Parameters Parameter Description path Fully qualified path (drive, directory, filename, and extension) Example <!--- This example shows the use of GetFileFromPath---> <html>...
  • Page 448: Getfunctionlist

    Chapter 3 ColdFusion Functions GetFunctionList Description Returns a structure of functions that are available in ColdFusion. Category System functions GetFunctionList() Syntax Example <!--------------------------------------------------------------- The following code displays a list of ColdFusion functions. -----------------------------------------------------------------> <cfset fList = GetFunctionList()> <cfoutput>#StructCount(fList)# functions<BR><BR></cfoutput> <CFLOOP COLLECTION = "#fList#" ITEM = "key"> <cfoutput>#key#<BR></cfoutput>...
  • Page 449: Gethttprequestdata

    Alphabetical List of ColdFusion Functions GetHttpRequestData Description akes HTTP request headers and body available to CFML pages. Does not take arguments. Returns a ColdFusion structure. is especially useful GetHttpRequestData for capturing SOAP request data, which can be delivered in an HTTP header. Category System functions GetHttpRequestData()
  • Page 450 Chapter 3 ColdFusion Functions <tr> <td>request_method</td> <td>#x.method#</td> </tr> <tr> <td>server_protocol</td> <td>#x.protocol#</td> </tr> </table> <b>http_content --- #x.content#</b> </cfoutput>...
  • Page 451: Gethttptimestring

    Alphabetical List of ColdFusion Functions GetHttpTimeString Description This function takes one argument, a ColdFusion date/time object, and returns the time formatted as a string according to the HTTP standard described in RFC 1123. Category Date and time functions GetHttpTimeString(date_time_object) Syntax Parameters Parameter Description...
  • Page 452: Getlocale

    Chapter 3 ColdFusion Functions GetLocale Description Returns the locale for the current request. Locales are determined by the native operating system. A locale is an encapsulation of the set of attributes that govern the display and formatting of international date, time, number, and currency values. Category International functions GetLocale()
  • Page 453 Alphabetical List of ColdFusion Functions <P>The locale for this system is <cfoutput>#GetLocale()#</cfoutput> </body> </html>...
  • Page 454: Getmetricdata

    Chapter 3 ColdFusion Functions GetMetricData Description On Windows NT, returns system and application metrics, depending GetMetricData on the value of the mode parameter. Category System functions GetMetricData(mode) Syntax Parameters Parameter Description mode The name of the metric. The metrics that you can check are: Returns internal data that is otherwise displayed in PERF_MONITOR the Windows NT PerfMonitor.
  • Page 455 Alphabetical List of ColdFusion Functions AvgDBTime CachePops Example <!--------------------------------------------------------------------- This example gets and displays the metric data provided by Windows NT PerfMonitor. ----------------------------------------------------------------------> <cfset pmData = GetMetricData( "PERF_MONITOR" ) > <cfoutput> Current PerfMonitor data is: <P> InstanceName:#pmData.InstanceName# <P> PageHits:#pmData.PageHits# <P> ReqQueued: #pmData.ReqQueued# <P>...
  • Page 456: Getprofilestring

    Chapter 3 ColdFusion Functions GetProfileString Description Returns the value of an entry in an initialization file, or an empty string if the value does not exist. An initialization file assigns values to configuration variables, also known as entries, that must be set when the system boots, the operating system comes up, or an application starts.
  • Page 457 Alphabetical List of ColdFusion Functions <form action = "getprofilestring.cfm" method = "POST"> <hr size = "2" color = "#0000A0"> <table cellspacing = "2" cellpadding = "2" border = "0"> <tr> <td>Full Path of Init File</td> <td><input type = "Text" name = "IniPath" value = "C:\myboot.ini"> </td>...
  • Page 458: Gettempdirectory

    Chapter 3 ColdFusion Functions GetTempDirectory Description Returns the full pathname of a directory, including the trailing slash. The directory that is returned 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.
  • Page 459: Gettempfile

    Alphabetical List of ColdFusion Functions GetTempFile Description Creates and returns the name of a temporary file in a directory whose name starts with (at most) the first three characters of prefix. Category System functions GetTempFile(dir, prefix) Syntax See also GetTempDirectory Parameters Parameter Description...
  • Page 460: Gettemplatepath

    Chapter 3 ColdFusion Functions GetTemplatePath Description Returns the fully specified path of the base template. Note For backward compatibility, is still supported. However, GetTemplatePath supersedes this function, and should be used in place of it. GetBaseTemplatePath Category System functions GetTemplatePath() Syntax See also GetBaseTemplatePath, FileExists,...
  • Page 461: Gettickcount

    Alphabetical List of ColdFusion Functions GetTickCount Description Returns a millisecond clock counter that can be used for timing sections of CFML code or other aspects of page processing. Category Date and time functions GetTickCount() Syntax Usage Generate useful timing values by taking differences between the results of GetTickCount() at successive points of page processing.
  • Page 462: Gettimezoneinfo

    Chapter 3 ColdFusion Functions GetTimeZoneInfo Description Returns a structure that contains time zone information for the computer on which it is executed. The structure contains four elements with the following keys: offset of the local time, in minutes, from Universal utcTotalOffset Coordinated Time (UTC).
  • Page 463: Gettoken

    Alphabetical List of ColdFusion Functions GetToken Description Returns a token in a string. Default delimiters are spaces, tabs, and newline characters. If index is greater than the number of tokens in string, returns GetToken an empty string. Category String functions GetToken(string, index [, delimiters ]) Syntax See also...
  • Page 464: Hash

    Chapter 3 ColdFusion Functions Hash Description Converts a variable-length string to a 32-byte, hexadecimal string, using the MD5 algorithm. The algorithm is a one-way hash—there is no conversion from the hash result back to the source string. Category String functions Hash(string) Syntax Parameters...
  • Page 465: Hour

    Alphabetical List of ColdFusion Functions Hour Description Returns the ordinal value for the hour, in the range 0 - 23. Category Date and time functions Hour(date) Syntax See also DatePart, Minute, Second Parameters Parameter Description date A date Usage Year values 0–29 are interpreted as 21 century dates.
  • Page 466: Htmlcodeformat

    Chapter 3 ColdFusion Functions HTMLCodeFormat Description Returns HTML escaped string enclosed in tags. Carriage returns <PRE> </PRE> are removed from string, and special characters (> < " &) are escaped. Category Display and formatting functions HTMLCodeFormat(string [, version ]) Syntax See also HTMLEditFormat Parameters...
  • Page 467 Alphabetical List of ColdFusion Functions <!--- do simple error check to avoid crashing the tag ---> <cfif Trim(Form.urladdress) is "" or Trim(Form.urladdress) is "http:/ /"> <!--- if error condition tripped, set alternative ---> <cfset urlAddress = "http://localhost/cfdocs/index.htm"> <H4>because you entered no url or an empty string, the tag will return the following address: http://localhost/cfdocs/ index.htm</H4>...
  • Page 468: Htmleditformat

    Chapter 3 ColdFusion Functions HTMLEditFormat Description Returns HTML escaped string. Carriage returns are removed from string, and special characters (> < " &) are escaped. Category Display and formatting functions HTMLEditFormat(string [, version ]) Syntax See also HTMLCodeFormat Parameters Parameter Description string String to be HTML escaped...
  • Page 469 Alphabetical List of ColdFusion Functions <!--- if we have passed a url address in the FORM, we want to display the passed address ---> <cfif IsDefined("FORM.urladdress") is True> <!--- do simple error check to avoid crashing the tag ---> <cfif Trim(Form.urladdress) is "" or Trim(Form.urladdress) is "http:/ /">...
  • Page 470 Chapter 3 ColdFusion Functions Description The function evaluates condition as a Boolean. If the result is TRUE, it returns the value of ; otherwise, it returns the value of Evaluate(string_expression1) Evaluate(string_expression2) Before using , read the Usage section and Note. is primarily intended for the conditional processing of dynamic expressions.
  • Page 471 Alphabetical List of ColdFusion Functions For example, is undefined; however, the following logic functions as you LocalVar would expect if you do not use pound signs around LocalVal <cfoutput> #IIf(IsDefined("LocalVar"), "LocalVar", DE("The variable is not defined."))# </cfoutput> The output is: The variable is not defined.
  • Page 472: Incrementvalue

    Chapter 3 ColdFusion Functions IncrementValue Description Returns integer part of number incremented by one. Category Mathematical functions IncrementValue(number) Syntax See also DecrementValue Parameters Parameter Description number Number to increment Example <!--- This shows the use of IncrementValue ---> <html> <head> <title>...
  • Page 473: Inputbasen

    Alphabetical List of ColdFusion Functions InputBaseN Description Returns the number obtained by converting string using the base specified by radix, an integer ranging from 2 to 36. Category Mathematical functions InputBaseN(string, radix) Syntax See also FormatBaseN Parameters Parameter Description string A string representing number in base specified by radix radix Base of number represented by string in the range 2 to 36...
  • Page 474: Insert

    Chapter 3 ColdFusion Functions Insert Description Inserts a substring in a string after a specified character position. Prepends the substring if position is equal to 0. Category String functions Insert(substring, string, position) Syntax See also RemoveChars, Parameters Parameter Description substring String to insert string String into which to inserted...
  • Page 475 Alphabetical List of ColdFusion Functions Description Returns the closest integer that is smaller than a number. Category Mathematical functions Int(number) Syntax See also Ceiling, Fix, Round Parameters Parameter Description number Real number to round down to an integer Example <!--- This example shows the use of Int ---> <html>...
  • Page 476: Isarray

    Chapter 3 ColdFusion Functions IsArray Description Returns TRUE if value is an array. Category Decision functions, Array functions IsArray(value [, number ]) Syntax Parameters Parameter Description value Variable or array name number Tests whether the array has exactly the specified dimension Number of elements in value Example <!--- This example shows IsArray --->...
  • Page 477: Isauthenticated

    Alphabetical List of ColdFusion Functions IsAuthenticated Description Returns TRUE if the user is authenticated for a ColdFusion security context. If you specify a security context name, returns TRUE if the user is IsAuthenticated authenticated for it. See the Usage section for crucial information. Category Decision functions IsAuthenticated([security-context-name ])
  • Page 478: Isauthorized

    Chapter 3 ColdFusion Functions IsAuthorized Description Returns TRUE if the user is authorized to perform an action on a ColdFusion resource. Category Decision functions IsAuthorized(resourcetype, resourcename [, action ]) Syntax See also IsAuthenticated Parameters Parameter Description resourcetype String that specifies the type of resource: Application CFML File...
  • Page 479 Alphabetical List of ColdFusion Functions Action types The following table shows the actions associated with each resourcetype. resourcetype Actions APPLICATION USECLIENTVARIABLES CFML Valid actions for the tag specified by resourcename FILE READ WRITE DATASOURCE CONNECT SELECT INSERT UPDATE DELETE SP (stored procedure) COMPONENT No actions for this resource type COLLECTION...
  • Page 480: Isbinary

    Chapter 3 ColdFusion Functions IsBinary Description Returns TRUE if value is binary; otherwise, returns FALSE. Category Decision functions IsBinary(value) Syntax See also ToBinary, ToBase64, IsNumeric, YesNoFormat Parameters Parameter Description value A value Example <!------------------------------------------------------------------ This example shows the use of IsBinary. It assumes that another page in a syndication program passed this page the value of the variable data_var, which can hold character or binary data.
  • Page 481: Isboolean

    Alphabetical List of ColdFusion Functions IsBoolean Description Returns TRUE if value can be converted to a Boolean; otherwise, FALSE. Category Decision functions IsBoolean(value) Syntax See also IsNumeric, YesNoFormat Parameters Parameter Description value A number or string Example <!--- This example shows the use of IsBoolean ---> <html>...
  • Page 482: Iscustomfunction

    Chapter 3 ColdFusion Functions IsCustomFunction Description Returns TRUE if name can be called as a custom function; otherwise returns FALSE. Category Decision functions IsCustomFunction(name) Syntax Parameters Parameter Description name The name of a custom function. The parameter value is the unquoted function name to check.
  • Page 483 Alphabetical List of ColdFusion Functions </cfif> </cfif> <form action = "isDate.cfm" method = "POST"> <P>Enter a string, and discover if it can be evaluated to a date value. <P><input type = "Text" name = "TheTestValue" value = "<cfoutput>#Now()#</cfoutput>"> <input type = "Submit" value = "Is it a Date?" name = ""> </FORM>...
  • Page 484: Isdate

    Chapter 3 ColdFusion Functions IsDate Description 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." See the Usage section for crucial information. Category Decision functions IsDate(string) Syntax...
  • Page 485: Isdebugmode

    Alphabetical List of ColdFusion Functions IsDebugMode Description Returns TRUE if debugging mode is set in the ColdFusion Administrator; FALSE if debugging mode is disabled. Category Decision functions IsDebugMode() Syntax Example <!--- This example shows the use of IsDebugMode ---> <html> <head>...
  • Page 486: Isdefined

    Chapter 3 ColdFusion Functions IsDefined Description Evaluates a string value to determine whether the variable named in it exists. Returns TRUE if the variable is found, FALSE if not found. is an alternative to the function, eliminating the need IsDefined ParameterExists for cumbersome expressions used to test for the existence of a variable: Evaluate("ParameterExists(#var_name#)")
  • Page 487: Isleapyear

    Alphabetical List of ColdFusion Functions IsLeapYear Description Returns TRUE if the year is a leap year; otherwise, FALSE. Category Decision functions IsLeapYear(year) Syntax See also DaysInYear Parameters Parameter Description year Number representing a year Example <!--- This example shows the use of IsLeapYear ---> <html>...
  • Page 488: Isnumeric

    Chapter 3 ColdFusion Functions IsNumeric Description Returns TRUE if string can be converted to a number; otherwise, FALSE. Supports numbers in U.S. number format. For international number support, use LSIsNumeric Category Decision functions IsNumeric(string) Syntax See also IsBinary Parameters Parameter Description string A string value...
  • Page 489: Isnumericdate

    Alphabetical List of ColdFusion Functions IsNumericDate Description Evaluates "real value" of date/time object. Returns TRUE if the number represents "real value" of the date/time object; otherwise, FALSE. Category Decision functions IsNumericDate(number) Syntax See also IsDate, ParseDateTime Parameters Parameter Description number Real number Example <!--- This example shows the use of IsNumericDate --->...
  • Page 490: Isprotected

    Chapter 3 ColdFusion Functions IsProtected Description Returns TRUE if a resource is protected in an authenticated user’s security context. Category Decision functions IsProtected(resourcetype, resourcename [, action]) Syntax See also IsAuthorized Parameters Parameter Description resourcetype String that specifies the type of resource: Application CFML File...
  • Page 491 Alphabetical List of ColdFusion Functions Action types The following table shows the actions associated with each resource type:. resourcetype Actions APPLICATION USECLIENTVARIABLES CFML Valid actions for the tag specified by resourcename FILE READ WRITE DATASOURCE CONNECT SELECT INSERT UPDATE DELETE SP (stored procedure) COMPONENT No actions for this resource type...
  • Page 492 Chapter 3 ColdFusion Functions </cfoutput> </cfif> </cfif> </body> </html>...
  • Page 493: Isquery

    Alphabetical List of ColdFusion Functions IsQuery Description Returns TRUE if value is a query. Category Decision functions IsQuery(value) Syntax See also QueryAddRow Parameters Parameter Description value Query variable Example <!--- Shows an example of IsQuery and IsSimpleValue ---> <html> <head> <title>IsQuery Example</title>...
  • Page 494: Issimplevalue

    Chapter 3 ColdFusion Functions IsSimpleValue Description Returns TRUE if value is a string, number, Boolean, or date/time value. Category Decision functions IsSimpleValue(value) Syntax Parameters Parameter Description value Variable or expression Example <!--- Shows an example of IsQuery and IsSimpleValue ---> <html>...
  • Page 495: Isstruct

    Alphabetical List of ColdFusion Functions IsStruct Description Returns TRUE if variable is a structure. Category Structure functions IsStruct(variable ) Syntax Parameters Parameter Description variable Variable name Example <!--- This view-only example illustrates usage of IsStruct. ---> <P>This file is similar to addemployee.cfm, which is called by StructNew, StructClear, and StructDelete.
  • Page 496: Iswddx

    Chapter 3 ColdFusion Functions IsWDDX Description Returns TRUE if the value is a well formed WDDX packet and FALSE if not. Category Decision functions IsWDDX(value) Syntax Parameters Parameter Description value A WDDX packet. This function processes the WDDX packet specified in e using a validating XML Usage valu...
  • Page 497 Alphabetical List of ColdFusion Functions <CFWDDX ACTION="WDDX2CFML" INPUT=#packet# OUTPUT="s" VALIDATE="yes"...
  • Page 498: Javacast

    Chapter 3 ColdFusion Functions JavaCast Description Indicates the data type conversion of a ColdFusion variable to pass as an argument to an overloaded method of a Java object. It should be used only for scalar and string arguments. Category String functions JavaCast(type, variable) Syntax See also...
  • Page 499: Jsstringformat

    Alphabetical List of ColdFusion Functions JSStringFormat Description Returns a string that is safe to use with JavaScript. Category String functions JSStringFormat(string) Syntax Parameters Parameter Description string A string escapes special JavaScript characters, such as single quote, double Usage JSStringFormat quote, and newline, so you can put arbitrary strings safely into JavaScript. Example <!----------------------------------------------------------- This example illustrates use of the JSStringFormat function.
  • Page 500: Lcase

    Chapter 3 ColdFusion Functions LCase Description Returns string converted to lowercase. Category String functions LCase(string) Syntax See also UCase Parameters Parameter Description string String to convert to lowercase Example <!--- This example shows the use of LCase ---> <html> <head> <title>...
  • Page 501: Left

    Alphabetical List of ColdFusion Functions Left Description Returns the count of characters from the beginning of a string argument. Category String functions Left(string, count) Syntax See also Right, Mid, Parameters Parameter Description string String from which the leftmost characters are retrieved count Positive integer;...
  • Page 502 Chapter 3 ColdFusion Functions Description Returns the length of a string or binary object. Category String functions Len(string or binary object) Syntax See also ToBinary, Left, Right, Parameters Parameter Description string A string or binary object Example <!--- This example shows the use of Len ---> <html>...
  • Page 503: Listappend

    Alphabetical List of ColdFusion Functions ListAppend Description Returns list with value appended to its last element. Category List functions ListAppend(list, value [, delimiters ]) Syntax See also ListPrepend, ListInsertAt, ListSetAt Parameters Parameter Description list A list value Number or list to append delimiters Set of delimiters used in list Usage...
  • Page 504: Listchangedelims

    Chapter 3 ColdFusion Functions ListChangeDelims Description Returns list with delimiter characters changed to new_delimiter string. Category List functions ListChangeDelims(list, new_delimiter [, delimiters ]) Syntax See also ListFirst, ListQualify Parameters Parameter Description list List of delimiters to change new_delimiter String to use as a new delimiter delimiters Set of delimiters used in list Example...
  • Page 505: Listcontains

    Alphabetical List of ColdFusion Functions ListContains Description Returns the index of the first item that contains a specified substring. The search is case-sensitive. If the substring is not found in the list items, it returns zero (0). Category List functions ListContains(list, substring [, delimiters ]) Syntax See also...
  • Page 506 Chapter 3 ColdFusion Functions it will not find the substring "wo" in the list. <BR>ListFind<BR> <cfoutput> The substring "wo" is in <b>Item #ListFind(aList, "wo")#</b> of the list. </cfoutput> <P> However, if you specify the entire string <B>two</B>, both ListContains and ListFind will find it in the second item in the list. <BR>ListContains<BR>...
  • Page 507: Listcontainsnocase

    Alphabetical List of ColdFusion Functions ListContainsNoCase Description Returns the index of the first element of a list that contains a specified substring within elements. The search is case-insensitive. If no element is found, returns 0. Category List functions ListContainsNoCase(list, substring [, delimiters ]) Syntax See also ListContains, ListFindNoCase.
  • Page 508: Listdeleteat

    Chapter 3 ColdFusion Functions ListDeleteAt Description Returns list with element deleted at the specified position. Category List functions ListDeleteAt(list, position [, delimiters ]) Syntax See also ListGetAt, ListSetAt, ListLen. Parameters Parameter Description list A list. position Positive integer that indicates the position of the element to delete. The starting position in a list is denoted by the number 1, not 0.
  • Page 509: Listfind

    Alphabetical List of ColdFusion Functions ListFind Description Returns the index of the first occurrence of a value within a list. Returns 0 if no value is found. The search is case-sensitive. Category List functions ListFind(list, value [, delimiters ]) Syntax See also ListContains, ListFindNoCase...
  • Page 510 Chapter 3 ColdFusion Functions it will not find the substring "wo" in the list. <BR>ListFind<BR> <cfoutput> The substring "wo" is in <b>Item #ListFind(aList, "wo")#</b> of the list. </cfoutput> <P> However, if you specify the entire string <B>two</B>, both ListContains and ListFind will find it in the second item in the list. <BR>ListContains<BR>...
  • Page 511: Listfindnocase

    Alphabetical List of ColdFusion Functions ListFindNoCase Description Returns the index of the first occurrence of a value within a list. Returns 0 if no value was found. The search is case-insensitive. Category List functions ListFindNoCase(list, value [, delimiters ]) Syntax See also ListContains ListFind...
  • Page 512: Listfirst

    Chapter 3 ColdFusion Functions ListFirst Description Returns the first element of the list. Category List functions ListFirst(list [, delimiters ]) Syntax See also ListGetAt, ListLast, ListQualify Parameters Parameter Description list List whose first element to retrieve delimiters Set of delimiters used in list Usage Note ColdFusion ignores empty list elements;...
  • Page 513: Listgetat

    Alphabetical List of ColdFusion Functions ListGetAt Description Returns the element at a given position. Category List functions ListGetAt(list, position [, delimiters ]) Syntax See also ListFirst, ListLast, ListQualify, ListSetAt Parameters Parameter Description list List whose element to retrieve position Positive integer; position of the element to retrieve delimiters Set of delimiters used in list Usage...
  • Page 514: Listinsertat

    Chapter 3 ColdFusion Functions ListInsertAt Description Returns list with value inserted at the specified position. Category List functions ListInsertAt(list, position, value [, delimiters ]) Syntax See also ListDeleteAt, ListAppend, ListPrepend, ListSetAt Parameters Parameter Description list A list. position Position in which to insert a value. The first position in a list is denoted by the number 1, not 0.
  • Page 515: Listlast

    Alphabetical List of ColdFusion Functions ListLast Description Returns the last element of the list. Category List functions ListLast(list [, delimiters ]) Syntax See also ListGetAt, ListFirst Parameters Parameter Description list List whose last element to retrieve delimiters Set of delimiters used in list Usage Note ColdFusion ignores empty list elements;...
  • Page 516: Listlen

    Chapter 3 ColdFusion Functions ListLen Description Returns the number of elements in the list. Category List functions ListLen(list [, delimiters ]) Syntax See also ListAppend, ListDeleteAt, ListInsertAt, ListPrepend. Parameters Parameter Description list A list delimiters Set of delimiters used in list Usage Note ColdFusion ignores empty list elements;...
  • Page 517: Listprepend

    Alphabetical List of ColdFusion Functions ListPrepend Description Returns list with value inserted at the first position, shifting other elements to the right. Category List functions ListPrepend(list, value [, delimiters ]) Syntax See also ListAppend, ListInsertAt, ListSetAt Parameters Parameter Description list A list value Number or list to prepend...
  • Page 518: Listqualify

    Chapter 3 ColdFusion Functions ListQualify Description Returns a list with a qualifying character around each item in the list, such as double or single quotes. Category List functions ListQualify(list, qualifier [, delimiters ] [, elements ]) Syntax Parameters Parameter Description list A list of items or a variable that names a list.
  • Page 519 Alphabetical List of ColdFusion Functions <CFLOOP query = "GetEmployeeNames"> <cfset temp = ArrayAppend(myArray, "#FirstName# #LastName#")> </CFLOOP> <!--- sort that array descending alphabetically ---> <cfset myAlphaArray = ArraySort(myArray, "textnocase")> <!--- show the resulting array as a list ---> <cfset myList = ArrayToList(myArray, ",")> <cfoutput>...
  • Page 520: Listrest

    Chapter 3 ColdFusion Functions ListRest Description Returns list without its first element. Returns an empty list (empty string) if list has only one element. Category List functions ListRest(list [, delimiters ]) Syntax See also ListFirst, ListGetAt, ListLast Parameters Parameter Description list List whose elements to retrieve delimiters...
  • Page 521: Listsetat

    Alphabetical List of ColdFusion Functions ListSetAt Description Returns list with value assigned to its element at specified position. Category List functions ListSetAt(list, position, value [, delimiters ]) Syntax See also ListDeleteAt, ListGetAt, ListInsertAt Parameters Parameter Description list A list. position A position.
  • Page 522 Chapter 3 ColdFusion Functions <!--- loop through the list and show it with ListGetAt ---> <H3>This is a list of <cfoutput>#ListLen(temp)#</cfoutput> subjects posted in messages.</H3> <cfset ChangedItem = ListGetAt(temp, 2, ",")> <cfset TempToo = ListSetAt(temp, 2, "I changed this subject", ",")> <UL>...
  • Page 523: Listsort

    Alphabetical List of ColdFusion Functions ListSort Description Sorts and delimits the items in a list according to a sort type and sort order. Category List functions ListSort(list, sort_type [, sort_order] [, delimiter ]) Syntax Parameters Parameter Description list List to sort. List items must be separated by commas or another delimiter.
  • Page 524 Chapter 3 ColdFusion Functions <cfoutput> #sortedList# </cfoutput> <P>Here is a numeric list that is to be sorted in descending order.</P> <cfset sortedNums = ListSort("12,23,107,19,1,65","Numeric", "Desc")> <cfoutput> #sortedNums# </cfoutput> <P>Here is a list that must be sorted numerically, since it contains negative and positive numbers, as well as decimal numbers. </P> <cfset sortedNums2 = ListSort("23.75;-34,471:100,-9745","Numeric", "ASC", ";,:")>...
  • Page 525: Listtoarray

    Alphabetical List of ColdFusion Functions ListToArray Description Converts a list to an array. Category List functions ListToArray(list [, delimiter ]) Syntax See also ArrayToList Parameters Parameter Description list Name of the list variable that contains the elements to use to build an array.
  • Page 526: Listvaluecount

    Chapter 3 ColdFusion Functions ListValueCount Description Returns the number of instances of a specified value in a list. The search is case-sensitive. Category List functions ListValueCount(list, value [, delimiters ]) Syntax See also ListValueCountNoCase Parameters Parameter Description list A list or the name of a list to search. value The string or number that the function is to find and count.
  • Page 527 Alphabetical List of ColdFusion Functions </OPTION> </select> <input type = "Submit" name = "Submit" value = "Search Employee List"> </FORM> <!--- wait to have a string for searching defined ---> <cfif IsDefined("FORM.Submit") and IsDefined("FORM.departmentName")> <cfset myList = ValueList(SearchByDepartment.Department)> <cfset numberInDepartment = ListValueCount(myList, FORM.departmentName)>...
  • Page 528: Listvaluecountnocase

    Chapter 3 ColdFusion Functions ListValueCountNoCase Description Returns the number of instances of a value in a list. The search is not case-sensitive. Category List functions ListValueCountNoCase(list, value [, delimiters ]) Syntax See also ListValueCount Parameters Parameter Description list A list or the name of a list to search. value The string or number that the function is to find and count.
  • Page 529 Alphabetical List of ColdFusion Functions </select> </select> <input type = "Submit" name = "Submit" value = "Search Employee List"> </FORM> <!--- 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)>...
  • Page 530: Ljustify

    Chapter 3 ColdFusion Functions LJustify Description Returns left-justified string of a field length. Category String functions LJustify(string, length) Syntax See also CJustify, RJustify Parameters Parameter Description string String to left-justify length Length of field Example <!--- This example shows how to use LJustify ---> <CFPARAM name = "jstring"...
  • Page 531 Alphabetical List of ColdFusion Functions Description Returns the natural logarithm of a number. Natural logarithms are based on the constant e (2.71828182845904). Category International functions Log(number) Syntax See also Exp, Log10 Parameters Parameter Description number Positive real number for which you want the natural logarithm Example <!--- This example shows how to use Log --->...
  • Page 532: Log10

    Chapter 3 ColdFusion Functions Log10 Description Returns the logarithm of number to base 10. Category International functions Log10(number) Syntax See also Exp, Parameters Parameter Description number Positive real number for which you want the logarithm Example <!--- This example shows how to use Log10 ---> <html>...
  • Page 533: Lscurrencyformat

    Alphabetical List of ColdFusion Functions LSCurrencyFormat Description Returns a currency value using the locale convention. Default value is "local." Category International functions LSCurrencyFormat(number [, type ]) Syntax See also LSEuroCurrencyFormat Parameters Parameter Description number The currency value. type Currency type. Arguments are: none For example, 10.00 (default) For example, $10.00...
  • Page 534 Chapter 3 ColdFusion Functions Locale Format Type Output (continued) Local: 100 000,00 $ French (Canadian) International: CAD100 000,00 None: 100 000,00 Local: 100 000,00 F French (Standard) International: FRF100 000,00 None: 100 000,00 French (Swiss) Local: SFr. 100’000.00 International: CHF100’000.00 None: 100’000.00 Local: öS 100.000,00 German (Austrian)
  • Page 535 Alphabetical List of ColdFusion Functions Example <!--- This shows LSCurrencyFormat ---> <html> <head> <title>LSCurrencyFormat Example</title> </head> <body> <H3>LSCurrencyFormat Example</H3> <P>LSCurrencyFormat returns a currency value using the locale convention. Default value is "local." <!--- loop through a list of locales and show currency values for 100,000 units --->...
  • Page 536: Lsdateformat

    Chapter 3 ColdFusion Functions LSDateFormat Description Formats the date portion of a date/time value using the locale convention. Like returns a formatted date/time value. If no mask is DateFormat LSDateFormat specified, returns a date value using the locale-specific format. LSDateFormat Category International functions LSDateFormat(date [, mask ])
  • Page 537 Alphabetical List of ColdFusion Functions <!--- loop through a list of locales; show date values for Now()---> <CFLOOP LIST = "#Server.Coldfusion.SupportedLocales#" INDEX = "locale" DELIMITERS = ","> <cfset oldlocale = SetLocale(locale)> <cfoutput><P><B><I>#locale#</I></B><BR> #LSDateFormat(Now(), "mmm-dd-yyyy")#<BR> #LSDateFormat(Now(), "mmmm d, yyyy")#<BR> #LSDateFormat(Now(), "mm/dd/yyyy")#<BR> #LSDateFormat(Now(), "d-mmm-yyyy")#<BR>...
  • Page 538: Lseurocurrencyformat

    Chapter 3 ColdFusion Functions LSEuroCurrencyFormat Description Returns a currency value using the convention of the locale and the euro as the currency symbol. Default value is "local." Category International functions LSEuroCurrencyFormat(currency-number [, type ]) Syntax See also LSParseEuroCurrency, LSCurrencyFormat, SetLocale Parameters Parameter Description...
  • Page 539 Alphabetical List of ColdFusion Functions Locale Format Type Output English (Canadian) Local: 100,000.00 International: EUR100,000.00 None: 100,000.00 English (New Zealand) Local: 100,000.00 International: EUR100,000.00 None: 100,000.00 English (UK) Local: 100,000.00 International: EUR100,000.00 None: 100,000.00 English (US) Local: 100,000.00 International: EUR100,000.00 None: 100,000.00 French (Belgian) Local: 100.000,00...
  • Page 540 Chapter 3 ColdFusion Functions Locale Format Type Output Portuguese (Brazilian) Local: 100.000,00 International: EUR100.000,00 None: 100.000,00 Portuguese (Standard) Local: 100.000,00 International: EUR100.000,00 None: 100.000,00 Spanish (Mexican) Local: 100,000.00 International: EUR100,000.00 None: 100,000.00 Spanish (Modern) Local: 10.000.000 International: EUR10.000.000 None: 10.000.000 Spanish (Standard) Local: 10.000.000 International: EUR10.000.000...
  • Page 541: Lsiscurrency

    Alphabetical List of ColdFusion Functions LSIsCurrency Description Checks whether a string is a locale-specific currency string. Returns TRUE if string is a currency string, FALSE otherwise. Category International functions LSIsCurrency(string) Syntax Parameters Parameter Description string A locale-specific currency string Example <!--- This example shows LSIsCurrency --->...
  • Page 542: Lsisdate

    Chapter 3 ColdFusion Functions LSIsDate Description Like the function, returns TRUE if string can be converted to a IsDate LSIsDate date/time value in the current locale, FALSE otherwise. Category International functions LSIsDate(string) Syntax Parameters Parameter Description string A string value Years less than 100 are interpreted as 20 century dates.
  • Page 543: Lsisnumeric

    Alphabetical List of ColdFusion Functions LSIsNumeric Description Like the function, returns TRUE if string can be converted to IsNumeric LSIsNumeric a number in the current locale; otherwise, FALSE. Category International functions LSIsNumeric(string) Syntax Parameters Parameter Description string Any string value Example <!--- This example shows LSIsNumeric --->...
  • Page 544: Lsnumberformat

    Chapter 3 ColdFusion Functions LSNumberFormat Description Formats a number using the locale convention. If mask is omitted, the number is formatted as an integer. Category International functions LSNumberFormat(number [, mask ]) Syntax Parameters Parameter Description number The number to format mask LSNumberFormat mask characters apply, except that ($) dollar, (,) comma, and (.) dot are mapped to their locale-specific...
  • Page 545 Alphabetical List of ColdFusion Functions Note If you do not specify a sign for the mask, positive and negative numbers do not align in columns. If you expect to display positive and negative numbers in your application, use a space or - (hyphen) to force a space in front of positive numbers and a minus sign in front of negative numbers.
  • Page 546 Chapter 3 ColdFusion Functions Number Mask Result 3.21 C__(^)__ " (3.21) " 12345678 12345678 Example <!--- This shows LSNumberFormat ---> <html> <head> <title>LSNumberFormat Example</title> </head> <body> <H3>LSNumberFormat Example</H3> <P>LSNumberFormat returns a number value using the locale convention. <!--- loop through a list of locales and show number values --->...
  • Page 547: Lsparsecurrency

    Alphabetical List of ColdFusion Functions LSParseCurrency Description Converts a locale-specific currency string to a number. Attempts conversion through each of the default currency formats (none, local, international). Returns the number matching the value of string. Category International functions LSParseCurrency(string) Syntax See also LSCurrencyFormat, LSParseEuroCurrency...
  • Page 548 Chapter 3 ColdFusion Functions Locale Format Type Output Local: 100 000,00 F French (Standard) International: FRF100 000,00 None: 100 000,00 Local: SFr. 100’000.00 French (Swiss) International: CHF100’000.00 None: 100’000.00 German (Austrian) Local: öS 100.000,00 International: ATS100.000,00 None: 100.000,00 Local: 100.000,00 DM German (Standard) International: DEM100.000,00 None: 100.000,00...
  • Page 549 Alphabetical List of ColdFusion Functions Example <!--- This example shows LSParseCurrency ---> <html> <head> <title>LSParseCurrency Example</title> </head> <body> <H3>LSParseCurrency Example</H3> <P>LSParseCurrency coverts a local-specific currency string to a number. Attempts conversion through each of the three default currency formats. <!--- loop through a list of locales and show currency values for 123,456 units --->...
  • Page 550: Lsparsedatetime

    Chapter 3 ColdFusion Functions LSParseDateTime Description A locale-specific version of the function, except that there is no ParseDateTime option for POP date/time object parsing. Returns a date/time object. International functions LSParseDateTime(date/time-string) Syntax See also ParseDateTime, SetLocale Parameters Parameter Description date/time-string String to convert to date/time object.
  • Page 551 Alphabetical List of ColdFusion Functions <body> <H3>LSParseDateTime Example</H3> <P>LSParseDateTime returns a locale-specific date/time object. <!--- loop through a list of locales and show date values for Now()---> <CFLOOP LIST = "#Server.Coldfusion.SupportedLocales#" INDEX = "locale" DELIMITERS = ","> <cfset oldlocale = SetLocale(locale)> <cfoutput><P><B><I>#locale#</I></B><BR>...
  • Page 552: Lsparseeurocurrency

    Chapter 3 ColdFusion Functions LSParseEuroCurrency Description Converts a locale-specific currency string that contains the Euro symbol ( ) or sign (EUR) to a number. Attempts conversion through each of the default currency formats (none, local, international). Returns the number that matches the value of string.
  • Page 553 Alphabetical List of ColdFusion Functions <Hr noshade> </cfoutput> </CFLOOP> </body> </html>...
  • Page 554: Lsparsenumber

    Chapter 3 ColdFusion Functions LSParseNumber Description Converts a locale-specific string to a number. Returns the number that matches the value of string. Category International functions LSParseNumber(string) Syntax Parameters Parameter Description string String to convert to a number Example <!--- This shows LSParseNumber ---> <html>...
  • Page 555: Lstimeformat

    Alphabetical List of ColdFusion Functions LSTimeFormat Description Returns a custom-formatted time value using the locale convention. Category International functions LSTimeFormat(time [, mask ]) Syntax See also LSParseDateTime Parameters Parameter Description string A date/time value or string convertible to a time value. mask Masking characters that determine the format: Hours;...
  • Page 556 Chapter 3 ColdFusion Functions <cfoutput><P><B><I>#locale#</I></B><BR> #LSTimeFormat(Now())#<BR> #LSTimeFormat(Now(), ‘hh:mm:ss’)#<BR> #LSTimeFormat(Now(), ‘hh:mm:sst’)#<BR> #LSTimeFormat(Now(), ‘hh:mm:sstt’)#<BR> #LSTimeFormat(Now(), ‘HH:mm:ss’)#<BR> <Hr noshade> </cfoutput> </CFLOOP> </body> </html>...
  • Page 557: Ltrim

    Alphabetical List of ColdFusion Functions LTrim Description Returns string with leading spaces removed. Category String functions LTrim(string) Syntax See also RTrim, ToBase64 Parameters Parameter Description string String to left-trim. Example <!--- This example shows the use of LTrim ---> <html> <head>...
  • Page 558 Chapter 3 ColdFusion Functions Description Returns the higher value of two numbers. Category Date and time functions Max(number1, number2) Syntax See also Parameters Parameter Description number1, number2 Any numbers. Example <!--- This example shows the Max and Min of two numbers ---> <html>...
  • Page 559 Alphabetical List of ColdFusion Functions Description Returns count characters from string beginning at start position. Category Date and time functions Mid(string, start, count) Syntax See also Left, Len, Right Parameters Parameter Description string Any string. start Starting position for count. count Number of characters to return Example...
  • Page 560 Chapter 3 ColdFusion Functions Description Returns the smaller, value of two numbers. Category Date and time functions Min(number1, number2) Syntax See also Parameters Parameter Description number1, number2 Any numbers. Example <!--- This example shows the Max and Min of two numbers ---> <html>...
  • Page 561: Minute

    Alphabetical List of ColdFusion Functions Minute Description Returns the ordinal for the minute, in the range 0–59. Category Date and time functions Minute(date) Syntax See also DatePart, Hash, Second Parameters Parameter Description date A date/time object. Usage Year values 0 - 29 are interpreted as 21 century dates.
  • Page 562: Month

    Chapter 3 ColdFusion Functions Month Description Returns the ordinal for the month, ranging from 1 (January) to 12 (December). Category Date and time functions Month(Date) Syntax See also DatePart, MonthAsString, Quarter Parameters Parameter Description date A date/time object. Usage Year values 0 - 29 are interpreted as 21 century dates.
  • Page 563: Monthasstring

    Alphabetical List of ColdFusion Functions MonthAsString Description Returns the name of the month corresponding to month_number. Category Date and time functions MonthAsString(month_number) Syntax See also DatePart, Month, Quarter Parameters Parameter Description month_number An integer ranging from 1 to 12. Example <!--- shows the value of the MonthAsString function --->...
  • Page 564 Chapter 3 ColdFusion Functions Description Returns the current date and time of the computer running the ColdFusion server. The date and time is in the form of a date/time object, which can be passed as a parameter to many date functions, such as DaysInYear FirstDayOfMonth Category...
  • Page 565: Numberformat

    Alphabetical List of ColdFusion Functions NumberFormat Description Creates a custom-formatted number value. If no mask is specified, returns the value as an integer with a thousands separator. supports the numeric NumberFormat formatting used in the U.S. For international number formatting, see LSNumberFormat Category Display and formatting functions...
  • Page 566 Chapter 3 ColdFusion Functions Note If you do not specify a sign for the mask, positive and negative numbers do not align in columns. If you expect to display positive and negative numbers in your application, use the space or - (minus sign) to force a space in front of positive numbers and a minus sign in front of negative numbers.
  • Page 567 Alphabetical List of ColdFusion Functions Number Mask Result 3.21 C__(^)__ " (3.21) " 12345678 12345678 When converting string to double, this function adds a rounding factor of 1.5543122344752E-014 to the converted number to prevent rounding errors. 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 568: Paragraphformat

    Chapter 3 ColdFusion Functions ParagraphFormat Description Returns string with converted single newline characters (CR/LF sequences) into spaces and double newline characters into HTML paragraph markers ( <p> Category Display and formatting functions ParagraphFormat(string) Syntax See also StripCR Parameters Parameter Description string String to convert to the HTML paragraph format ParagraphFormat is useful for displaying data entered into TEXTAREA fields.
  • Page 569: Parameterexists

    Alphabetical List of ColdFusion Functions ParameterExists Description Returns True if the specified parameter has been passed to the current template or has already been created during execution of the current template. Otherwise returns NO. This function is provided for backward compatibility with previous versions of ColdFusion.
  • Page 570: Parsedatetime

    Chapter 3 ColdFusion Functions ParseDateTime Description Returns a date/time object from a string. converts date/time strings ParseDateTime that are in the U.S. date format. Use for international date parsing. LSParseDateTime Category Date and time functions ParseDateTime(date/time-string [, pop-conversion ] ) Syntax See also IsDate,...
  • Page 571 Alphabetical List of ColdFusion Functions <cfif IsDefined("FORM.theTestValue")> <cfif IsDate(FORM.theTestValue)> <H3>The expression <cfoutput>#DE(FORM.theTestValue)#</cfoutput> is a valid date</H3> <P>The date, parsed for use as a date/time value: <cfoutput>#ParseDateTime(FORM.theTestValue)#</cfoutput>...
  • Page 572 Chapter 3 ColdFusion Functions Description Returns the number 3.14159265358979, the mathematical constant , accurate to 15 digits. Category Mathematical functions Pi() Syntax See also ASin, Cos, Sin, Example <!--- This shows the use of Pi ---> <html> <head> <title> Pi Example </title>...
  • Page 573: Preservesinglequotes

    Alphabetical List of ColdFusion Functions PreserveSingleQuotes Description Prevents ColdFusion from automatically "escaping" single quotes contained in variable. Category Other functions PreserveSingleQuotes(variable) Syntax Parameters Parameter Description variable Variable that contains a string for which single quotes are preserved. Usage is useful in SQL statements. PreserveSingleQuotes Example <!--- This example shows the use of PreserveSingleQuotes --->...
  • Page 574: Quarter

    Chapter 3 ColdFusion Functions Quarter Description calculates and returns an integer (1–4) of the year quarter in which the date Quarter falls. Category Date and time functions Quarter(date) Syntax See also DatePart, Month Parameters Parameter Description date Any date. Year values 0 - 29 are interpreted as 21 century dates.
  • Page 575: Queryaddcolumn

    Alphabetical List of ColdFusion Functions QueryAddColumn Description Adds a new column to a specified query and populates the column’s rows with the contents of a one-dimensional array. Returns the number of the column that has been added. Padding is added, if necessary, on the query columns to ensure that all columns have the same number of rows.
  • Page 576 Chapter 3 ColdFusion Functions <P>After populating the query, the example shows, in tabular format, the contents of the columns.</P> <!--- make a new query ---> <cfset myQuery = QueryNew("")> <!--- create an array ---> <cfset FastFoodArray = ArrayNew(1)> <cfset FastFoodArray[1] = "French Fries"> <cfset FastFoodArray[2] = "Hot Dogs">...
  • Page 577: Queryaddrow

    Alphabetical List of ColdFusion Functions QueryAddRow Description Adds a specified number of empty rows to a query. Returns the total number of rows in the query that you are adding rows to. Category Query functions QueryAddRow(query [, number ]) Syntax See also QueryAddColumn, QueryAddRow, QuerySetCell, QueryNew...
  • Page 578: Querynew

    Chapter 3 ColdFusion Functions QueryNew Description Returns an empty query with a set of columns or an empty query. See Usage for more information. Category Query functions QueryNew(columnlist) Syntax See also QueryAddColumn, QueryAddRow, QuerySetCell Parameters Parameter Description columnlist Comma-separated list of columns to add to the query or an empty string.
  • Page 579: Querysetcell

    Alphabetical List of ColdFusion Functions QuerySetCell Description Sets the cell in a column to a value. If no row number is specified, the cell on the last row is set. Returns TRUE. Category Query functions QuerySetCell(query, column_name, value [, row_number ]) Syntax See also QueryAddColumn, QueryAddRow,...
  • Page 580 Chapter 3 ColdFusion Functions <P>After the QueryAddRow action, the query has <cfoutput>#GetCourses.RecordCount#</cfoutput> records. <cfoutput query = "GetCourses"> <PRE>#Course_ID##Course_Num##Descript#</PRE> </cfoutput> </body> </html>...
  • Page 581: Quotedvaluelist

    Alphabetical List of ColdFusion Functions QuotedValueList Description Returns a comma-separated list of the values of each record returned from a previously executed query. Each value in the list is enclosed in single quotes. Category Query functions QuotedValueList(query.column [, delimiter ]) Syntax See also ValueList...
  • Page 582: Rand

    Chapter 3 ColdFusion Functions Rand Description Returns a random decimal number in the range 0 - 1. Category Mathematical functions Rand() Syntax See also Randomize, RandRange Usage To ensure greater randomness, call before calling Randomize Rand Example <!--- This example shows the use of Rand() ---> <html>...
  • Page 583: Randomize

    Alphabetical List of ColdFusion Functions Randomize Description Seeds the random number generator in ColdFusion with the integer part of a number. By seeding the generator with a variable value, you help ensure that the Rand function generates highly random numbers. Category Mathematical functions Randomize(number)
  • Page 584: Randrange

    Chapter 3 ColdFusion Functions RandRange Description Returns a random integer between two specified numbers. Requests for random integers greater than 100,000,000 result in nonrandom behavior. This restriction prevents overflow during internal computations. Category Mathematical functions RandRange(number1, number2) Syntax See also Rand, Randomize Parameters...
  • Page 585: Refind

    Alphabetical List of ColdFusion Functions REFind Description Returns the position of the first occurrence of a regular expression in a string starting from a specified position. Returns 0 if no occurrences are found. The search is case sensitive. Returns the position and length of the first occurrence of a regular expression in a string, if the returnsubexpressions parameter is set to True.
  • Page 586 Chapter 3 ColdFusion Functions Example <!--- This example shows the use of REFind ---> <html> <head> <title> REFind Example </title> </head> <body> <H3>REFind Example</H3> <P>This example shows the use of the REFind function with and without the <i>returnsubexpressions</i> parameter set to True.</P> If you do not use the <i>returnsubexpressions</i>...
  • Page 587 Alphabetical List of ColdFusion Functions </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> <P>...
  • Page 588: Refindnocase

    Chapter 3 ColdFusion Functions REFindNoCase Description Returns the position of the first occurrence of a regular expression in a string starting from a specified position, if the returnsubexpressions parameter is not set to True. Returns 0 if no occurrences are found. The search is case-insensitive. Returns the position and length of the first occurrence of a regular expression in a string, if the returnsubexpressions parameter is set to True.
  • Page 589 Alphabetical List of ColdFusion Functions the regular expression in the first element of the respective arrays; the position and length of the first instance of each subexpression within the regular expression are returned in subsequent array elements. Example <!--- This example shows the use of REFindNoCase ---> <html>...
  • Page 590 Chapter 3 ColdFusion Functions <P>To create this structure you can use a CFSET statement, for example:</P> &lt;CFSET st = REFindNoCase("[[:alpha:]]+",testString,1,"TRUE")&gt; <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 591: Removechars

    Alphabetical List of ColdFusion Functions RemoveChars Description Returns string with count characters removed from a specified starting position. Return 0 if no characters are found. Category String functions RemoveChars(string, start, count) Syntax See also Insert, Parameters Parameter Description string A string start Starting position for the search count...
  • Page 592: Repeatstring

    Chapter 3 ColdFusion Functions RepeatString Description Returns a string created from string repeated a specified number of times. Category String functions RepeatString(string, count) Syntax See also CJustify, LJustify, RJustify Parameters Parameter Description string String to repeat count Number of repeats Example <!--- This example shows RepeatString --->...
  • Page 593: Replace

    Alphabetical List of ColdFusion Functions Replace Description Returns string with occurrences of substring1 replaced with substring2 in a specified scope. Category String functions Replace(string, substring1, substring2 [, scope ]) Syntax See also REFind, ReplaceNoCase, ReplaceList, REReplace Parameters Defines how to complete the replace operation: Parameter Description string...
  • Page 594: Replacelist

    Chapter 3 ColdFusion Functions ReplaceList Description Returns string with occurrences of the elements from a specified comma-delimited list replaced with corresponding elements from another comma-delimited list. The search is case-sensitive. Category String functions ReplaceList(string, list1, list2) Syntax See also Find, REFind, Replace, REReplace Parameters Parameter...
  • Page 595 Alphabetical List of ColdFusion Functions <P>Substring 1 (find this list of substrings) <BR><input type = "Text" value = "Test, String" name = "MySubstring1"> <P>Substring 2 (replace with this list of substrings) <BR><input type = "Text" value = "Replaced, Sentence" name = "MySubstring2">...
  • Page 596: Replacenocase

    Chapter 3 ColdFusion Functions ReplaceNoCase Description Returns string with occurrences of substring1 replaced, regardless of case, matching with substring2 in the specified scope. Category String functions ReplaceNoCase(string, substring1, substring2 [, scope ]) Syntax See also REFind, Replace, ReplaceList, REReplace Parameters Parameter Description string...
  • Page 597: Rereplace

    Alphabetical List of ColdFusion Functions REReplace Description Returns string with a regular expression replaced with substring in the specified scope. This is a case-sensitive search. Category String functions REReplace(string, reg_expression, substring [, scope ]) Syntax See also REFind, Replace, ReplaceList, REReplaceNoCase Parameters Parameter...
  • Page 598: Rereplacenocase

    Chapter 3 ColdFusion Functions REReplaceNoCase Description Returns string with a regular expression replaced with substring in the specified scope. The search is case-insensitive. Category String functions REReplaceNoCase(string, reg_expression, substring [, scope ]) Syntax See also REFind, REFindNoCase, Replace, ReplaceList Parameters Parameter Description string...
  • Page 599: Reverse

    Alphabetical List of ColdFusion Functions Reverse Description Returns string with reversed order of characters. Category String functions Reverse(string) Syntax See also Left, Mid, Right Parameters Parameter Description string String to reverse Example <!--- This example shows the use of Reverse ---> <html>...
  • Page 600: Right

    Chapter 3 ColdFusion Functions Right Description Returns the rightmost count characters of a string. Category String functions Right(string, count) Syntax See also Mid, Left, Reverse Parameters Parameter Description string String from which the rightmost characters are retrieved count Integer; number of characters to return Example <!--- This example shows the use of Right --->...
  • Page 601: Rjustify

    Alphabetical List of ColdFusion Functions RJustify Description Returns right-justified string in the specified field length. Category String functions RJustify(string, length) Syntax See also CJustify, LJustify Parameters Parameter Description string String to right-justify length Length of field Example <!--- This example shows how to use RJustify ---> <CFPARAM name = "jstring"...
  • Page 602: Round

    Chapter 3 ColdFusion Functions Round Description Rounds a number to the closest integer. Category Mathematical functions Round(number) Syntax See also Ceiling, Fix, Parameters Parameter Description number Number to round Example <!--- This example shows the use of Round ---> <html> <head>...
  • Page 603: Rtrim

    Alphabetical List of ColdFusion Functions RTrim Description Returns string with trailing spaces removed. Category String functions RTrim(string) Syntax See also LTrim, Trim Parameters Parameter Description string String to right-trim Example <!--- This example shows the use of RTrim ---> <html> <head>...
  • Page 604: Second

    Chapter 3 ColdFusion Functions Second Description For a date/time value, returns the ordinal for the second, an integer 0–59. Category Date and time functions Second(date) Syntax See also DatePart, Hash, Minute Parameters Parameter Description date A date Usage When passing a date/time value as a string, enclose it in quotes. Otherwise, it is interpreted as a number representation of a date/time object.
  • Page 605: Setlocale

    Alphabetical List of ColdFusion Functions SetLocale Description Sets a locale for the current session. Category International functions SetLocale(new_locale) Syntax See also GetHttpTimeString, GetLocale Parameters Parameter Description new_locale The name of the locale to set Usage SetLocale can be used to restore a previous locale setting by referencing a variable in which the locale was stored: <cfset oldlocale = SetLocale("localename")>...
  • Page 606 Chapter 3 ColdFusion Functions <H3>SetLocale Example</H3> <P>SetLocale sets the locale to the specified new locale for the current session. <P>A locale is an encapsulation of the set of attributes that govern the display and formatting of international date, time, number, and currency values. <P>The locale for this system is <cfoutput>#GetLocale()#</cfoutput>...
  • Page 607: Setprofilestring

    Alphabetical List of ColdFusion Functions SetProfileString Description Sets the value of a profile entry in an initialization file. The function returns an empty string if the operation succeeds, or an error message if the operation fails. Category System functions SetProfileString(iniPath, section, entry, value) Syntax See also GetProfileString...
  • Page 608 Chapter 3 ColdFusion Functions <P>Setting the timeout value to <cfoutput>#MyTimeout#</cfoutput> </P> <cfset code = SetProfileString(IniPath, Section, "timeout", MyTimeout)> <P>Value returned from SetProfileString: <cfoutput>#code#</cfoutput></P> <cfelse> <hr size = "2" color = "red"> <P>Timeout value should be greater than zero in order to provide time for user response.</P>...
  • Page 609: Setvariable

    Alphabetical List of ColdFusion Functions SetVariable Description Sets the variable specified by name to value; returns the new value of the variable. Category Dynamic evaluation functions SetVariable(name, value) Syntax See also DeleteClientVariable, GetClientVariablesList Parameters Parameter Description name Variable name value String or number assigned to the variable Usage The client variable must exist before using this function.
  • Page 610 Chapter 3 ColdFusion Functions <cfoutput> <P>Your variable, #varName# <P>The value of #varName# is #varNameValue# </cfoutput> </cfif>...
  • Page 611 Alphabetical List of ColdFusion Functions Description Determines the sign of a number. Returns 1 if number is positive; 0 if number is 0; -1 if number is negative. Category Mathematical functions Sgn(number) Syntax See also Parameters Parameter Description number A number Example <!--- This example shows the use of Sgn --->...
  • Page 612 Chapter 3 ColdFusion Functions Description Returns the sine of an angle. Category Mathematical functions Sin(number) Syntax See also ASin, Atn, Cos, Pi, Parameters Parameter Description number Angle, in radians, for which you want the sine. If the angle is in degrees, multiply it by PI()/180 to convert it to radians.
  • Page 613: Spanexcluding

    Alphabetical List of ColdFusion Functions SpanExcluding Description Returns all characters from string, from the beginning to a character from the set of characters. The search is case-sensitive. Category String functions SpanExcluding(string, set) Syntax See also GetToken, SpanIncluding Parameters Parameter Description string A string String that contains one or more characters sought...
  • Page 614: Spanincluding

    Chapter 3 ColdFusion Functions SpanIncluding Description Returns all characters from string, from the beginning to a character that is not in the set of characters. The search is case-sensitive. Category String functions SpanIncluding(string, set) Syntax See also GetToken, SpanExcluding Parameters Parameter Description string...
  • Page 615 Alphabetical List of ColdFusion Functions Description Returns a positive square root. Category Mathematical functions Sqr(number) Syntax See also Parameters Parameter Description number Number whose square root to get Usage Number must be greater than or equal to 0. Example <!--- This example shows Sqr ---> <html>...
  • Page 616: Stripcr

    Chapter 3 ColdFusion Functions StripCR Description Returns string with carriage return characters removed. Category Other functions StripCR(string) Syntax See also ParagraphFormat Parameters Parameter Description string String to format Usage Useful for preformatted HTML display of data (PRE) entered into fields. textarea Example <!--- This example shows StripCR --->...
  • Page 617: Structappend

    Alphabetical List of ColdFusion Functions StructAppend Description Appends one structure to another. Always returns Yes. StructAppend(struct1, struct2, overwriteFlag) Syntax See also StructDelete StructFind, StructGet, StructInsert, StructIsEmpty, StructKeyArray, StructKeyExists, StructKeyList, StructCount, StructNew, StructUpdate, StructSort, StructFindKey, StructClear Parameters Parameter Description struct1 The structure to append. struct2 The structure containing the data appended to struct1...
  • Page 618 Chapter 3 ColdFusion Functions <!--- Display the contents of the person struct, after the Append ---> <p> The person struct <b>after</b> the Append call:<br> <cfloop collection=#personCLK# item="myItem"> <cfoutput> #myItem#<br> </cfoutput> </cfloop>...
  • Page 619: Structclear

    Alphabetical List of ColdFusion Functions StructClear Description Removes all data from the specified structure. Always returns Yes. StructClear(structure) Syntax See also StructDelete StructFind, StructInsert, StructIsEmpty, StructKeyArray, StructKeyExists, StructKeyList, StructCount, StructNew, StructUpdate, StructAppend, StructGet, StructSort, StructFindKey, StructClear Parameters Parameter Description structure Structure to clear Example <!--- This example shows how to use the StructClear function.
  • Page 620: Structcopy

    Chapter 3 ColdFusion Functions StructCopy Description Returns a new structure with the keys and values of a structure. Category Structure functions StructCopy(structure) Syntax See also Duplicate, StructClear, StructFind, StructInsert, StructIsEmpty, StructKeyArray, StructKeyExists, StructKeyList, StructCount, StructNew, StructUpdate, StructAppend, StructGet, StructSort, StructFindKey, StructClear Parameters Parameter...
  • Page 621 Alphabetical List of ColdFusion Functions Variable Type Assigned by structure.object reference structure.query reference Example <!-------------------------------------------------------------------- Theis code shows examples of assignment by-value and by-reference. ----------------------------------------------------------------------> // This script creates a structure that StructCopy copies by value. <br> <cfscript> // Create elements. s = StructNew();...
  • Page 622 Chapter 3 ColdFusion Functions s.number = #s.number#<br> s.string = #s.string#<br> // Array value <br> s.array[1][1] = #s.array[1][1]#<br> s.array[1][2] = #s.array[1][2]#<br> </cfoutput> <hr> <b>Copied structure values should be the same as the original.</b><br> <cfoutput> // Simple values <br> copied.number = #copied.number#<br> copied.string = #copied.string#<br>...
  • Page 623 Alphabetical List of ColdFusion Functions // Change the values of the original structure. s.nested.number = 100; s.nested.string = "hello tommy (modified)"; s.nested.array[1][1] = "one one (modified)"; s.nested.array[1][2] = "one two (modified)"; </cfscript> <hr> <b>Modified Original Values</b><br> <cfoutput> // Simple values <br> s.nested.number = #s.nested.number#<br>...
  • Page 624: Structcount

    Chapter 3 ColdFusion Functions StructCount Description Returns the number of keys in a structure. Category Structure functions See also StructClear, StructFind, StructInsert, StructIsEmpty, StructKeyArray, StructKeyExists, StructKeyList, StructCount, StructNew, StructUpdate, StructAppend, StructGet, StructSort, StructFindKey, StructClear StructCount(structure) Syntax Parameters Parameter Description structure Structure to access This function throws an exception if structure does not exist.
  • Page 625: Structdelete

    Alphabetical List of ColdFusion Functions StructDelete Description Removes an item from a structure. Category Structure functions StructDelete(structure, key [, indicatenotexisting ]) Syntax See also StructClear, StructFind, StructInsert, StructIsEmpty, StructKeyArray, StructKeyExists, StructKeyList, StructCount, StructNew, StructUpdate, StructAppend, StructGet, StructSort, StructFindKey, StructClear Parameters Parameter Description structure...
  • Page 626 Chapter 3 ColdFusion Functions </CFScript> <cfoutput> employee is a structure: #IsStruct(employee)# </cfoutput> <cfset rc = StructDelete(employee, "#form.field#", "True")> <cfoutput> <P>Did I delete the field "#form.field#"? The code indicates: #rc# </P> </cfoutput> </cfif> <cfif NOT IsDefined("FORM.Delete")> <form action = "structdelete.cfm" method = "post"> <P>Select the field to be deleted:&nbsp;...
  • Page 627: Structfind

    Alphabetical List of ColdFusion Functions StructFind Description Returns the value associated with a key in a structure. Category Structure functions StructFind(structure, key) Syntax See also StructClear, StructDelete, StructInsert StructIsEmpty StructKeyArray, StructKeyExists, StructKeyList, StructCount, StructNew, StructUpdate, StructAppend, StructGet, StructSort, StructFindKey, StructClear Parameters Parameter Description...
  • Page 628: Structfindkey

    Chapter 3 ColdFusion Functions StructFindKey Description Searches recursively through a sub-structure of nested arrays, structures, and other elements and returns an array containing any structures with values that match the search key specified in the value parameter. StructFindKey(top, value, scope) Syntax See also StructDelete...
  • Page 629: Structfindvalue

    Alphabetical List of ColdFusion Functions StructFindValue Description Searches recursively through a sub-structure of nested arrays, structures, and other elements and returns an array containing any structures with values that match the search key specified in the value parameter. StructFindValue( top, value [, scope]) Syntax See also StructDelete...
  • Page 630: Structget

    Chapter 3 ColdFusion Functions StructGet Description Returns an array of structures from the specified path. StructGet(pathDesired) Syntax See also StructDelete StructFind, StructAppend, StructInsert, StructIsEmpty, StructKeyArray, StructKeyExists, StructKeyList, StructCount, StructNew, StructUpdate, StructSort, StructFindKey, StructClear Parameters Parameter Description pathDesired The pathname of the variable containing the structure or array from which ColdFusion retrieves the structure.
  • Page 631: Structinsert

    Alphabetical List of ColdFusion Functions StructInsert Description Inserts a key-value pair into a structure. Returns Yes if the insert was successful and No if an error occurs. Category Structure functions StructInsert(structure, key, value [, allowoverwrite ]) Syntax See also StructClear, StructDelete, StructFind, StructIsEmpty StructKeyArray, StructKeyExists, StructKeyList, StructCount, StructNew, StructUpdate,...
  • Page 632 Chapter 3 ColdFusion Functions StructInsert(employee, "department", FORM.department); </CFScript> <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#">...
  • Page 633: Structisempty

    Alphabetical List of ColdFusion Functions StructIsEmpty Description Indicates whether a structure contains data. Returns TRUE if structure is empty. Category Structure functions StructIsEmpty(structure) Syntax See also StructClear, StructDelete, StructFind, StructInsert, StructKeyArray, StructKeyExists, StructKeyList, StructCount, StructNew, StructUpdate, StructAppend, StructGet, StructSort, StructFindKey, StructClear Parameters Parameter...
  • Page 634: Structkeyarray

    Chapter 3 ColdFusion Functions StructKeyArray Description Returns an array of the keys in a ColdFusion structure. Category Structure functions StructKeyArray(structure) Syntax See also StructClear, StructDelete, StructFind, StructInsert, StructIsEmpty, StructKeyExists, StructKeyList, StructCount, StructNew, StructUpdate, StructAppend, StructGet, StructSort, StructFindKey, StructClear Parameters Parameter Description structure Structure from which to extract a list of keys...
  • Page 635 Alphabetical List of ColdFusion Functions <cfset employee.company = FORM.company> <cfelseIf Form.Submit is "Clear"> <cfset rc = StructClear(employee)> </cfif> </cfif> <P> This example uses the StructNew function to create a structure that supplies employee information. The data structure is called "employee" and its fields are filled with the contents of the following form.
  • Page 636 Chapter 3 ColdFusion Functions <hr size = "2" color = "#0000A0"> <cfset keysToStruct = StructKeyArray(employee)> <CFLOOP index = "i" from = "1" to = "#ArrayLen(keysToStruct)#"> <P><cfoutput>Key#i# is #keysToStruct[i]#</cfoutput></P> <P><cfoutput>Value#i# is #employee[keysToStruct[i]]#</cfoutput> </P> </CFLOOP> </cfif> </body> </html>...
  • Page 637: Structkeyexists

    Alphabetical List of ColdFusion Functions StructKeyExists Description Returns TRUE if a key is in a structure and FALSE if it is not. Category Structure functions StructKeyExists(structure, key) Syntax See also StructClear, StructDelete, StructFind, StructInsert, StructIsEmpty, StructKeyArray, StructCount, StructNew, StructUpdate, StructAppend, StructGet, StructSort, StructFindKey, StructClear Parameters...
  • Page 638: Structkeylist

    Chapter 3 ColdFusion Functions StructKeyList Description Returns the list of keys in a ColdFusion structure. Category Structure functions StructKeyList(structure, [delimiter]) Syntax See also StructClear, StructDelete, StructFind, StructInsert, StructIsEmpty, StructKeyArray, StructCount, StructNew, StructUpdate, StructAppend, StructGet, StructSort, StructFindKey, StructClear Parameters Parameter Description structure Structure from which to extract a list of keys delimiter...
  • Page 639 Alphabetical List of ColdFusion Functions <basefont face = "Arial, Helvetica" size = 2> <body bgcolor = "#FFFFD5"> <H3>StructKeyList Function</H3> <H3>Listing the Keys in the Employees Structure</H3> <P> This example uses the StructNew function to create a structure that supplies employee information. The data structure is called "employee"...
  • Page 640 Chapter 3 ColdFusion Functions </tr> </table> </FORM> <cfif NOT StructISEmpty(employee)> <hr size = "2" color = "#0000A0"> <cfset keysToStruct = StructKeyList(employee,"<LI>")> <P>Here are the keys to the structure:</P> <UL> <LI> <cfoutput>#keysToStruct#</cfoutput> </UL> <P> If these fields are correct, we can process your new employee information.
  • Page 641: Structnew

    Alphabetical List of ColdFusion Functions StructNew Description Returns a new structure. Category Structure functions StructNew() Syntax See also StructClear, StructDelete, StructFind, StructInsert, StructIsEmpty, StructKeyArray, StructCount, StructUpdate, StructAppend, StructGet, StructSort, StructFindKey, StructClear Example <!---- This example shows how to use StructNew. It calls the CF_ADDEMPLOYEE custom tag, which uses the addemployee.cfm file to add the employee record to a database.
  • Page 642: Structsort

    Chapter 3 ColdFusion Functions StructSort Description Returns an array of structures containing top-level key names (strings) sorted according to the value of the specified subelement. The value of the keys may be simple values or complex elements. StructSort( base, pathToSubElement, sortOrder, sortType ) Syntax See also StructDelete...
  • Page 643 Alphabetical List of ColdFusion Functions <cfoutput> <p> list of employees based on the salary (text search): <br> 1) #ArrayToList( StructSort( salaries ) )#<br> 2) #ArrayToList( StructSort( salaries ) )#<br> 3) #ArrayToList( StructSort( salaries, "text", "ASC" ) )#<br> 4) #ArrayToList( StructSort( salaries, "textnocase", "ASC" ) )#<br> 5) #ArrayToList( StructSort( salaries, "text", "DESC"...
  • Page 644: Structupdate

    Chapter 3 ColdFusion Functions StructUpdate Description Updates a key with a value. Returns Yes if the function is successful and throws an exception if an error occurs. Category Structure functions StructUpdate(structure, key, value) Syntax See also StructClear, StructDelete, StructFind, StructInsert, StructIsEmpty, StructKeyArray, StructCount, StructNew, StructAppend, StructGet, StructSort, StructFindKey, StructClear...
  • Page 645 Alphabetical List of ColdFusion Functions Description Returns the tangent of an angle. Category Mathematical functions Tan(number) Syntax See also Atn, ASin, Cos, Parameters Parameter Description number Angle, in radians, for which you want the tangent. If the angle is in degrees, multiply it by PI()/180 to convert it to radians. Example <!--- This example shows Tan --->...
  • Page 646: Timeformat

    Chapter 3 ColdFusion Functions TimeFormat Description 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 TimeFormat(time [, mask ]) Syntax See also CreateTime, Now,...
  • Page 647 Alphabetical List of ColdFusion Functions <LI>#TimeFormat(todayDate, "hh:mm:ss")# <LI>#TimeFormat(todayDate, "hh:mm:sst")# <LI>#TimeFormat(todayDate, "hh:mm:sstt")# <LI>#TimeFormat(todayDate, "HH:mm:ss")# </UL> </cfoutput> </body> </html>...
  • Page 648: Tobase64

    Chapter 3 ColdFusion Functions ToBase64 Description Returns the Base64 representation of the string or binary object. Base64 is a format that uses printable characters, allowing binary data to be sent in forms and e-mail, and stored in a database or file. Category Conversion functions ToBase64(string or binary_object)
  • Page 649 Alphabetical List of ColdFusion Functions <!-------------------------------------------------------------------- Create a string of all ASCII characters (32-255) and concatenate them together. ----------------------------------------------------------------------> <CFLOOP index = "data" from = "32" to = "255"> <cfset ch = chr(data)> <cfset charData = charData & ch> </CFLOOP> <P>...
  • Page 650: Tobinary

    Chapter 3 ColdFusion Functions ToBinary Description Returns the binary representation of Base64 encoded data. Category Conversion functions ToBinary(string_in_Base64 or binary_value) Syntax See also See: for information about loading and reading binary data cffile for information about serializing and deserializing binary data cfwddx for checking for binary data and converting it into IsBinary...
  • Page 651 Alphabetical List of ColdFusion Functions <P> The following string is the concatenation of all characters (32 to 255) from the ASCII table.<BR> <cfoutput>#charData#</cfoutput> </P> <!-------------------------------------------------------------------- Create a Base64 representation of this string. ----------------------------------------------------------------------> <cfset data64 = toBase64(charData)> <!-------------------------------------------------------------------- Convert string to binary. ---------------------------------------------------------------------->...
  • Page 652: Tostring

    Chapter 3 ColdFusion Functions ToString Description Attempts to convert a value of any type, including a binary value, into a string. Category Conversion functions ToString(any_value) Syntax Parameters Parameter Description any_value The value to convert to a string If ToString cannot convert the value into a string, it throws an exception. Simple Usage values can be converted into a string.
  • Page 653 Alphabetical List of ColdFusion Functions <!-------------------------------------------------------------------- Create a Base64 representation of this string. ----------------------------------------------------------------------> <cfset data64 = toBase64(#charData#)> <P> The following string is the Base64 representation of the original string.<BR> <cfoutput>#data64#</cfoutput> </P> <!-------------------------------------------------------------------- Create a binary representation of Base64 data. ---------------------------------------------------------------------->...
  • Page 654: Trim

    Chapter 3 ColdFusion Functions Trim Description Returns string with leading and trailing spaces removed. Category String functions Trim(string) Syntax See also LTrim, RTrim Parameters Parameter Description string String to trim Example <!--- This example shows the use of Trim ---> <html>...
  • Page 655: Ucase

    Alphabetical List of ColdFusion Functions UCase Description Returns string converted to uppercase. Category String functions UCase(string) Syntax See also LCase Parameters Parameter Description string String to convert to uppercase Example <!--- This example shows the use of UCase ---> <html> <head>...
  • Page 656: Urldecode

    Chapter 3 ColdFusion Functions URLDecode Description Decodes a URL-encoded string. Category Other functions URLDecode(urlEncodedString) Syntax See also URLEncodedFormat Parameters Parameter Description urlEncodedString A string that has been URL-encoded. Usage URL encoding is a data format in which high ASCII and nonalphanumeric characters are encoded using a percent sign followed by the two character hexadecimal representation of the character code.
  • Page 657: Urlencodedformat

    Alphabetical List of ColdFusion Functions URLEncodedFormat Description Returns a URL-encoded string. Spaces are replaced with %20, and nonalphanumeric characters with equivalent hexadecimal escape sequences. The function lets you pass arbitrary strings within a URL, because ColdFusion automatically decodes URL parameters that are passed to the template. Category Other functions URLEncodedFormat(string)
  • Page 658 Chapter 3 ColdFusion Functions Description Returns a number that the beginning of a string can be converted to. Returns 0 if conversion is not possible. Category String functions Val(string) Syntax See also IsNumeric Parameters Parameter Description string A string Example <!--- This example shows Val --->...
  • Page 659: Valuelist

    Alphabetical List of ColdFusion Functions ValueList Description Returns a comma-separated list of the values of each record returned from a previously executed query. Category Other functions ValueList(query.column [, delimiter ]) Syntax See also QuotedValueList Parameters Parameter Description query.column Name of an executed query and column. Separate query name and column name with a period.
  • Page 660: Week

    Chapter 3 ColdFusion Functions Week Description Returns the ordinal for the week number in a year; an integer in the range 1–53. Category Date and time functions Week(date) Syntax See also DatePart Parameters Parameter Description date A date/time value or string convertible to date Usage Year values 0–29 are interpreted as 21 century dates.
  • Page 661: Writeoutput

    Alphabetical List of ColdFusion Functions WriteOutput Description Appends text to the page output stream. Although you can call this function anywhere within a page, it is most useful inside a block. cfscript This function writes to the page output stream regardless of conditions established by the tag.
  • Page 662: Xmlformat

    Chapter 3 ColdFusion Functions XMLFormat Description Returns a string that is safe to use with XML. Category Conversion functions XMLFormat(string) Syntax Parameters Parameter Description string A string. escapes special XML characters so that you can put arbitrary strings Usage XMLFormat safely into XML.
  • Page 663: Year

    Alphabetical List of ColdFusion Functions Year Description Returns the year corresponding to date. Category Date and time functions Year(date) Syntax Parameters Parameter Description date A date/time value or string convertible to date DatePart, IsLeapYear See also Usage Year values 0–29 are interpreted as 21 century dates.
  • Page 664: Yesnoformat

    Chapter 3 ColdFusion Functions YesNoFormat Description Returns Boolean data as YES or NO. Category Decision functions YesNoFormat(value) Syntax Parameters Parameter Description value A number or Boolean value IsBinary, IsNumeric See also Usage function returns non-zero values as YES and zero values as NO. YesNoFormat Example <!--- This example shows the YesNoFormat --->...
  • Page 665: Chapter 4 Coldfusion C++ Cfx Reference

    Chapter 4 ColdFusion C++ CFX Reference This chapter describes the CFXAPI classes and members. Contents C++ Class Overview....................648 CCFXException Class....................649 CCFXQuery Class ....................651 CCFXRequest Class ....................655 CCFXStringSet Class....................664...
  • Page 666: C++ Class Overview

    Chapter 4 ColdFusion C++ CFX Reference C++ Class Overview A list of CFXAPI classes and members follows. Members are described in detail in the following sections. Class Members CCFXException Class CCFXException::GetError CCFXException::GetDiagnostics CCFXQuery Class CCFXQuery::AddRow CCFXQuery::GetColumns CCFXQuery::GetData CCFXQuery::GetName CCFXQuery::GetRowCount CCFXQuery::SetData CCFXQuery::SetQueryString CCFXQuery::SetTotalTime CCFXRequest Class...
  • Page 667: Ccfxexception Class

    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 CCFXRequest Class, CCFXQuery Class, and CCFXStringSet Class. Your ColdFusion Extension code must be written to handle exceptions of this type.
  • Page 668 Chapter 4 ColdFusion C++ CFX Reference // this prevents the server from crashing in // case of an unexpected exception) catch( ... ) pRequest->ThrowException( "Error occurred in tag CFX_FOO2", "Unexpected error occurred while processing tag." ) ;...
  • Page 669: Ccfxquery Class

    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 virtual int AddRow() CCFXQuery::AddRow adds a row to a query.
  • Page 670: Ccfxquery::getcolumns

    Chapter 4 ColdFusion C++ CFX Reference // Second row iRow = pQuery->AddRow() ; pQuery->SetData( iRow, iCity, "St. Paul" ) ; pQuery->SetData( iRow, iState, "MN" ) ; pQuery->SetData( iRow, iZip, "55105" ) ; CCFXQuery::GetColumns Syntax CCFXStringSet* CCFXQuery::GetColumns(void) Description Retrieves a list of the column names contained in a query. Returns an object of CCFXStringSet Class that contains a list of the columns in the...
  • Page 671: Ccfxquery::getname

    CCFXQuery Class int iRow, iCol ; int nNumCols = pQuery->GetColumns()->GetCount() ; int nNumRows = pQuery->GetRowCount() ; for ( iRow=1; iRow<=nNumRows; iRow++ ) for ( iCol=1; iCol<=nNumCols; iCol++ ) pRequest->Write( pQuery->GetData( iRow, iCol ) ) ; pRequest->Write( " " ) ; pRequest->Write( "<BR>"...
  • Page 672: Ccfxquery::setquerystring

    Chapter 4 ColdFusion C++ CFX Reference Parameters Parameter Description iRow Row of data element to set (1-based) lColumn Column of data element to set (1-based) lpszData New value for data element Example The following example shows the addition of two rows to a three-column (’City’, ’State’, and ’Zip’) query: // First row int iRow ;...
  • Page 673: Ccfxrequest Class

    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 several interfaces that can be used by the custom extension, including functions for: Reading and writing variables Returning output...
  • Page 674: Ccfxrequest::addquery

    Chapter 4 ColdFusion C++ CFX Reference virtual void SetCustomData( LPVOID lpvData ) CCFXRequest::SetCustomData sets custom (tag specific) data to carry with a request. virtual LPVOID GetCustomData() CCFXRequest::GetCustomData gets 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.
  • Page 675: Ccfxrequest::createstringset

    CCFXRequest Class Description Checks whether the attribute was passed to the tag. Returns TRUE if the attribute is available; otherwise, returns FALSE. 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 676: Ccfxrequest::getattribute

    Chapter 4 ColdFusion C++ CFX Reference CCFXRequest::GetAttribute Syntax LPCSTR CCFXRequest::GetAttribute(LPCSTR lpszName) Description Retrieves the value of the passed attribute. Returns an empty string if the attribute does not exist. (To test whether an attribute was passed to the tag, use CCFXRequest::AttributeExists.) Returns Returns the value of the attribute passed to the tag.
  • Page 677: Ccfxrequest::getcustomdata

    CCFXRequest Class CCFXRequest::GetCustomData Syntax LPVOID CCFXRequest::GetCustomData(void) Description Gets the custom (tag specific) data for the request. This member is typically used from within subroutines of a tag implementation to extract tag data from a request. Returns Returns a pointer to the custom data, or if no custom data has been set during NULL this request using CCFXRequest::SetCustomData.
  • Page 678: Ccfxrequest::rethrowexception

    Chapter 4 ColdFusion C++ CFX Reference Returns Returns the value of the custom tag setting. If no setting of that name exists, an empty string is returned. Parameters Parameter Description lpszSettingName Name of the setting to retrieve (case insensitive) Example The following example retrieves the value of a setting named ’VerifyAddress’...
  • Page 679: Ccfxrequest::setcustomdata

    CCFXRequest Class CCFXRequest::SetCustomData Syntax void CCFXRequest::SetCustomData(LPVOID lpvData) Description Sets custom (tag specific) data to carry with the request. Use this function to store request specific data to pass to procedures within your custom tag implementation. Parameters Parameter Description lpvData Pointer to custom data The following example creates a request-specific data structure of hypothetical type Example MYTAGDATA and stores a pointer to the structure in the request for future use:...
  • Page 680: Ccfxrequest::throwexception

    Chapter 4 ColdFusion C++ CFX Reference CCFXRequest::ThrowException Syntax void CCFXRequest::ThrowException(LPCSTR lpszError, LPCSTR lpszDiagnostics) Throws an exception and ends processing of a request. Call this function when you Description encounter an error that does not allow you to continue processing the request. This function is almost always combined with the CCFXRequest::ReThrowException protect against resource leaks in extension code.
  • Page 681: Ccfxrequest::writedebug

    CCFXRequest Class CCFXRequest::WriteDebug Syntax void CCFXRequest::WriteDebug(LPCSTR lpszOutput) Description Writes text output into the debug stream. The text is only displayed to the end-user if the tag contains the attribute. (For more information, see DEBUG CCFXRequest::Debug.) Parameters Parameter Description lpszOutput Text to output The following example checks whether the DEBUG attribute is present;...
  • Page 682: Ccfxstringset Class

    Chapter 4 ColdFusion C++ CFX Reference 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 ) CCFXStringSet::AddString...
  • Page 683: Ccfxstringset::getindexforstring

    CCFXStringSet Class Example The following example demonstrates using with CCFXStringSet::GetString GetCount to iterate over a string set and write the contents of the list back to the user: int nNumItems = pStringSet->GetCount() ; for ( int i=1; i<=nNumItems; i++ ) pRequest->Write( pStringSet->GetString( i ) ) ;...
  • Page 684 Chapter 4 ColdFusion C++ CFX Reference Example The following example demonstrates with CCFXStringSet::GetCount GetString iterate over a string set and write the contents of a list back to the user: int nNumItems = pStringSet->GetCount() ; for ( int i=1; i<=nNumItems; i++ ) pRequest->Write( pStringSet->GetString( i ) ) ;...
  • Page 685: Chapter 5 Coldfusion Java Cfx Reference

    Chapter 5 ColdFusion Java CFX Reference This chapter describes the Java interfaces available for building ColdFusion custom CFXs in Java. Contents CustomTag Interface....................669 Query Interface......................670 Request Interface ....................675 Response Interface....................680 Debugging Classes Reference................. 683...
  • Page 686: Overview Class Libraries

    Chapter 5 ColdFusion Java CFX Reference 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...
  • Page 687: Customtag Interface

    CustomTag Interface CustomTag Interface public abstract interface CustomTag Interface for implementing custom tags. Classes that implement this interface can be specified in the CLASS attribute of the Java CFX tag. For example, in a class which implements this interface, MyCustomTag, the following CFML code calls the method: MyCustomTag.processRequest...
  • Page 688: Query Interface

    Chapter 5 ColdFusion Java CFX Reference Query Interface public abstract interface Query Interface to a query used or created by a CustomTag. A query contains tabular data organized by named columns and rows. Methods Returns Method Description addRow() Adds a row to the query getColumnIndex(String name) Gets the index of a column given its name...
  • Page 689: Getcolumnindex

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

    Chapter 5 ColdFusion Java CFX Reference getData Retrieves a data element from a row and column of a query. Row and column Description indexes begin with 1. You can find the number of rows in a query by calling . You can find the number of columns in a query by calling getRowCount getColumns Returns the value of the requested data element.
  • Page 691: Getrowcount

    Query Interface getRowCount Retrieves the number of rows in a query. Description Returns the number of rows contained in a query. Query Interface Category Syntax public int getRowCount() The following example retrieves the number of rows in a query and writes it back to Example the user: Query query = request.getQuery() ;...
  • Page 692 Chapter 5 ColdFusion Java CFX Reference // Second row iRow = query.addRow() ; query.setData( iRow, iCity, "St. Paul" ) ; query.setData( iRow, iState, "MN" ) ; query.setData( iRow, iZip, "55105" ) ;...
  • Page 693: Request Interface

    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 694: Debug

    Chapter 5 ColdFusion Java CFX Reference Example The following example checks whether the user passed an attribute named DESTINATION to the tag; if not, it throws an exception: if ( ! request.attributeExists("DESTINATION") ) throw new Exception( "Missing DESTINATION parameter", "You must pass a DESTINATION parameter in " "order for this tag to work correctly."...
  • Page 695: Getattributelist

    Request Interface 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 Retrieves a list of attributes passed to the tag. To retrieve the value of one attribute, Description use the member function.
  • Page 696: Getquery

    Chapter 5 ColdFusion Java CFX Reference 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") ; if ( nPort != -1 ) response.write( "The port is: "...
  • Page 697 Request Interface 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. To avoid name conflicts, preface the names of settings with the name of your CustomTag class.
  • Page 698: Response Interface

    Chapter 5 ColdFusion Java CFX Reference Response Interface public abstract interface Response Interface to response generated from a CustomTag. 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.
  • Page 699: Write

    Response Interface // Create a query which contains these columns Query query = response.addQuery( "People", columns ) ; // Add data to the query int iRow = query.addRow() ; query.setData( iRow, iFirstName, "John" ) ; query.setData( iRow, iLastName, "Smith" ) ; iRow = query.addRow() ;...
  • Page 700: Writedebug

    Chapter 5 ColdFusion Java CFX Reference public void write(String output) Syntax Parameters Parameter Description output Text to output The following example outputs the value of the DESTINATION attribute: Example response.write( "DESTINATION = " + request.getAttribute("DESTINATION") ) ; writeDebug Writes text output into the debug stream. This text is displayed to the end-user only if Description the tag contains the DEBUG attribute (check for this attribute using the member function).
  • Page 701: Debugging Classes Reference

    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 DebugQuery , and interfaces, respectively. Request Response Query DebugRequest // initialize a debug request with attributes public DebugRequest( Hashtable attributes ) ;...
  • Page 702 Chapter 5 ColdFusion Java CFX Reference...
  • Page 703: Chapter 6 Wddx Javascript Objects

    Chapter 6 WDDX JavaScript Objects This chapter provides information about JavaScript objects and functions used when implementing WDDX in a ColdFusion application. Contents WddxSerializer Object..................... 687 WddxRecordset Object.................... 691...
  • Page 704: Javascript Object Overview

    Chapter 6 WDDX JavaScript Objects JavaScript Object Overview Below is a list of JavaScript objects and functions. Functions are described in detail in the following sections. Class Members WddxSerializer Object serialize serializeVariable serializeValue write WddxRecordset Object addColumn addRows getField getRowCount setField wddxSerialize...
  • Page 705: Wddxserializer Object

    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 object. serialize (rootobj) Creates a WDDX packet for a passed WddxRecordset instance. object.
  • Page 706: Serializevariable

    Chapter 6 WDDX JavaScript Objects alert("Couldn’t serialize data"); serializeVariable Serializes a property of a structure. If an object is not a string, number, array, Description Boolean, or date, WddxSerializer treats it as a structure. object. ( name, obj ) Syntax serializeVariable Parameters Parameter...
  • Page 707: Write

    WddxSerializer Object This function serializes null values as empty strings. object. ( obj ) Syntax serializeValue 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. This is an internal function;...
  • Page 708 Chapter 6 WDDX JavaScript Objects // Number value this.write("<number>" + obj + "</number>"); else if (typeof(obj) == "boolean") // Boolean value this.write("<boolean value=’" + obj + "’/>");...
  • Page 709: Wddxrecordset Object

    WddxRecordset Object WddxRecordset Object Includes functions that you call as needed when constructing a WDDX recordset. Functions Function Syntax Description object. addColumn (name) Adds a column to all rows in a WddxRecordset instance object. addRows (n) Adds rows to all columns in a WddxRecordset instance object.
  • Page 710: Addrows

    Chapter 6 WDDX JavaScript Objects addRows Adds rows to all columns in a WddxRecordset instance. Description object. ( n ) Syntax addRows Parameters Parameter Description object Instance name of the WddxRecordset object Integer; number of rows to add None. Return value This function adds the specified number of rows to every column of a WDDX record Usage set.
  • Page 711: Setfield

    WddxRecordset Object Example This example calls the getField function (the variable r is a reference to a WddxRecordset instance): for (row = 0; row < nRows; ++row) o += "<tr>"; for (i = 0; i < colNames.length; ++i) o += "<td>" + r.getField(row, colNames[i]) + "</td>"; o += "</tr>";...
  • Page 712: Wddxserialize

    Chapter 6 WDDX JavaScript Objects Parameter Description Integer or string; the column containing the element to set value Value to set None. Return value Usage Call this function to set a value in a WddxRecordset instance. This example calls the setField function: Example // create a new recordset rs = new WddxRecordset();...
  • Page 713 WddxRecordset Object // Object knows how to serialize itself bSuccess = obj.wddxSerialize(this);...
  • Page 714 Chapter 6 WDDX JavaScript Objects...

This manual is also suitable for:

Coldfusion 5

Table of Contents