MACROMEDIA COLDFUSION 4.5-CFML LANGUAGE Reference

Cfml language reference
Table of Contents

Advertisement

Quick Links

CFML Language
Reference
ColdFusion 4.5
Allaire Corporation

Advertisement

Table of Contents
loading

Summary of Contents for MACROMEDIA COLDFUSION 4.5-CFML LANGUAGE

  • Page 1 CFML Language Reference ColdFusion 4.5 Allaire Corporation...
  • Page 2 Copyright Notice © 1999 Allaire Corporation. All rights reserved. This manual, as well as the software described in it, is furnished under license and may be used or copied only in accordance with the terms of such license. 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 Allaire Corporation.
  • Page 3: Table Of Contents

    Contents Preface: Welcome To ColdFusion ..............xiii Intended Audience.........................xiv Welcome to the ColdFusion 4.5 Web Application Server ............xiv Products and System Requirements ....................xiv New features in ColdFusion 4.5 .....................xv New visual tools ........................xvi Enhancements to CFML ......................xvi Better reliability ........................xvi Improved performance......................xvii Enterprise connectivity features ..................xvii Security enhancements.......................
  • Page 4 CFML Language Reference Flow-Control Tags ..........................7 Internet Protocol Tags ........................7 Java Servlet and Java Object Tags ....................8 Variable Manipulation Tags......................8 Web Application Framework Tags ....................8 Other Tags ............................8 CFABORT............................9 CFAPPLET............................11 CFAPPLICATION ..........................13 CFASSOCIATE ..........................16 CFAUTHENTICATE ........................17 CFBREAK ............................19 CFCACHE ............................20 CFCOL..............................23 CFCOLLECTION ..........................25 CFCONTENT ...........................28...
  • Page 5 Contents CFHEADER ............................90 CFHTMLHEAD..........................91 CFHTTP ............................92 CFHTTPPARAM ..........................98 CFIF/CFELSEIF/CFELSE......................100 CFIMPERSONATE.........................102 CFINCLUDE ..........................104 CFINDEX ............................105 CFINPUT ............................109 CFINSERT ............................112 CFLDAP............................115 CFLOCATION..........................121 CFLOCK ............................122 CFLOOP ............................129 Index Loops..........................129 Conditional Loops.........................130 Looping over a Query......................131 Looping over a List ........................132 Looping over a COM Collection or Structure..............133 CFMAIL............................135 CFMAILPARAM..........................138 CFMODULE ..........................140...
  • Page 6 CFML Language Reference Arrays............................197 Dynamic variable names ......................197 COM objects ..........................197 CFSETTING ...........................199 CFSILENT ............................201 CFSLIDER ............................202 CFSTOREDPROC ..........................207 CFSWITCH/CFCASE/CFDEFAULTCASE..................210 CFTABLE............................212 CFTEXTINPUT ..........................214 CFTHROW .............................218 CFTRANSACTION.........................220 CFTREE ............................223 CFTREEITEM ..........................228 CFTRY/CFCATCH.........................232 CFUPDATE ............................236 CFWDDX ............................239 Chapter 2: ColdFusion Functions..............241 Alphabetical List of ColdFusion Functions.................242 New Functions in ColdFusion 4.5 ....................245 Array Functions..........................245 Authentication Functions ......................245...
  • Page 7 Contents ArrayResize ............................268 ArraySet............................269 ArraySort............................270 ArraySum ............................271 ArraySwap............................273 ArrayToList ............................274 Asc ..............................275 ASin ..............................276 Atn ..............................278 AuthenticatedContext ........................279 AuthenticatedUser........................280 BitAnd ............................281 BitMaskClear ..........................282 BitMaskRead ..........................283 BitMaskSet.............................284 BitNot.............................285 BitOr...............................286 BitSHLN ............................287 BitSHRN............................288 BitXor .............................289 Ceiling ............................290 Chr..............................291 CJustify............................292 Compare ............................293 CompareNoCase...........................295 Cos..............................296 CreateDate.............................297 CreateDateTime..........................299...
  • Page 8 viii CFML Language Reference DaysInMonth ..........................333 DaysInYear ............................334 DE..............................335 DecimalFormat ..........................336 DecrementValue ...........................337 Decrypt ............................338 DeleteClientVariable ........................339 DirectoryExists ..........................340 DollarFormat..........................341 Encrypt............................342 Evaluate ............................343 Exp..............................344 ExpandPath ...........................345 FileExists ............................346 Find ..............................347 FindNoCase ...........................348 FindOneOf .............................349 FirstDayOfMonth..........................350 Fix ..............................351 FormatBaseN..........................352 GetBaseTagData..........................353 GetBaseTagList..........................354 GetBaseTemplatePath........................355 GetClientVariablesList........................356 GetCurrentTemplatePath......................357...
  • Page 9 Contents IsBoolean ............................391 IsDate .............................392 IsDebugMode..........................393 IsDefined ............................394 IsLeapYear .............................395 IsNumeric ............................396 IsNumericDate..........................397 IsProtected.............................398 IsQuery............................401 IsSimpleValue..........................402 IsStruct............................403 JSStringFormat ..........................404 LCase..............................405 Left ..............................406 Len..............................407 ListAppend ............................408 ListChangeDelims.........................409 ListContains ..........................410 ListContainsNoCase ........................412 ListDeleteAt ...........................413 ListFind ............................414 ListFindNoCase..........................416 ListFirst ............................417 ListGetAt ............................418 ListInsertAt ............................419 ListLast............................420 ListLen ............................421 ListPrepend ...........................422...
  • Page 10 CFML Language Reference LSParseNumber ..........................460 LSTimeFormat ..........................461 LTrim..............................463 Max..............................464 Mid ..............................465 Min ..............................466 Minute............................467 Month ............................468 MonthAsString ..........................469 Now ..............................470 NumberFormat ..........................471 ParagraphFormat..........................474 ParameterExists ..........................475 ParseDateTime..........................476 Pi..............................478 PreserveSingleQuotes........................479 Quarter............................480 QueryAddColumn.........................481 QueryAddRow ..........................483 QueryNew............................484 QuerySetCell..........................485 QuotedValueList ...........................487 Rand ...............................488 Randomize.............................489 RandRange ............................490 REFind ............................491 REFindNoCase ..........................494 RemoveChars ..........................497...
  • Page 11 Contents StripCR............................521 StructClear.............................522 StructCopy.............................523 StructCount ...........................524 StructDelete...........................525 StructFind ............................527 StructInsert............................528 StructIsEmpty..........................530 StructKeyArray ..........................531 StructKeyExists..........................534 StructKeyList ..........................535 StructNew ............................538 StructUpdate ..........................539 Tan ..............................540 TimeFormat...........................541 ToBase64............................543 ToBinary ............................545 ToString ............................547 Trim..............................549 UCase .............................550 URLDecode ...........................551 URLEncodedFormat........................552 Val..............................553 ValueList ............................554 Week...............................555 WriteOutput ..........................556 XMLFormat ...........................557 Year ..............................558 YesNoFormat..........................559...
  • Page 12 CFML Language Reference Notes on using variables.......................575 Operators ............................576 Arithmetic operators ......................576 String operators ........................577 Decision, or comparison, operators ..................577 Boolean operators .........................579 Operator Precedence........................579 Function Syntax ..........................580 Optional arguments in functions..................580 Pound Signs...........................581 Pound signs inside CFOUTPUT tags ...................581 Pound signs inside strings ....................582 Pound signs inside tag attribute values ................583 Nested pound signs.......................583...
  • Page 13 Welcome To ColdFusion Preface ColdFusion is a rapid application development system for professional developers who want to create dynamic Web applications and interactive Web sites. It provides the fastest way to integrate browser, server, and database technologies into powerful Web applications. With ColdFusion, you can build everything from online stores to sophisticated business systems.
  • Page 14: Intended Audience

    CFML Language Reference Intended Audience This reference is intended for web developers who have a working knowledge of ColdFusion; that is, you know how to use tags and functions, but you need a comprehensive reference that provides an in-depth description of each tag and function, and examples of how tags and functions are used in the context of an HTML/ CFML page.
  • Page 15: New Features In Coldfusion 4.5

    Preface 128 MB RAM (256 MB recommended for clustering) ColdFusion Server 4.5 Enterprise Edition for Solaris SPARC Solaris 2.5.1, 2.6, or 7 (patch 103582-1B or higher) 128 MB RAM (256 MB recommended for clustering) 200 MB hard disk space ColdFusion Server 4.5 Enterprise Edition for Linux Red Hat Linux 6.0 or 6.1 Intel Pentium or above 128 MB RAM (256 MB recommended for clustering)
  • Page 16: New Visual Tools

    CFML Language Reference New visual tools Universal File Browser — Access all your files from a single explorer that integrates access to the Windows file system, ColdFusion RDS servers, and FTP servers. Drag- and-drop between any of these services all in an integrated file browser. Advanced Project Management —...
  • Page 17: Improved Performance

    Preface xvii Improved Automatic Server Recovery — Monitor and automatically restart server process in case of failures or critical errors on individual servers not deployed in a cluster. Clustering Support for Apache — Setup ColdFusion clusters on Linux and Solaris using the Apache Web Server.
  • Page 18: Security Enhancements

    xviii CFML Language Reference Java-based ColdFusion Extensions (CFX) — Extend ColdFusion with new functionality through CFXs created with Java. Binary Object Support — Use Character Large Binary Object (CLOB) support to encoded binary objects, transmit them via XML, and store them in databases or files. SQL Bind Parameters —...
  • Page 19: Language Reference Features

    Preface Language Reference Features The CFML Language Reference provides descriptions, syntax, usage, and code examples for: CFML Tags CFML Functions JavaScript objects used when implementing web distributed data exchange (WDDX) The CFML Language Reference also provides a chapter on expressions, operators, and other CFML constructs.
  • Page 20: Using End Tags

    CFML Language Reference Using End Tags Except where noted in the syntax, CFML tags do not require an end tag. However, all CFML tags (except CFELSE and CFELSEIF) can accept an optional end tag, as follows: Shorthand — You can use shorthand notation to include the end tag with the base tag.
  • Page 21: About Coldfusion Documentation

    Preface About ColdFusion Documentation ColdFusion documentation is designed to provide support for all components of the ColdFusion development system. Both the print and online versions are organized to allow you to quickly locate the information you need. In addition to the book set, the documentation is provided in two other formats: HTML —...
  • Page 22: Coldfusion Server Online Documentation

    xxii CFML Language Reference Using ColdFusion Studio Documents everything you need to know about using ColdFusion Studio, including features like projects, source control integration, as well as the Studio workspace and interface. ColdFusion Quick Reference Guide A valuable quick reference to CFML tags, functions, and variables. ColdFusion Server online documentation To view the HTML documentation, open the following URL: http://127.0.0.1/...
  • Page 23: Documentation Conventions

    Preface xxiii Documentation conventions When reading, please be aware of these formatting cues: Code samples, filenames, and URLs are set in a font monospaced Notes and tips are identified by bold type Bulleted lists present options and features Numbered steps indicate procedures Tool button icons are generally shown with procedure steps Menu levels are separated by the greater than (>) sign Text for you to type in is set in italics...
  • Page 24 xxiv CFML Language Reference Technical support Telephone support is available Monday through Friday 8 A.M. to 8 P.M. Eastern time (except holidays) Toll Free: 888.939.2545 (U.S. and Canada) Tel: 617.761.2100 (outside U.S. and Canada) For complete details about Allaire Product Support options, please refer to the Allaire Support pages on the Allaire web site: http://www.allaire.com/support Postings to the ColdFusion Support Forum (...
  • Page 25: Chapter 1: Coldfusion Tags

    H A P T E R ColdFusion Tags Chapter 1 This chapter describes each of the tags in the ColdFusion Markup Language (CFML). The introduction contains an alphabetical summary of ColdFusion tags, a list of new tags in ColdFusion 4.5, and a list of tags by category. The remainder of this chapter provides complete descriptions of each tag, listed alphabetically.
  • Page 26: Alphabetical List Of Coldfusion Tags

    CFML Language Reference Alphabetical List of ColdFusion Tags The ColdFusion Markup Language (CFML) consists of a set of tags you use in your 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 each CFML tag.
  • Page 27 Chapter 1: ColdFusion Tags CFML Tag Summary (Continued) CFML Tag Description CFFORM Builds an input form and performs client-side input validation. CFFTP Permits FTP file operations. CFGRID Used in CFFORM to create a grid control for tabular data. CFGRIDCOLUMN Used in CFFORM to define the columns used in a CFGRID. CFGRIDROW Used with CFGRID to define a grid row.
  • Page 28 CFML Language Reference CFML Tag Summary (Continued) CFML Tag Description CFMAILPARAM Attaches a file or adds a header to an email message. CFMODULE Invokes a custom tag for use in your ColdFusion application pages. CFOBJECT Creates and uses COM, CORBA, or JAVA objects. CFOUTPUT Displays output of database query or other operation.
  • Page 29: New Tags In Coldfusion 4.5

    Chapter 1: ColdFusion Tags CFML Tag Summary (Continued) CFML Tag Description CFSILENT Suppresses all output that is produced by the CFML within the tag’s scope. CFSLIDER Used in CFFORM to create a slider control element. CFSTOREDPROC Specifies database connection information and identifies the stored procedure to be executed.
  • Page 30: Coldfusion Forms Tags

    CFML Language Reference ColdFusion Forms Tags CFAPPLET CFINPUT CFFORM CFSELECT CFGRID CFSLIDER CFGRIDCOLUMN CFTEXTINPUT CFGRIDROW CFTREE CFGRIDUPDATE CFTREEITEM Database Manipulation Tags CFINSERT CFQUERYPARAM CFPROCPARAM CFSTOREDPROC CFPROCRESULT CFTRANSACTION CFQUERY CFUPDATE Data Output Tags CFCOL CFOUTPUT CFCONTENT CFTABLE CFHEADER Exception Handling Tags CFERROR CFRETHROW CFTHROW...
  • Page 31: Extensibility Tags

    Chapter 1: ColdFusion Tags Extensibility Tags CFCOLLECTION CFSEARCH CFEXECUTE CFSERVLET CFINDEX CFSERVLETPARAM CFOBJECT CFWDDX CFREPORT File Management Tags CFDIRECTORY CFFILE Flow-Control Tags CFABORT CFLOOP CFBREAK CFSWITCH/CFCASE/CFDEFAULTCASE CFEXECUTE CFTHROW CFIF/CFELSEIF/CFELSE CFTRY/CFCATCH CFLOCATION Internet Protocol Tags CFFTP CFMAIL CFHTTP CFMAILPARAM CFHTTPPARAM CFPOP CFLDAP...
  • Page 32: Java Servlet And Java Object Tags

    CFML Language Reference Java Servlet and Java Object Tags CFOBJECT CFSERVLETPARAM CFSERVLET Variable Manipulation Tags CFCOOKIE CFSCRIPT CFPARAM CFSET Web Application Framework Tags CFAPPLICATION CFERROR CFASSOCIATE CFLOCK CFAUTHENTICATE Other Tags CFASSOCIATE CFREPORT CFCACHE CFSETTING CFHTMLHEAD CFSILENT CFINCLUDE CFWDDX CFLOCK...
  • Page 33: Cfabort

    Chapter 1: ColdFusion Tags CFABORT The CFABORT tag stops processing of a page at the tag location. ColdFusion simply returns everything that was processed before the CFABORT tag. CFABORT is often used with conditional logic to stop processing a page because of a particular condition.
  • Page 34 CFML Language Reference <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 35: Cfapplet

    Chapter 1: ColdFusion Tags CFAPPLET Used in a CFFORM, CFAPPLET allows you to reference custom Java applets that have been previously registered using the ColdFusion Administrator. To register a Java applet, open the ColdFusion Administrator and click the Applets button. Syntax <CFAPPLET APPLETSOURCE="applet_name"...
  • Page 36 CFML Language Reference AbsMiddle Baseline AbsBottom NOTSUPPORTED Optional. The text you want to display if the page containing a Java applet-based CFFORM control is opened by a browser that does not support Java or has Java support disabled. For example: NOTSUPPORTED="<B>Browser must support Java to view ColdFusion Java Applets</B>"...
  • Page 37: Cfapplication

    Chapter 1: ColdFusion Tags CFAPPLICATION 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, used to enable session variables and to set timeouts for both session and application variables.
  • Page 38 CFML Language Reference SESSIONMANAGEMENT Optional. Yes or No. Yes enables session variables. Default is No. SESSIONTIMEOUT Optional. Enter the CreateTimeSpan function and the values you want in days, hours, minutes, and seconds, separated by commas to specify the lifespan of any session variables that are set.
  • Page 39 Chapter 1: ColdFusion Tags <BODY bgcolor="#FFFFD5"> <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 40: Cfassociate

    CFML Language Reference CFASSOCIATE The CFASSOCIATE tag allows sub-tag data to be saved with the base tag. This applies to custom tags only. Syntax <CFASSOCIATE BASETAG="tagname" DATACOLLECTION="collectionname"> BASETAG Specifies the name of the base tag. DATACOLLECTION Optional. Specifies the name of the structure in which the base tag stores sub-tag data.
  • Page 41: Cfauthenticate

    Chapter 1: ColdFusion Tags CFAUTHENTICATE The CFAUTHENTICATE tag authenticates a user, setting a security context for the application. See the descriptions of the functions IsAuthenticated AuthenticatedContext. Syntax <CFAUTHENTICATE SECURITYCONTEXT="context" USERNAME="user ID" PASSWORD="password" SETCOOKIE="yes/no" THROWONFAILURE="yes/no"> SECURITYCONTEXT Required. Security context with which the specified user is authenticated. This context must have been previously defined in the security system.
  • Page 42 CFML Language Reference <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> <CFAPPLICATION NAME="Personnel">...
  • Page 43: Cfbreak

    Chapter 1: ColdFusion Tags CFBREAK Used to break out of a CFLOOP . See Breaking out of a loop, later in this chapter, for more information. Syntax <CFBREAK> Example <!--- This example shows the use of CFBREAK to exit a loop when a condition is met ---> <!--- select a list of courses and use CFLOOP to find a condition and then break the loop --->...
  • Page 44: Cfcache

    CFML Language Reference CFCACHE CFCACHE allows you to speed up pages considerably in cases where the dynamic content doesn’t need to be retrieved each time a user accesses the page. To accomplish this, it creates temporary files that contain the static HTML returned from a particular run of the ColdFusion page.
  • Page 45 Chapter 1: ColdFusion Tags CACHEDIRECTORY Optional. Specifies the fully qualified path of the directory where the pages are to be cached. The default is the directory of the current page. EXPIREURL Optional. Used with ACTION=FLUSH. EXPIREURL takes a wildcarded URL reference that ColdFusion matches against all mappings in the cfcache.map file.
  • Page 46 CFML Language Reference You can refresh the cache in the following ways: TIMEOUT attribute — ColdFusion tests the timestamp of the cached file against the TIMEOUT attribute. If the cached file’s timestamp is older than TIMEOUT, the old file is deleted and a new one created. You can use fixed dates if necessary, but it's preferable to use relative dates.
  • Page 47: Cfcol

    Chapter 1: ColdFusion Tags CFCOL Defines table column header, width, alignment, and text. Only used inside a CFTABLE. Syntax <CFCOL HEADER="text" WIDTH="number" ALIGN="position" TEXT="text"> HEADER The text to use for the column’s header. WIDTH The width of the column in characters (the default is 20). If the length of the data displayed exceeds the width value, the data is truncated to fit.
  • Page 48 CFML Language Reference as well as specifying the header information and the text/CFML with which to fill the cell ---> <CFCOL HEADER = "<B>ID</B>" ALIGN = "Left" WIDTH = 2 TEXT = "#Emp_ID#"> <CFCOL HEADER = "<B>Name/Email</B>" ALIGN = "Left" WIDTH = 15 TEXT = "<a href=’mailto:#Email#’>#FirstName# #LastName#</A>">...
  • Page 49: Cfcollection

    Chapter 1: ColdFusion Tags CFCOLLECTION The CFCOLLECTION tag allows you to create and administer Verity collections. Syntax <CFCOLLECTION ACTION="action" COLLECTION="collection" PATH="implementation directory" LANGUAGE="language"> ACTION Required. Specifies the action to perform: CREATE — Creates a new collection using the specified path and optionally specified language.
  • Page 50 CFML Language Reference LANGUAGE Optional for CREATE. To use the LANGUAGE attribute you must have the ColdFusion International Search Pack installed. Valid entries are: English (default) German Finnish French Danish Dutch Italian Norwegian Portuguese Spanish Swedish Usage CFCOLLECTION works at the collection level only. To add content to a collection, use CFINDEX.
  • Page 51 Chapter 1: ColdFusion Tags COLLECTION="#FORM.CollectionName#" PATH="C:\CFUSION\Verity\Collections\"> <H3>Collection created.</H3> </CFCASE> <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#"> <H3>Collection deleted.</H3> </CFCASE> </CFSWITCH>...
  • Page 52: Cfcontent

    CFML Language Reference CFCONTENT Defines the MIME type returned by the current page. Optionally, allows you to specify the name of a file to be returned with the page. Note The ColdFusion Server Basic security settings may prevent CFCONTENT from executing. These settings are managed using the ColdFusion Administrator Basic Security page.
  • Page 53 Chapter 1: ColdFusion Tags <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 54: Cfcookie

    CFML Language Reference CFCOOKIE Defines cookie variables, including expiration and security options. Syntax <CFCOOKIE NAME="cookie_name" VALUE="text" EXPIRES="period" SECURE="Yes/No" PATH="urls" DOMAIN=".domain"> NAME Required. The name of the cookie variable. VALUE Optional. The value assigned to the cookie variable. EXPIRES Optional. Schedules the expiration of a cookie variable. Can be specified as a date (as in, 10/09/97), number of days (as in, 10, 100), NOW, or NEVER.
  • Page 55 Chapter 1: ColdFusion Tags do not have an EXPIRES attribute in a CFCOOKIE, the cookie set exists only as long as the client browser is open. When the browser is closed, the cookie expires. It is never written to the file.
  • Page 56 CFML Language Reference <!--- 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 57: Cfdirectory

    Chapter 1: ColdFusion Tags CFDIRECTORY Use the CFDIRECTORY tag to handle all interactions with directories. Note The ColdFusion Server Basic security settings may prevent CFDIRECTORY from executing. These settings are managed using the ColdFusion Administrator Basic Security page. In order for CFDIRECTORY to execute, it needs to be enabled on the Basic Security page.
  • Page 58 CFML Language Reference Optional. Used with ACTION="Create" to define the permissions for a directory on Solaris or HP-UX. Ignored in Windows. Valid entries correspond to the octal values (not symbolic) of the UNIX command. Permissions are assigned for chmod owner, group, and other, respectively. For example: MODE=644 Assigns all, owner read/write permission, group and other read/write permissions.
  • Page 59 Chapter 1: ColdFusion Tags Example <!---------------------------------------------------------------------- This example shows the use of CFDIRECTORY to display the contents of the snippets directory in CFDOCS. -----------------------------------------------------------------------> <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) --->...
  • Page 60: Cferror

    CFML Language Reference CFERROR Provides the ability to display customized HTML pages when errors occur. This allows you to maintain a consistent look and feel within your application even when errors occur. Syntax <CFERROR TYPE="Request" or "Validation" or "Monitor" or "Exception" TEMPLATE="template_path"...
  • Page 61: Cferror Error Variables

    Chapter 1: ColdFusion Tags Types and Their Corresponding Custom Error Pages (Continued) Type Custom Error Page Request This template can include only the error variables described in the table under CFERROR Error Variables and cannot include CFML tags. It Validation A validation error handler.
  • Page 62 CFML Language Reference Error Variables for Request, Exception, and Monitor Types The following error variables are available when CFERROR specifies TYPE="Request", TYPE="Exception" or TYPE="Monitor": Variables for Request, Exception, and Monitor Types Error Variable Description Error.Diagnostics Detailed error diagnostics from ColdFusion Server. Error.MailTo Email address of administrator who should be notified (corresponds to the value set in the MAILTO...
  • Page 63 Chapter 1: ColdFusion Tags Example <!--- This example shows the use of CFERROR. ---> <HTML> <HEAD> <TITLE>CFERROR Example</TITLE> </HEAD> <BODY> <H3>CFERROR Example</H3> <P>CFERROR provides the ability to display customized HTML pages when errors occur. This allows you to maintain a consistent look and feel within your application even when errors occur.
  • Page 64: Cfexecute

    CFML Language Reference CFEXECUTE Enables ColdFusion developers to execute any process on the server machine. Syntax <CFEXECUTE NAME=" ApplicationName " ARGUMENTS="CommandLine Arguments" OUTPUTFILE="Output file name” TIMEOUT=”Timeout interval in seconds”> NAME Required. The full path name of the application that is to be executed. Note: On Windows systems, you must specify the extension, for example, .exe, as part of the application’s name.
  • Page 65 Chapter 1: ColdFusion Tags Usage CFEXECUTE is available on Windows NT 4.0 and UNIX platforms. Do not put any other ColdFusion tags or functions between the start and the end tags of CFEXECUTE. Also, CFEXECUTE tags cannot be nested. Exception CFEXECUTE throws the following exceptions: If the application name is not found, an Application File Not Found exception will be thrown.
  • Page 66: Cfexit

    CFML Language Reference CFEXIT CFEXIT can be 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. Syntax <CFEXIT METHOD="method">...
  • Page 67 Chapter 1: ColdFusion Tags Example <!--- This example shows the use of CFEXIT, and is a read-only example ---> <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 will resume immediately following the invocation of the custom tag in the page that called the tag.
  • Page 68 CFML Language Reference <P>If CFEXIT is used outside of a custom tag, it functions like a CFABORT. For example, the text after this message will not be processed: <CFEXIT> <P>This text will not be executed due to the existence of the CFEXIT tag above it.
  • Page 69: Cffile

    Chapter 1: ColdFusion Tags CFFILE Use the CFFILE tag to handle all interactions with files. The attributes you use with CFFILE depend on the value of the ACTION attribute. For example, if the ACTION is "Write, " ColdFusion expects the attributes associated with writing a text file. See the individual CFFILE topics below for details about which attributes apply to which ACTIONs.
  • Page 70: Cffile Action Attributes

    CFML Language Reference CFFILE ACTION attributes Depending on the value you assign to the ACTION attribute of CFFILE, there are several additional attributes you can set. This table shows which attributes you can use with each CFFILE ACTION. Attributes Used with CFFILE ACTIONs ACTION Attributes Upload...
  • Page 71: Cffile Action="Upload

    Chapter 1: ColdFusion Tags CFFILE ACTION="Upload" Use CFFILE with the Upload action to upload a file specified in a form field to a directory on the Web server. Note The MODE attribute applies to ColdFusion on Solaris and HP-UX, only. Syntax <CFFILE ACTION="Upload"...
  • Page 72 CFML Language Reference Note that the browser uses the file extension to determine file type. MODE Optional. Defines permissions for an uploaded file on Solaris or HP-UX. Ignored in Windows. Valid entries correspond to the octal values (not symbolic) of the UNIX chmod command.
  • Page 73: Evaluating The Results Of A File Upload

    Chapter 1: ColdFusion Tags Evaluating the results of a file upload After a file upload is completed, you can retrieve status information using file upload parameters. This status information includes a wide range of data about the file, such as the file’s name and the directory where it was saved. File upload status parameters .
  • Page 74 CFML Language Reference File Upload Parameters (Continued) Parameter Description FileWasRenamed Indicates (Yes or No) whether or not the uploaded file was renamed to avoid a name conflict. FileWasSaved Indicates (Yes or No) whether or not Cold Fusion saved a file. OldFileSize Size of a file that was overwritten in the file upload operation.
  • Page 75: Cffile Action="Move

    Chapter 1: ColdFusion Tags <CFFILE ACTION="Append" DESTINATION="/home/tomj/testing.txt" MODE=666 OUTPUT="Is this a test?"> The next example uploads a file and gives it permissions (owner/group/ rwx-rw-rw other=read/write). CFFILE ACTION="Upload" FILEFIELD="fieldname" DESTINATION="/tmp/program.exe" MODE=755> CFFILE ACTION="Move" The CFFILE MOVE action can be used to move a file from one location on the server to another.
  • Page 76: Cffile Action="Rename

    CFML Language Reference Example The following example moves the file from the keymemo.doc c:\files\upload\ directory to the directory on Windows: c:\files\memo\ <CFFILE ACTION="Move" SOURCE="c:\files\upload\keymemo.doc" DESTINATION="c:\files\memo\"> Note On Windows, you must include the backward slash (\) after the destination directory name if you do not specify a file name. In this example, the specified destination directory is "memo.
  • Page 77: Cffile Action="Copy

    Chapter 1: ColdFusion Tags Example The following example renames the file keymemo.doc oldmemo.doc <CFFILE ACTION="Rename" SOURCE="c:\files\memo\keymemo.doc" DESTINATION="c:\files\memo\oldmemo.doc"> CFFILE ACTION="Copy" The CFFILE tag can be used to copy a file from one directory to another on the server. Syntax <CFFILE ACTION="Copy" SOURCE="full_path_name"...
  • Page 78: Cffile Action="Delete

    CFML Language Reference Note On Windows, you must include the backward slash (\) after the destination directory name if you do not specify a file name. In this example, the specified destination directory is "backup. " CFFILE ACTION="Delete" The CFFILE tag can be used to delete a file on the server. Syntax <CFFILE ACTION="Delete"...
  • Page 79: Cffile Action="Readbinary

    Chapter 1: ColdFusion Tags <CFOUTPUT>#Message#</CFOUTPUT> ColdFusion supports a number of powerful functions for manipulating the contents of text files. You can also use variable created by a CFFILE Read operation in ArrayToList and ListToArray functions. String Functions Array Functions for more information about working with strings and arrays.
  • Page 80 CFML Language Reference FILE Required. The full path name of the file to be created. OUTPUT Required. The content of the file to be created. MODE Optional. Defines permissions for a file on Solaris or HP-UX. Ignored in Windows. Valid entries correspond to the octal values (not symbolic) of the Unix chmod command.
  • Page 81 Chapter 1: ColdFusion Tags Example The following example creates a file with the information a user entered into an HTML insert form: <CFFILE ACTION="Write" FILE="c:\files\updates\#Form.UpdateTitle#.txt" OUTPUT="Created By: #Form.FullName# Date: #Form.Date# #Form.Content#"> If the user submitted a form where: UpdateTitle="FieldWork" FullName="World B. Frueh" Date="10/30/98"...
  • Page 82: Cffile Action="Append

    CFML Language Reference CFFILE ACTION="Append" Use CFFILE with the Append action to append additional text to the end of an existing text file, for example, when creating log files. Syntax <CFFILE ACTION="Append" FILE="full_path_name" OUTPUT="string" ATTRIBUTES="file_attributes"> FILE Required. The full path name of the file to which the content of the OUTPUT attribute is appended.
  • Page 83: Cfform

    Chapter 1: ColdFusion Tags CFFORM CFFORM allows you to build a form with CFML custom control tags that provide much greater functionality than standard HTML form input elements. Syntax <CFFORM NAME="name" ACTION="form_action" ENABLECAB="Yes/No" ONSUBMIT="javascript" TARGET="window_name" ENCTYPE="type" PASSTHROUGH="HTML_attributes"> </CFFORM> NAME Optional. A name for the form you are creating. ACTION Required.
  • Page 84: Incorporating Html Form Tags

    CFML Language Reference code that is generated for the CFINPUT tag. See the Usage section for more information about specifying values. Usage The following custom control tags are available: CFINPUT — Creates a form input element (radio button, text box, or checkbox) and can validate form input.
  • Page 85 Chapter 1: ColdFusion Tags Example <!--- This example shows the use of CFINPUT controls in a CFFORM ---> <HTML> <HEAD> <TITLE> CFFORM Example </TITLE> </HEAD> <BODY> <H3>CFFORM Example</H3> <CFIF IsDefined("form.oncethrough") is "Yes"> <CFIF IsDefined("form.testVal1") is True> <H3>Results of Radio Button Test</H3> <CFIF form.testVal1 is "Yes">Your radio button answer was yes</CFIF>...
  • Page 86 CFML Language Reference <CFINPUT TYPE="Checkbox" NAME="ChkTest2" VALUE="Yes"> </TD> </TR> <TR> <TD> <H4>This example shows a client-side validation for CFINPUT text boxes.</H4> <BR>(<I>This item is optional</I>)<BR> Please enter a credit card number: <CFINPUT TYPE="Text" NAME="TextSample" MESSAGE="Please enter a Credit Card Number" VALIDATE="creditcard" REQUIRED="No"> </TD>...
  • Page 87: Cfftp

    Chapter 1: ColdFusion Tags CFFTP CFFTP allows users to implement File Transfer Protocol operations. By default, CFFTP caches an open connection to an FTP server. Note The CFFTP tag is for moving files between a ColdFusion server and an FTP server. CFFTP cannot move files between a ColdFusion server and a browser (client).
  • Page 88 CFML Language Reference PORT="port" CONNECTION="name" PROXYSERVER="proxyserver" PROXYBYPASS="proxybypass" RETRYCOUNT="number" STOPONERROR="Yes/No" PASSIVE="Yes/No"> ACTION Required. Determines the FTP operation to perform. To create an FTP connection, use Open. To terminate an FTP connection, use Close. See Connection Caching for more information. USERNAME Required for Open. User name to pass in the FTP operation. PASSWORD Required for Open.
  • Page 89 Chapter 1: ColdFusion Tags RETRYCOUNT Optional. Number of retries until failure is reported. Default is one (1). STOPONERROR Optional. Yes or No. When Yes, halts all processing and displays an appropriate error. Default is Yes. When No, three variables are populated: CFFTP .Succeeded –...
  • Page 90: File And Directory Operations With Cfftp

    CFML Language Reference CONNECTION="my_query"> <CFOUTPUT QUERY="ListFiles"> #name#<BR> </CFOUTPUT> <P>Close the connection: <CFFTP ACTION="close" CONNECTION="My_query" STOPONERROR="Yes"> <P>Did it succeed? <CFOUTPUT>#CFFTP.Succeeded#</CFOUTPUT> ---> </BODY> </HTML> File and Directory Operations with CFFTP Use this form of the CFFTP tag to perform file and directory operations with CFFTP . If you use connection caching to an already active FTP connection, you don’t need to respecify the connection attributes: USERNAME...
  • Page 91 Chapter 1: ColdFusion Tags CreateDir ListDir GetFile PutFile Rename Remove GetCurrentDir GetCurrentURL ExistsDir ExistsFile Exists Note: Names of objects (files and directories) are case-sensitive; thus, using ListDir on " " will not find a file named " . " test.log test.LOG When ACTION="ListDir", the Attributes column returns either "Directory"...
  • Page 92 CFML Language Reference NAME Required for ACTION="ListDir". Specifies the query name to hold the directory listing. See Usage for more information. SERVER Required if the FTP connection is not already cached. If connection caching is used, the SERVER attribute is not required. The FTP server to connect to. TIMEOUT Optional.
  • Page 93 Chapter 1: ColdFusion Tags ITEM Required for ACTION=Exists, and Remove. Specifies the object, file or directory, of these actions. EXISTING Required for ACTION=Rename. Specifies the current name of the file or directory on the remote server. Required for ACTION=Rename. Specifies the new name of the file or directory on the remote server.
  • Page 94: Cfftp.returnvalue Variable

    CFML Language Reference CFFTP.ReturnValue Variable The value of the CFFTP.ReturnValue variable is determined by the results of the ACTION attribute used in CFFTP . CFFTP.ReturnValue Variable CFFTP Action Value of CFFTP.ReturnValue GetCurrentDir String value containing the current directory GetCurrentURL String value containing the current URL ExistsDir Yes or No ExistsFile...
  • Page 95: Connection Caching

    Chapter 1: ColdFusion Tags CFFTP Query Object Columns (Continued) Column Description Attributes String indicating attributes of the current element IsDirectory Boolean value indicating whether object is a file or directory Connection Caching Once you’ve established a connection with CFFTP, you can reuse the connection to perform additional FTP operations.
  • Page 96 CFML Language Reference <CFFTP CONNECTION="FTP" ACTION="listdir" DIRECTORY="/*." NAME="q" STOPONERROR="Yes"> <HR>FTP Directory Listing:<P> <CFTABLE QUERY="q" HTMLTABLE> <CFCOL HEADER="<B>Name</B>" TEXT="#name#"> <CFCOL HEADER="<B>Path</B>" TEXT="#path#"> <CFCOL HEADER="<B>URL</B>" TEXT="#url#"> <CFCOL HEADER="<B>Length</B>" TEXT="#length#"> <CFCOL HEADER="<B>LastModified</B>" TEXT="Date(Format#lastmodified#)"> <CFCOL HEADER="<B>IsDirectory</B>" TEXT="#isdirectory#"> </CFTABLE>...
  • Page 97: Cfgrid

    Chapter 1: ColdFusion Tags CFGRID Used inside CFFORM, CFGRID allows you to place a grid control in a ColdFusion form. A grid control is a table of data divided into rows and columns. CFGRID column data is specified with individual CFGRIDCOLUMN tags.
  • Page 98 CFML Language Reference DELETEBUTTON="text" SORTASCENDINGBUTTON="text" SORTDESCENDINGBUTTON="text"> </CFGRID> NAME Required. A name for the grid element. HEIGHT Optional. Height value of the grid control in pixels. WIDTH Optional. Width value of the grid control in pixels. VSPACE Optional. Vertical margin spacing above and below the grid control in pixels. HSPACE Optional.
  • Page 99 Chapter 1: ColdFusion Tags ITALIC Optional. Yes or No. Yes presents all grid control text in italic. Default is No. BOLD Optional. Yes or No. Yes presents all grid control text in boldface. Default is No. HREF Optional. URL to associate with the grid item or a query column for a grid that is populated from a query.
  • Page 100 CFML Language Reference TYPE="Image", you can use ROWHEIGHT to define enough room for graphics you want to display in the row. ROWHEADER Optional. Yes or No. Yes displays 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.
  • Page 101 Chapter 1: ColdFusion Tags A hex value can be entered in the form: BGCOLOR="## xxxxxx " where x is 0-9 or A-F. Use either two pound signs or no pound signs. SELECTCOLOR Optional. Background color for a selected item. See BGCOLOR for color options. SELECTMODE Optional.
  • Page 102: Select Mode And Form Variables

    CFML Language Reference Usage You can populate a CFGRID with data from a CFQUERY. If you do not specify any CFGRIDCOLUMN entries, a default set of columns is generated. Each column in the 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 103 Chapter 1: ColdFusion Tags If the APPENDKEY attribute is set to No, then no grid values are appended to the URL. The value of selection is determined by the value of the SELECTMODE attribute: When SELECTMODE="Single", selection is the value of the column clicked. When SELECTMODE="Row", selection is a comma-separated list of column values in the clicked row, beginning with the value of the first cell in the selected row.
  • Page 104 CFML Language Reference <!--- CFGRIDCOLUMN tags are used to change the parameters involved in displaying each data field in the table---> <CFGRID NAME="FirstGrid" WIDTH="450" QUERY="GetCourses" INSERT="Yes" DELETE="Yes" SORT="Yes" FONT="Tahoma" BOLD="No" ITALIC="No" APPENDKEY="No" HIGHLIGHTHREF="No" GRIDDATAALIGN="LEFT" GRIDLINES="Yes" ROWHEADERS="Yes" ROWHEADERALIGN="LEFT" ROWHEADERITALIC="No" ROWHEADERBOLD="No" COLHEADERS="Yes" COLHEADERALIGN="LEFT" COLHEADERITALIC="No"...
  • Page 105: Cfgridcolumn

    Chapter 1: ColdFusion Tags CFGRIDCOLUMN Used with CFGRID in a CFFORM, you use CFGRIDCOLUMN to specify individual column data in a CFGRID control. Font and alignment attributes used in CFGRIDCOLUMN override any global font or alignment settings defined in CFGRID. Syntax <CFGRIDCOLUMN NAME="column_name"...
  • Page 106 CFML Language Reference BOLD Optional. Yes or No. Yes presents text in the column in boldface. Default is No. 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.
  • Page 107 Chapter 1: ColdFusion Tags When TYPE="Numeric", data in the grid can be sorted by the end user as numeric data rather than as simple character text. When TYPE="String_NoCase", data in the grid can be sorted by the end user as case insensitive text data like an Excel spreadsheet rather than as case sensitive character text.
  • Page 108 CFML Language Reference NumberFormat Mask Characters (Continued) Character Meaning Places parentheses around the mask if the number is less than 0. Places + in front of positive numbers, - (minus sign) in front of negative numbers. Place " " (space) in front of positive, - (minus sign) in front of negative numbers.
  • Page 109 Chapter 1: ColdFusion Tags HEADERBOLD="No" HEADERITALIC="No"> <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" DATAALIGN="LEFT" BOLD="No" ITALIC="No" SELECT="Yes" DISPLAY="Yes" HEADERBOLD="No" HEADERITALIC="No">...
  • Page 110: Cfgridrow

    CFML Language Reference CFGRIDROW CFGRIDROW allows you to define a CFGRID that does not use a QUERY as source for row data. If a QUERY attribute is specified in CFGRID, the CFGRIDROW tags are ignored. Syntax <CFGRIDROW DATA="col1, col2, ..."> DATA Required.
  • Page 111: Cfgridupdate

    Chapter 1: ColdFusion Tags CFGRIDUPDATE Used in a CFGRID, CFGRIDUPDATE allows you to perform updates to data sources directly from edited grid data. CFGRIDUPDATE provides a direct interface with your data source. CFGRIDUPDATE first applies DELETE row actions followed by INSERT row actions and finally UPDATE row actions.
  • Page 112 CFML Language Reference DBSERVER Optional. For native database drivers and the SQLOLEDB provider, specifies the name of the database server machine. If specified, DBSERVER overrides the server specified in the data source. DBNAME Optional. The database name (Sybase System 11 driver and SQLOLEDB provider only).
  • Page 113 Chapter 1: ColdFusion Tags Example <!--- This example shows the CFGRID, CFGRIDCOLUMN, CFGRIDROW, and CFGRIDUPDATE tags in action ---> <!--- If the gridEntered form field has been tripped, perform the gridupdate on the table specified in the database. Using the default value keyonly=yes allows us to change only the information that differs from the previous grid --->...
  • Page 114: Cfheader

    CFML Language Reference CFHEADER CFHEADER generates custom HTTP response headers to return to the client. Syntax <CFHEADER NAME="header_name" VALUE="header_value"> <CFHEADER STATUSCODE="status_code" STATUSTEXT="status_text"> NAME Required if you do not specify the STATUSCODE attribute. A name for the header. VALUE Optional. A value for the HTTP header. This attribute is used in conjunction with the NAME attribute.
  • Page 115: Cfhtmlhead

    Chapter 1: ColdFusion Tags CFHTMLHEAD CFHTMLHEAD writes the text specified in the TEXT attribute to the <HEAD> section of a generated HTML page. CFHTMLHEAD can be useful for embedding JavaScript code, or placing other HTML tags such as META, LINK, TITLE, or BASE in an HTML page header.
  • Page 116: Cfhttp

    CFML Language Reference CFHTTP The CFHTTP tag allows you to execute POST and GET operations on files. Using CFHTTP, you can execute standard GET operations as well as create a query object from a text file. POST operations allow you to upload MIME file types to a server, or post cookie, formfield, URL, file, or CGI variables directly to a specified server.
  • Page 117 Chapter 1: ColdFusion Tags PASSWORD Optional. When required by a server, a valid password. NAME Optional. The name to assign to a query when a query is to be constructed from a file. COLUMNS Optional. The column names for a query. If no column names are specified, the query returns all rows in the query except for the first row.
  • Page 118 CFML Language Reference FRAME SRC BGSOUND SRC OBJECT DATA OBJECT CLASSID OBJECT CODEBASE OBJECT USEMAP PROXYSERVER Optional. Host name or IP address of a proxy server. PROXYPORT Optional. The port number on the proxy server from which the object is being requested.
  • Page 119 Chapter 1: ColdFusion Tags If there is no timeout set on the URL in the browser, no timeout set in the ColdFusion Administrator, and no timeout set with the TIMEOUT attribute, ColdFusion processes requests synchronously; thus, ColdFusion waits indefinitely for the CFHTTP request to process. Note that you must enable the timeout set in the ColdFusion Administrator in order for the ColdFusion Administrator timeout and the URL timeout to take effect.
  • Page 120 CFML Language Reference Encryption — CFHTTP is capable of using Secure Sockets Layer (SSL) for negotiating secured transactions over the wire. CFHTTP.StatusCode— CFHTTP throws an error and provides the CFHTTP.StatusCode variable for access to the HTTP error string associated with the error if the THROWONERROR attribute is set to YES.
  • Page 121 Chapter 1: ColdFusion Tags </UL> <CFHTTP URL = "http://www.allaire.com" resolveurl = 1 throwonerror = Yes > </CFHTTP> <CFOUTPUT> #cfhttp.filecontent#<BR> <BR> <H3><B>The mime-type:</B></H3><BR> #cfhttp.mimetype#<BR> <H3><B>The Status Code:</B></H3><BR> #cfhttp.statuscode#<BR> <H3><B>The Raw Header:</B></H3><BR> #cfhttp.header#<BR> </CFOUTPUT> <H3><B>Output the Response Headers:</B></H3><BR> <HR> <CFLOOP collection=#CFHTTP.RESPONSEHEADER# item="httpHeader"> <CFSET value = CFHTTP.RESPONSEHEADER[httpHeader]>...
  • Page 122: Cfhttpparam

    CFML Language Reference CFHTTPPARAM Required for CFHTTP POST operations, CFHTTPPARAM is used to specify the parameters necessary to build a CFHTTP POST. Syntax <CFHTTPPARAM NAME="name" TYPE="type" VALUE="transaction type" FILE="filename"> NAME Required. A variable name for the data being passed. TYPE Required.
  • Page 123 Chapter 1: ColdFusion Tags <HEAD> <TITLE>Sample Page</TITLE> </HEAD> <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 124: Cfif/Cfelseif/Cfelse

    CFML Language Reference CFIF/CFELSEIF/CFELSE Used with CFELSE and CFELSEIF, CFIF lets you create simple and compound conditional statements in CFML. The value in the CFIF tag can be any expression. Syntax <CFIF expression> HTML and CFML tags <CFELSEIF> HTML and CFML tags <CFELSE expression>...
  • Page 125 Chapter 1: ColdFusion Tags </CFOUTPUT> <P>If we would like more than one condition to be the case, we can ask for a list of the centers in San Diego <B>OR</B> Santa Ana. If the center does not follow this condition, we can use CFELSE to show only the names and cities of the other centers.
  • Page 126: Cfimpersonate

    CFML Language Reference CFIMPERSONATE Allows you to impersonate a user defined in a security context defined in Advanced Security. The ColdFusion Application Server enforces all the privileges and restrictions that have been set up for that user with the Advanced Security rules. Syntax <CFIMPERSONATE SECURITYCONTEXT="SecurityContext"...
  • Page 127 Chapter 1: ColdFusion Tags engine enforces the rules and policies specified for the user in the Advanced Security section of the ColdFusion Administrator. Therefore, there is no need to make multiple isAuthorized() calls in the code to protect each resource. Refer to Administering ColdFusion Server for more information about Advanced Security.
  • Page 128: Cfinclude

    CFML Language Reference CFINCLUDE CFINCLUDE lets you embed references to ColdFusion pages in your CFML. If necessary, you can embed CFINCLUDE tags recursively. For an additional method of encapsulating CFML, see the CFMODULE tag, used to create custom tags in CFML. Syntax <CFINCLUDE TEMPLATE="template_name">...
  • Page 129: Cfindex

    Chapter 1: ColdFusion Tags CFINDEX Use the CFINDEX tag to populate collections with indexed data. CFINDEX and CFSEARCH encapsulate the Verity indexing and searching utilities. Verity collections can be populated from either text files in a directory you specify, or from a query generated by any ColdFusion query.
  • Page 130 CFML Language Reference File — Indexes files. Path — Indexes all files in specified path that pass EXTENSIONS filter. Custom — Indexes custom entities from a ColdFusion query. TITLE Required when TYPE="Custom". Specifies one of the following: A title for the collection A query column name for any TYPE and a valid query name The TITLE attribute allows searching collections by title or displaying a separate title from the actual key.
  • Page 131 Chapter 1: ColdFusion Tags EXTENSIONS Optional. Specifies the comma-separated list of file extensions that ColdFusion uses to index files when TYPE="Path". Default is HTM, HTML, CFM, CFML, DBM, DBML. An entry of "*." returns files with no extension: EXTENSIONS=".htm, .html, .cfm, .cfml, *." Returns files with the specified extensions as well as files with no extension.
  • Page 132 CFML Language Reference <!--- To index the collection, select the check box on the form ---> <CFIF IsDefined("form.IndexCollection")> <CFINDEX ACTION="UPDATE" COLLECTION="Snippets" KEY="c:\inetpub\wwwroot\cfdocs\snippets" TYPE="PATH" TITLE="Test" URLPATH="http://127.0.0.1/cfdocs/snippets/" EXTENSIONS=".cfm" RECURSE="Yes">...
  • Page 133: Cfinput

    Chapter 1: ColdFusion Tags CFINPUT CFINPUT is used inside CFFORM to place radio buttons, checkboxes, or text boxes. Provides input validation for the specified control type. CFINPUT supports the JavaScript onClick event in the same manner as the HTML INPUT tag: <CFINPUT TYPE="radio"...
  • Page 134 CFML Language Reference date — Verifies US date entry in the form mm/dd/yyyy. 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. integer —...
  • Page 135 Chapter 1: ColdFusion Tags If you specify a value in quotation marks, you must escape the quotation marks by doubling them, for example, PASSTHROUGH= "readonly= " "YES " " " Example <!--- This example shows the use of CFINPUT to validate input ---> <HTML>...
  • Page 136: Cfinsert

    CFML Language Reference CFINSERT CFINSERT inserts new records in data sources. Syntax <CFINSERT DATASOURCE="ds_name" DBTYPE="type" DBSERVER="dbms" DBNAME="database name" TABLENAME="tbl_name" TABLEOWNER="owner" TABLEQUALIFIER="tbl_qualifier" USERNAME="username" PASSWORD="password" PROVIDER="COMProvider" PROVIDERDSN="datasource" FORMFIELDS="formfield1, formfield2, ..."> DATASOURCE Required. Name of the data source that contains your table. DBTYPE Optional.
  • Page 137 Chapter 1: ColdFusion Tags TABLENAME Required. Name of the table you want the form fields inserted in. Note the following: ORACLE drivers — This specification must be in uppercase. Sybase driver — This specification is case-sensitive and must be in the same case as that used when the table was created TABLEOWNER Optional.
  • Page 138 CFML Language Reference SELECT CommentID, EMail, FromUser, Subject, CommtType, MessText, Posted, Processed FROM Comments </CFQUERY> <HTML> <HEAD> <TITLE> CFINSERT Example </TITLE> </HEAD> <BODY bgcolor=silver> <H3>CFINSERT Example</H3> <P>First, we’ll show a list of the available comments in the cfsnippets datasource. <!--- show all the comments in the db ---> <TABLE>...
  • Page 139: Cfldap

    Chapter 1: ColdFusion Tags CFLDAP CFLDAP provides an interface to LDAP (Lightweight Directory Access Protocol) directory servers like the Netscape Directory Server. For complete examples of CFLDAP usage, refer to Developing Web Applications with ColdFusion. Syntax <CFLDAP SERVER="server_name" PORT="port_number" USERNAME="name" PASSWORD="password"...
  • Page 140 CFML Language Reference Modify — Modifies LDAP entries on an LDAP server with the exception of the distinguished name ("DN") attribute. Requires DN, ATTRIBUTES. See the MODIFYTYPE attribute for additional controls. ModifyDN — Modifies the distinguished name attribute for LDAP entries on an LDAP server.
  • Page 141 Chapter 1: ColdFusion Tags FILTERFILE Optional. Specifies the name of a filter file and the name of the stanza tag within that file that contains the LDAP filter string specification. You can specify either an absolute path name or a simple file name to identify the file. If you use a simple file name, CFLDAP looks for it in ColdFusion’s default LDAP directory.
  • Page 142 CFML Language Reference 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 143 Chapter 1: ColdFusion Tags The CFSSL_BASIC type of security provides V2 SSL, and the CFSSL_CLIENT_AUTH type of security provides V3 SSL. V2 SSL provides encryption and server authentication. V3 SSL adds to this certificate-based client authentication. Both forms of security encrypt the conversation, and the server always sends a digital certificate to confirm that it is the right server.
  • Page 144 CFML Language Reference <TH><FONT SIZE="-2">Name</FONT></TH> <TH><FONT SIZE="-2">Organization</FONT></TH> <TH><FONT SIZE="-2">Location</FONT></TH> <TH><FONT SIZE="-2">E-Mail</FONT></TH> <TH><FONT SIZE="-2">Phone</FONT></TH> </TR> <CFOUTPUT QUERY="results"> <TR> <TD><FONT SIZE="-2">#cn#</FONT></TD> <TD><FONT SIZE="-2">#o#</FONT></TD> <TD><FONT SIZE="-2">#l#, #st#, #c#</FONT></TD> <TD><FONT SIZE="-2"><A HREF="mailto:#mail#">#mail#</A></FONT></TD> <TD><FONT SIZE="-2">#telephonenumber#</FONT></TD> </TR> </CFOUTPUT> </TABLE> </CENTER> </CFIF> </CFIF> </BODY> </HTML>...
  • Page 145: Cflocation

    Chapter 1: ColdFusion Tags CFLOCATION CFLOCATION opens a specified ColdFusion page or HTML file. For example, you might use CFLOCATION to specify a standard message or response that you use in several different ColdFusion applications. Use the ADDTOKEN attribute to verify client requests.
  • Page 146: Cflock

    CFML Language Reference CFLOCK The CFLOCK tag 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 147 Chapter 1: ColdFusion Tags THROWONTIMEOUT Optional. Yes or No. Specifies how timeout conditions should be handled. If the value is Yes an exception will be generated to provide notification of the timeout. If the value is No execution continues past the </CFLOCK> tag. Default is Yes. TYPE Optional.
  • Page 148 CFML Language Reference following table shows which features are available for Server, Application, and Session scope. Features Server Application Session No automatic checking or locking Full checking Automatic read locking Single Threaded Sessions Each feature that you select has tradeoffs. No automatic checking or locking.
  • Page 149 Chapter 1: ColdFusion Tags Thus, 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 Locks the session scope . Locks the application scope.
  • Page 150 CFML Language Reference Lock the application scope. In the CFLOCK tag, indicate scope by specifying "APPLICATION" as the value of the SCOPE attribute. Lock the server scope. In the CFLOCK tag, indicate the scope by specifying "SERVER" as the value of the SCOPE attribute. Unlock the server scope.
  • Page 151 Chapter 1: ColdFusion Tags <CFIF NOT IsDefined("session.color")> <CFSET session.color = ""> </CFIF> </CFLOCK> <!--------------------------------------------------------------------- Use the application lock for the application variable. This variable keeps track of the total number of turtlenecks sold. The application lock should have the same name as specified in the CFAPPLICATION tag.
  • Page 152 CFML Language Reference <CFLOCK SCOPE="Application" TIMEOUT="30" TYPE="Exclusive"> <CFSET application.number = application.number + 1> </CFLOCK> <CFELSE><!--- Show the form only if it has not been submitted. ---> <FORM ACTION="cflock.cfm" METHOD="POST"> <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>...
  • Page 153: Cfloop

    Chapter 1: ColdFusion Tags CFLOOP Looping is a very powerful programming technique that lets you repeat a set of instructions or display output over and over until one or more conditions are met. CFLOOP supports five different types of loops: Index Loops Conditional Loops Looping over a Query...
  • Page 154: Conditional Loops

    CFML Language Reference FROM="1" TO="5"> The loop index is <CFOUTPUT>#LoopCount#</CFOUTPUT>.<BR> </CFLOOP> 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.
  • Page 155: Looping Over A Query

    Chapter 1: ColdFusion Tags <CFSET CountVar=CountVar + 1> The loop index is <CFOUTPUT>#CountVar#</CFOUTPUT>.<BR> </CFLOOP> The result of this loop in a browser would look something like: The loop index is 1. The loop index is 2. The loop index is 3. The loop index is 4.
  • Page 156: Looping Over A List

    CFML Language Reference The following example loops from the tenth through the twentieth record returned by "MyQuery ": <CFSET Start=10> <CFSET End=20> <CFLOOP QUERY="MyQuery" STARTROW="#Start#" ENDROW="#End#"> <CFOUTPUT>#MyQuery.MyColName#</CFOUTPUT><BR> </CFLOOP> The loop is done when there are no more records or when the current record is greater than the value of the ENDROW attribute.
  • Page 157: Looping Over A Com Collection Or Structure

    Chapter 1: ColdFusion Tags DELIMITERS Optional. Specifies the delimiter characters used to separate items in the LIST. Example This loop will display the names of each of the Beatles: <CFLOOP INDEX="ListElement" LIST="John,Paul,George,Ringo"> <CFOUTPUT>#ListElement#</CFOUTPUT><BR> </CFLOOP> Although CFLOOP expects elements in the list to be separated by commas by default, you are free to specify your own element boundaries in the DELIMITER attribute.
  • Page 158 CFML Language Reference Examples This example employs a COM object to output a list of files. In this example, is a FFUNC collection of objects. file2 <CFOBJECT CLASS=FileFunctions.files NAME=FFunc ACTION=Create> <CFSET FFunc.Path = "c:\"> <CFSET FFunc.Mask = "*.*" > <CFSET FFunc.attributes = 16 > <CFSET x=FFunc.GetFileList()>...
  • Page 159: Cfmail

    Chapter 1: ColdFusion Tags CFMAIL CFMAIL allows you to send email messages via an SMTP server. See also CFMAILPARAM. Syntax <CFMAIL TO="recipient" FROM="sender" CC="copy_to" BCC="blind_copy_to" SUBJECT="msg_subject" TYPE="msg_type" MAXROWS="max_msgs" MIMEATTACH="path" QUERY="query_name" GROUP="query_column" GROUPCASESENSITIVE="yes/no" STARTROW="query_row" SERVER="servername" PORT="port_ID" MAILERID="headerid" TIMEOUT="seconds"> Required. The name of the recipient(s) of the email message. This can be either a static address (as in, TO="support@allaire.com"), a variable that contains an address (such as, TO="#Form.Email#"), or the name of a query column that contains address information (such as, TO="#EMail#").
  • Page 160 CFML Language Reference TYPE Optional. Specifies extended type attributes for the message. Currently, the only valid value for this attribute is "HTML". Specifying TYPE= "HTML" informs the receiving email client that the message has embedded HTML tags that need to be processed.
  • Page 161 Chapter 1: ColdFusion Tags TIMEOUT Optional. The number of seconds to wait before timing out the connection to the SMTP server. Example <!--- This view-only example shows the use of CFMAIL ---> <HTML> <HEAD> <TITLE>CFMAIL Example</TITLE> </HEAD> <BODY bgcolor=silver> <H3>CFMAIL Example</H3> <P>This view-only example shows the use of CFMAIL.
  • Page 162: Cfmailparam

    CFML Language Reference CFMAILPARAM CFMAILPARAM can either attach a file or add a header to a message. If you use CFMAILPARAM, it is nested within a CFMAIL tag. You can use more than one CFMAILPARAM tags within a CFMAIL tag in order to attach one or more files and headers.
  • Page 163 Chapter 1: ColdFusion Tags </P> <CFMAIL FROM="peter@domain.com" To="paul@domain.com" Subject="See Important Attachments and Reply"> <CFMAILPARAM NAME="Reply-To" VALUE="mary@domain.com"> Please read the text file and view the new logo, and let us know what you think. <CFMAILPARAM FILE="c:\work\readme.txt"> <CFMAILPARAM FILE="c:\work\logo.gif"> </CFMAIL> </BODY> </HTML>...
  • Page 164: Cfmodule

    CFML Language Reference CFMODULE Use CFMODULE to invoke a custom tag for use in your ColdFusion application pages. CFMODULE can help deal with any custom tag name conflicts that might arise. Use the TEMPLATE attribute to name a ColdFusion page containing the custom tag definition, including its path.
  • Page 165 Chapter 1: ColdFusion Tags Likewise, if the custom tag uses a CFASSOCIATE tag to save its attributes, the attributes passed with ATTRIBUTECOLLECTION are saved as independent attribute values with no indication that the attributes are grouped into a structure by the custom tag’s caller. Example <!--- This example shows the use of CFMODULE --->...
  • Page 166 CFML Language Reference 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 ---> <P>Here is another way to invoke the custom tag, using the NAME attribute.</P> <CFOUTPUT>#HTMLCodeFormat("<CFMODULE NAME=’myTag’...
  • Page 167: Cfobject

    Chapter 1: ColdFusion Tags CFOBJECT The CFOBJECT tag allows you to call methods in COM, CORBA, and JAVA objects. Note ColdFusion administrators can disable the CFOBJECT tag in the ColdFusion Administrator Basic Security page. On UNIX, COM objects are not currently supported by CFOBJECT. CFOBJECT topics CFOBJECT Type="COM"...
  • Page 168: Cfobject Type="Com

    CFML Language Reference CFOBJECT Type="COM" CFOBJECT allows you to create and use COM (Component Object Model) objects. Any automation server object type that is currently registered on a machine can be invoked. You can use a utility like Microsoft’s OLEView to browse COM objects. OLEView, as well as information about COM and DCOM, can be found at Microsoft’s OLE Development web site http://www.microsoft.com/oledev/.
  • Page 169 Chapter 1: ColdFusion Tags Example <HTML> <HEAD> <TITLE>CFOBJECT (COM) Example</TITLE> </HEAD> <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 170: Cfobject Type="Corba

    CFML Language Reference <CFOUTPUT> Last name: #file2.lastname# <BR> </CFOUTPUT> </CFLOOP> </BODY> </HTML> CFOBJECT Type="CORBA" CFOBJECT allows you to call methods in CORBA objects. These CORBA objects must already have been defined and registered for use. Syntax <CFOBJECT TYPE="CORBA" CONTEXT="context" CLASS="file or naming service" NAME="text"...
  • Page 171: Cfobject Type="Java

    Chapter 1: ColdFusion Tags Note that each type-value pair has to start with a leading "-". Usage ColdFusion Enterprise version 4.0 and above supports CORBA through the Dynamic Invocation Interface (DII). To use CFOBJECT with CORBA objects, you need to know either the name of the file containing a stringified version of the IOR or the object’s naming context in the naming service.
  • Page 172 CFML Language Reference Call CFOBJECT to load the class. See Example. Use the init method with appropriate arguments to call a constructor explicitly. For example: <CFSET ret = myObj.init(arg1, arg2)> Calling a public method on the object without first calling the "init" method results in an implicit call to the default constructor.
  • Page 173: Cfoutput

    Chapter 1: ColdFusion Tags CFOUTPUT Displays the results of a database query or other operation. If you need to nest CFOUTPUT tags, please read the "Usage" section. Syntax <CFOUTPUT QUERY="query_name" GROUP="query_column" GROUPCASESENSITIVE="yes/no" STARTROW="start_row" MAXROWS="max_rows_output"> </CFOUTPUT> QUERY Optional. The name of the CFQUERY from which you want to draw data for the output section.
  • Page 174 CFML Language Reference Example <!--- This example shows how CFOUTPUT operates ---> <!--- run a sample query ---> <CFQUERY NAME="GetCourses" DATASOURCE="cfsnippets"> SELECT Dept_ID, CorName, CorLevel FROM courseList ORDER by Dept_ID, CorLevel, CorName </CFQUERY> <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.
  • Page 175: Cfparam

    Chapter 1: ColdFusion Tags CFPARAM CFPARAM is used to test for a parameter’s existence, and optionally test its data type, and provide a default value if one is not assigned. Syntax <CFPARAM NAME="param_name" TYPE="data_type"> DEFAULT="value"> NAME The name of the parameter you are testing (such as "Client.Email " or "Cookie.BackgroundColor ").
  • Page 176 CFML Language Reference Usage There are three ways to use CFPARAM: Test for a required variable — Use CFPARAM with only the NAME attribute to test that a required variable exists. If the variable does not exist, ColdFusion server stops processing the page and returns an error. Test for a required variable and for the type of variable —...
  • Page 177 Chapter 1: ColdFusion Tags <P> <FORM ACTION="cfparam.cfm" METHOD="POST"> Type in a new value for tempVar, and hit submit:<BR> <INPUT TYPE="Text" NAME="tempVar"> <INPUT TYPE="Submit" NAME="" VALUE="submit"> </FORM> </BODY> </HTML>...
  • Page 178: Cfpop

    CFML Language Reference CFPOP CFPOP retrieves and deletes email messages from a POP mail server. See also CFMAIL. Syntax <CFPOP SERVER="servername" PORT="port_number" USERNAME="username" PASSWORD="password" ACTION="action" NAME="queryname" MESSAGENUMBER="number" ATTACHMENTPATH="path" TIMEOUT="seconds" MAXROWS="number" STARTROW="number" GENERATEUNIQUEFILENAMES="boolean"> SERVER Required. Host name (biff.upperlip.com) or IP address (192.1.2.225) of the POP server.
  • Page 179 Chapter 1: ColdFusion Tags NAME Optional. The name you assign to the index query. Required for ACTION="GetHeaderOnly" and ACTION="GetAll". MESSAGENUMBER Optional. Specifies the message number(s) for the given action. MESSAGENUMBER is required for ACTION="Delete". If it is provided for ACTION="GetHeaderOnly" or ACTION="GetAll", only referenced messages will be retrieved.
  • Page 180 CFML Language Reference CFPOP Query Variables (Continued) Variable Names Description queryname. CurrentRow The current row of the query being processed by CFOUTPUT. queryname. ColumnList The list of the column names in the query. Message The following table lists the message header and body columns that are returned by CFPOP when you specify the ACTION attribute to be either GetHeaderOnly or GetAll.
  • Page 181 Chapter 1: ColdFusion Tags Usage To create a ColdFusion date/time object from the date-time string that is extracted from a mail message in the queryname.date column, use the following table to determine what to do. Date-Time Parsing According to Locale Locale What to do? English (US) locale...
  • Page 182 CFML Language Reference <CFOUTPUT QUERY="GetHeaders"> <LI>Row: #CurrentRow#: From: #From# -- Subject: #Subject# </CFOUTPUT> </UL> </CFIF> </CFIF> <FORM ACTION= "cfpop.cfm " METHOD= "POST "> <P>Enter your mail server: <P><INPUT TYPE= "Text " NAME= "server "> <P>Enter your username: <P><INPUT TYPE= "Text " NAME= "username "> <P>Enter your password: <P><INPUT TYPE= "password "...
  • Page 183: Cfprocessingdirective

    Chapter 1: ColdFusion Tags CFPROCESSINGDIRECTIVE Suppresses extraneous white space, and other output, produced by the CFML within the tag’s scope. Syntax <CFPROCESSINGDIRECTIVE SUPPRESSWHITESPACE="Yes" or "No"> … any CFML tags here … </CFPROCESSINGDIRECTIVE> SUPPRESSWHITESPACE Required. Boolean indicating whether to suppress the white space and other output generated by the CFML tags within the CFPROCESSINGDIRECTIVE block.
  • Page 184: Cfprocparam

    CFML Language Reference CFPROCPARAM The CFPROCPARAM tag is nested within a CFSTOREDPROC tag. You use it to specify parameter information, including type, name, value, and length. Syntax <CFPROCPARAM TYPE="IN/OUT/INOUT" VARIABLE="variable name" DBVARNAME="DB variable name" VALUE="parameter value" CFSQLTYPE="parameter datatype" MAXLENGTH="length" SCALE="decimal places" NULL="yes/no">...
  • Page 185 Chapter 1: ColdFusion Tags MAXLENGTH Optional. Maximum length of the parameter. SCALE Optional. Number of decimal places of the parameter. NULL Optional. Specify Yes or No. Indicates whether the parameter is passed as a NULL. If you specify Yes, the tag ignores the VALUE attribute. Usage Use this tag to identify stored procedure parameters and their data type.
  • Page 186 CFML Language Reference <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> <P>Record Count: #RS3.RecordCount# <P>Columns: #RS3.ColumnList# <hr> The return code for the stored procedure is: ’#CFSTOREDPROC.STATUSCODE#’<br>...
  • Page 187: Cfprocresult

    Chapter 1: ColdFusion Tags CFPROCRESULT The CFPROCRESULT tag is nested within a CFSTOREDPROC tag. This tag’s NAME parameter specifies a result set name that other ColdFusion tags, such as CFOUTPUT and CFTABLE, use to access the result set. It also allows you to optionally identify which of the stored procedure’s result sets to return.
  • Page 188 CFML Language Reference </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> </CFOUTPUT> <P> <CFOUTPUT> <hr> <P>Record Count: #RS3.RecordCount# <P>Columns: #RS3.ColumnList# <hr>...
  • Page 189: Cfquery

    Chapter 1: ColdFusion Tags CFQUERY CFQUERY passes SQL statements for any purpose to your data source. Not limited to queries. Syntax <CFQUERY NAME="query_name" DATASOURCE="ds_name" DBTYPE="type" DBSERVER="dbms" DBNAME="database name" USERNAME="username" PASSWORD="password" MAXROWS="number" BLOCKFACTOR="blocksize" TIMEOUT="milliseconds" CACHEDAFTER="date" CACHEDWITHIN="timespan" PROVIDER="COMProvider" PROVIDERDSN="datasource" DEBUG="Yes/No"> SQL statements </CFQUERY>...
  • Page 190 CFML Language Reference DB2 —DB2 5.2 native database driver. Informix73 —Informix73 native database driver. DBSERVER Optional. For native database drivers and the SQLOLEDB provider, specifies the name of the database server machine. If specified, DBSERVER overrides the server specified in the data source. DBNAME Optional.
  • Page 191 Chapter 1: ColdFusion Tags When specifying a date value as a string, make sure it is enclosed in quotes. CACHEDWITHIN Optional. Enter a timespan using the ColdFusion CreateTimeSpan function. Cached query data will be used if the original query date falls within the time span you define.
  • Page 192 CFML Language Reference Example <!--- This example shows the use of CFQUERY ---> <HTML> <HEAD> <TITLE>CFQUERY Example</TITLE> </HEAD> <BODY> <H3>CFQUERY Example</H3> <!--- define startrow and maxrows to facilitate ’next N’ style browsing ---> <CFPARAM NAME="MaxRows" DEFAULT="10"> <CFPARAM NAME="StartRow" DEFAULT="1"> <!--- query database for information ---> <CFQUERY NAME="GetParks"...
  • Page 193 Chapter 1: ColdFusion Tags </TR> </CFOUTPUT> <!--- If the total number of records is less than or equal to the total number of rows, then offer a link to the same page, with the StartRow value incremented by MaxRows (in the case of this example, incremented by 10) ---> <TR>...
  • Page 194: Cfqueryparam

    CFML Language Reference CFQUERYPARAM CFQUERYPARAM checks the data type of a query parameter. The CFQUERYPARAM tag is nested within a CFQUERY tag. More specifically, it is embedded within the query SQL statement. If you specify its optional parameters, CFQUERYPARAM also performs data validation.
  • Page 195 Chapter 1: ColdFusion Tags MAXLENGTH Optional. Maximum length of the parameter. The default value is the length of the string specified in the VALUE attribute. SCALE Optional. Number of decimal places of the parameter. The default value is zero. Applicable for CF_SQL_NUMERIC and CF_SQL_DECIMAL. NULL Optional.
  • Page 196 CFML Language Reference For a Sybase11 data source, the syntax of the SQL statement is as follows: SELECT * FROM courses WHERE col1=10 Example <!-------------------------------------------------------------------- This example shows the use of CFQUERYPARAM when valid input is given in Course_ID. -----------------------------------------------------------------------> <HTML>...
  • Page 197 Chapter 1: ColdFusion Tags </CFOUTPUT> </BODY> </HTML> The CFQUERYPARAM tag returns the following error message when this example is executed. VALUE Invalid data ’12; DELETE courses WHERE Course_ID=20’ for CFSQLTYPE ’CF_SQL_INTEGER’. <!---------------------------------------------------------------------- This example shows the use of CFQUERYPARAM when invalid string data is in Course_ID.
  • Page 198: Cfregistry

    CFML Language Reference CFREGISTRY The CFREGISTRY tag reads, writes, and deletes keys and values in the system registry. CFREGISTRY is supported on all platforms, including Solaris and HP-UX. Note The ColdFusion Server Basic security settings may prevent CFRegistry from executing. These settings are managed using the ColdFusion Administrator Basic Security page.
  • Page 199: Cfregistry Action="Getall

    Chapter 1: ColdFusion Tags Sections that follow describe these values and attributes in greater detail. CFREGISTRY ACTION="GetAll" Use CFREGISTRY with the GetAll action to return all registry keys and values defined in a branch. You can access these values as you would any record set. Syntax <CFREGISTRY ACTION="GetAll"...
  • Page 200: Cfregistry Action="Get

    CFML Language Reference Example <!--- This example uses CFREGISTRY with the GetAll Action ---> <HTML> <HEAD> <TITLE>CFREGISTRY ACTION="GetAll"</TITLE> </HEAD> <BODY> <CFREGISTRY ACTION="GetAll" 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 201: Cfregistry Action="Set

    Chapter 1: ColdFusion Tags VARIABLE Required. Variable into which CFREGISTRY places the value. Usage CFREGISTRY does not create the variable if the value does not exist. Example <!--- This example uses CFREGISTRY with the Get Action ---> <HTML> <HEAD> <TITLE>CFREGISTRY ACTION="Get"</TITLE> </HEAD>...
  • Page 202: Cfregistry Action="Delete

    CFML Language Reference VALUE Optional. The value data to be set. If you omit this attribute, CFREGISTRY creates default value data, as follows: String — Default value is an empty string: "" DWord — Default value is 0 (zero) Usage CFREGISTRY creates the key or value if it does not exist.
  • Page 203 Chapter 1: ColdFusion Tags Usage If you delete a key, CFREGISTRY also deletes values and subkeys defined beneath the key. Example <!--- This example uses CFREGISTRY with the Delete Action to remove a key from the registry ---> <HTML> <HEAD> <TITLE>CFREGISTRY ACTION="Delete"</TITLE>...
  • Page 204: Cfreport

    CFML Language Reference CFREPORT CFREPORT runs a predefined Crystal Reports report. Syntax <CFREPORT REPORT="report_path" ORDERBY="result_order" USERNAME="username" PASSWORD="password" FORMULA="formula"> </CFREPORT> REPORT Required. Specifies the path of the report. Store your Crystal Reports files in the same directories that you store your ColdFusion page files. ORDERBY Optional.
  • Page 205 Chapter 1: ColdFusion Tags The CFREPORT tag requires the name of the report to run; CFREPORT can also pass information to the report file being displayed to change the output conditions. <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.
  • Page 206: Cfrethrow

    CFML Language Reference CFRETHROW Rethrows the currently active exception. <CFRETHROW> preserves the exception’s CFCATCH.TYPE and CFCATCH.TAGCONTEXT information. See also CFTRY/CFCATCH. Syntax <CFRETHROW> Usage Use the <CFRETHROW> tag within a <CFCATCH> block. This tag is useful in error handling code when the error handler is not able to successfully handle the thrown error.
  • Page 207 Chapter 1: ColdFusion Tags </CFCATCH> </CFTRY> </BODY> </HTML>...
  • Page 208: Cfscript

    CFML Language Reference CFSCRIPT The CFSCRIPT tag encloses a code segment containing CFScript. Syntax <CFSCRIPT> CFScript code goes here </CFSCRIPT> Usage Use CFSCRIPT to perform processing in CFScript instead of CFML. Note the following regarding CFScript: CFScript uses ColdFusion functions, expressions, and operators You can read and write ColdFusion variables inside of CFScript One use of CFSCRIPT is to wrap a series of assignment functions that would otherwise require CFSET statements.
  • Page 209: Cfsearch

    Chapter 1: ColdFusion Tags CFSEARCH Use the CFSEARCH tag to execute searches against data indexed in Verity collections. Collections can be created by calling the CFCOLLECTION tag, by using the ColdFusion Administrator, or through native Verity indexing tools. Collections are populated with data either with the CFINDEX tag, or externally, using native Verity indexing tools.
  • Page 210 CFML Language Reference STARTROW Optional. Specifies the first row number to be retrieved. Default is 1. 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.
  • Page 211 Chapter 1: ColdFusion Tags SUMMARY — Returns the contents of the automatic summary generated by CFINDEX. The default summarization selects the best three matching sentences, up to a maximum of 500 characters. RECORDCOUNT — Returns the number of records returned in the record set. CURRENTROW —...
  • Page 212 CFML Language Reference <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" COLHEADERS HTMLTABLE> <CFCOL HEADER="SCORE" TEXT="#score#"> <CFCOL HEADER="TITLE" TEXT="<a href=’#url#’ target=’blank’>#title#</A>"> <CFCOL HEADER="SUMMARY"...
  • Page 213: Cfselect

    Chapter 1: ColdFusion Tags CFSELECT Used inside CFFORM, CFSELECT allows you to construct a drop-down list box form control. You can populate the drop-down list box from a query, or using the OPTION tag. Use OPTION elements to populate lists. Syntax for the OPTION tag is the same as for its HTML counterpart.
  • Page 214 CFML Language Reference VALUE Optional. The query column value for the list element. Used with the QUERY attribute. DISPLAY Optional. The query column displayed. Defaults to the value of VALUE. Used with the QUERY attribute. PASSTHROUGH Optional. HTML attributes that are not explicitly supported by CFSELECT. If you specify an attribute and its value, the attribute and its value are passed to the HTML code that is generated for the CFSELECT tag.
  • Page 215 Chapter 1: 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 216: Cfservlet

    CFML Language Reference CFSERVLET Executes a Java servlet on a JRun engine. This tag is used in conjunction with the CFSERVLETPARAM tag, which passes data to the servlet. Syntax <CFSERVLET CODE="class name of servlet" JRUNPROXY="proxy server" TIMEOUT="timeout in seconds" WRITEOUTPUT="Yes/No" DEBUG="Yes/No">...
  • Page 217 Chapter 1: ColdFusion Tags Usage The syntax of the CFSERVLET tag is designed to be consistent with the HTML markup <SERVLET> and <PARAM> used by some web servers to invoke Java servlets from .shtml pages in what is known as SSI, Server-Side Includes. CFSERVLET Variables Variable Name Description...
  • Page 218: Cfservletparam

    CFML Language Reference CFSERVLETPARAM The CFSERVLETPARAM is a child of CFSERVLET. It is used to pass data to the servlet. Each CFSERVLETPARAM tag within the CFSERVLET block passes a separate piece of data to the servlet. See also CFSERVLET. Syntax <CFSERVLET ...>...
  • Page 219 Chapter 1: ColdFusion Tags The first passes name-value pairs by value. This method uses the attributes NAME and VALUE to pass a simple name-value string pair to the servlet. The NAME attribute represents the name of the servlet parameter from which the string specified in the VALUE attribute can be retrieved.
  • Page 220 CFML Language Reference Example <CFSERVLET CODE=”MyServletName” JRUNPROXY=”236.3.3.4:8083” TIMEOUT=”300” WRITEOUTPUT=”Yes” DEBUG="Yes"> <CFSERVLETPARAM NAME=”Param1” VALUE=”Value1”> <CFSERVLETPARAM NAME=”Param2” VALUE=”Value2”> <CFSERVLETPARAM NAME=”Attribute1” VARIABLE=”CFVar1” TYPE="BOOL"> <CFSERVLETPARAM NAME=”Attribute2” VARIABLE=”CFVar2”> </CFSERVLET>...
  • Page 221: Cfset

    Chapter 1: ColdFusion Tags CFSET Use the CFSET tag to define a ColdFusion variable. If the variable already exists, CFSET resets it to the specified value. Syntax <CFSET variable_name=expression> Arrays The following example assigns a new array to the variable "months". <CFSET months=ArrayNew(1)>...
  • Page 222 CFML Language Reference 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 223: Cfsetting

    Chapter 1: ColdFusion Tags CFSETTING CFSETTING is used to control various aspects of page processing, such as controlling the output of HTML code in your pages. One benefit of this option is managing whitespace that can occur in output pages that are served by ColdFusion. Syntax <CFSETTING ENABLECFOUTPUTONLY="Yes/No"...
  • Page 224 CFML Language Reference <CFOUTPUT> <P>Text within CFOUTPUT is always shown </CFOUTPUT> </BODY> </HTML>...
  • Page 225: Cfsilent

    Chapter 1: ColdFusion Tags CFSILENT CFSILENT suppresses all output that is produced by the CFML within the tag’s scope. See also CFSETTING. Syntax <CFSILENT> Example <HTML> <HEAD> <TITLE>CFSILENT</TITLE> </HEAD> <BASEFONT FACE="Arial, Helvetica" SIZE=2> <BODY bgcolor="#FFFFD5"> <H3>CFSILENT</H3> <!--- This example shows the use of CFSILENT ---> <CFSILENT>...
  • Page 226: Cfslider

    CFML Language Reference CFSLIDER Used inside CFFORM, CFSLIDER allows you to place a slider control in a ColdFusion form. A slider control is like a sliding volume control. The slider groove is the area over which the slider moves. Note CFSLIDER incorporates a Java applet, so a browser must be Java-enabled for CFSLIDER to work properly.
  • Page 227 Chapter 1: ColdFusion Tags IMGSTYLE Optional. Style of the image to appear in the slider groove. Valid entries are: Centered Tiled Scaled Default is Scaled. RANGE Optional. Determines the values of the left and right slider range. The slider value appears as the slider is moved.
  • Page 228 CFML Language Reference ALIGN Optional. Alignment value. Valid entries are: Left Bottom Baseline TextTop AbsBottom Middle AbsMiddle Right GROOVECOLOR Optional. Color value of the slider groove. The slider groove is the area in which the slider box moves. Valid entries are: black magenta cyan...
  • Page 229 Chapter 1: ColdFusion Tags FONTSIZE Optional. Font size for label text measured in points. ITALIC Optional. Enter Yes for italicized label text, No for normal text. Default is No. BOLD Optional. Enter Yes for bold label text, No for medium text. Default is No. NOTSUPPORTED Optional.
  • Page 230 CFML Language Reference MESSAGE="Slide the bar to get a value between 1 and 100" HEIGHT="20" WIDTH="150" FONT="Verdana" BGCOLOR="Silver" GROOVECOLOR="Lime" BOLD="No" ITALIC="Yes" REFRESHLABEL="Yes"> 100 <P><INPUT TYPE="Submit" NAME="" VALUE="Show the Result"> </CFFORM> </BODY> </HTML>...
  • Page 231: Cfstoredproc

    Chapter 1: ColdFusion Tags CFSTOREDPROC The CFSTOREDPROC tag is the main tag used for executing stored procedures via an ODBC or native connection to a server database. It specifies database connection information and identifies the stored procedure. Syntax <CFSTOREDPROC PROCEDURE="procedure name" DATASOURCE="ds_name"...
  • Page 232 CFML Language Reference 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 CFSTOREDPROC.STATUSCODE with the status code returned by the stored procedure.
  • Page 233 Chapter 1: ColdFusion Tags 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> <P>Record Count: #RS3.RecordCount# <P>Columns: #RS3.ColumnList# <hr>...
  • Page 234: Cfswitch/Cfcase/Cfdefaultcase

    CFML Language Reference CFSWITCH/CFCASE/CFDEFAULTCASE Used with CFCASE and CFDEFAULTCASE, the CFSWITCH tag evaluates a passed expression and passes control to the CFCASE tag that matches the expression result. You can optionally code a CFDEFAULTCASE tag, which receives control if there is no matching CFCASE tag value.
  • Page 235 Chapter 1: ColdFusion Tags Example <!--- This example illustrates the use of CFSWITCH and CFCASE to exercise a case statement in CFML ---> <!--- query to get some information ---> <CFQUERY NAME="GetEmployees" DATASOURCE="cfsnippets"> SELECT Emp_ID, FirstName, LastName, EMail, Phone, Department FROM Employees </CFQUERY>...
  • Page 236: Cftable

    CFML Language Reference CFTABLE Builds a table in your ColdFusion page. Use the CFCOL tag to define column and row characteristics for a table. CFTABLE renders data either as preformatted text, or, with the HTMLTABLE attribute, as an HTML table. Use CFTABLE to create tables if you don’t want to write your own HTML TABLE tag code, or if your data can be well presented as preformatted text.
  • Page 237 Chapter 1: ColdFusion Tags Usage You can use the CFCOL tag to align the data in the table , specify the width of each column, and provide column headers. Note CFCOL is the only tag that you can nest within CFTABLE. Example <!--- This example shows the use of CFCOL and CFTABLE to align information returned from a query --->...
  • Page 238: Cftextinput

    CFML Language Reference CFTEXTINPUT The CFTEXTINPUT form custom control allows you to place a single-line text entry box in a CFFORM. In addition to input validation, the tag gives you control over all font characteristics. Note CFTEXTINPUT incorporates a Java applet, so a browser must be Java- enabled for CFTEXTINPUT to work properly.
  • Page 239 Chapter 1: ColdFusion Tags time — Verifies a time entry in the form hh:mm:ss. float — Verifies a floating point entry. integer — Verifies an integer entry. telephone — Verifies a telephone entry. Telephone data must be entered as ###- ###-####.
  • Page 240 CFML Language Reference WIDTH Optional. Width value of the control, in pixels. VSPACE Optional. Vertical spacing of the control, in pixels. HSPACE Optional. Horizontal spacing of the control, in pixels. ALIGN Optional. Alignment value. Valid entries are: Left Bottom Baseline TextTop AbsBottom Middle...
  • Page 241 Chapter 1: ColdFusion Tags MAXLENGTH Optional. The maximum length of text entered. NOTSUPPORTED Optional. The text you want to display if the page containing a Java applet-based CFFORM control is opened by a browser that does not support Java or has Java support disabled.
  • Page 242: Cfthrow

    CFML Language Reference CFTHROW The CFTHROW tag raises a developer-specified exception that can be caught with CFCATCH tag having any of the following type specifications: CFCATCH TYPE= "custom_type " CFCATCH TYPE= "APPLICATION " CFCATCH TYPE= "ANY " Syntax <CFTHROW TYPE= "exception_type " MESSAGE="message"...
  • Page 243 Chapter 1: ColdFusion Tags Note In order to see the information displayed by TagContext, use the ColdFusion Administrator to enable the CFML stack trace.Under Debugging in the ColdFusion Administrator, choose the checkbox next to "Enable CFML stack trace. " Example <!--- This example shows the use of CFTHROW.
  • Page 244: Cftransaction

    CFML Language Reference CFTRANSACTION Use CFTRANSACTION to group multiple queries into a single unit. CFTRANSACTION also provides commit and rollback processing. See Usage for details. Syntax <CFTRANSACTION ACTION="BEGIN" or "COMMIT" or "ROLLBACK" ISOLATION="Read_Uncommitted" or "Read_Committed" or "Repeatable_Read" > </CFTRANSACTION> ACTION Optional.
  • Page 245 Chapter 1: 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 246 CFML Language Reference CorName, CorLevel, LastUpdate) VALUES (’#myNumber#’, ’#myDescription#’, ’#myDepartment#’, ’#myDescription#’, ’#myCorLevel#’, #Now()#) </CFQUERY> <!------------------------------------------------------------------ Rolls back the pending insertion if database exception is caught. -------------------------------------------------------------------> <CFCATCH TYPE="DATABASE"> <CFTRANSACTION ACTION="ROLLBACK"/> <CFSET commitIt = "No"> </CFCATCH> <CFIF commitIt> <CFTRANSACTION ACTION="COMMIT"/> <!-------------------------------------------------------------- Commits the pending insertion.
  • Page 247: Cftree

    Chapter 1: ColdFusion Tags CFTREE The CFTREE form custom control allows you to place a tree control in a CFFORM. User selections can be validated. Individual tree items are created with CFTREEITEM tags inside the CFTREE tag block. Note CFTREE incorporates a Java applet, so a browser must be Java-enabled for CFTREE to work properly.
  • Page 248 CFML Language Reference 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 CFFORM ACTION attribute. The default is Yes. HIGHLIGHTHREF Optional.
  • Page 249 Chapter 1: ColdFusion Tags 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. Permits vertical scrolling. Default is Yes. NOTSUPPORTED Optional.
  • Page 250 CFML Language Reference <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 ---> <H3>CFSELECT Presentation of Data</H3> <H4>Click on an employee’s last name and hit "see information for this employee"...
  • Page 251 Chapter 1: ColdFusion Tags EXPAND="No" QUERYASROOT="No"> <CFTREEITEM VALUE="#Email#" DISPLAY="Email" PARENT="#Emp_ID#" QUERYASROOT="No" EXPAND="No"> <CFTREEITEM VALUE="#Email#" PARENT="#Email#" EXPAND="No" QUERYASROOT="No"> </CFLOOP> </CFTREE>...
  • Page 252: Cftreeitem

    CFML Language Reference CFTREEITEM Use CFTREEITEM to populate a tree control created with CFTREE with individual elements. You can use the IMG values supplied with ColdFusion or reference your own icons. Note CFTREEITEM incorporates a Java applet, so a browser must be Java- enabled for CFTREE to work properly.
  • Page 253 Chapter 1: ColdFusion Tags folder floppy fixed remote Use commas to separate image names corresponding to tree level, for example: IMG="folder,document" IMG=",document To specify your own custom image, specify the path and file extension: IMG="../images/page1.gif" IMGOPEN Optional. Icon displayed with open tree item. You can specify the icon filename using a relative path.
  • Page 254 CFML Language Reference <!--- set a default for the employeeNames variable ---> <CFPARAM NAME="employeeNames" DEFAULT=""> <!--- if an employee name has been passed from the form, set employeeNames variable to this value ---Auto> <CFIF IsDefined("form.employeeNames")> <CFSET employeeNames = form.employeeNames> </CFIF> <!--- query the datasource to find the employee information--->...
  • Page 255 Chapter 1: ColdFusion Tags <CFLOOP QUERY="GetEmployees"> <CFTREEITEM VALUE="#Emp_ID#" PARENT="SeeEmployees" EXPAND="No"> <CFTREEITEM VALUE="#LastName#" DISPLAY="Name" PARENT="#Emp_ID#" QUERYASROOT="No" EXPAND="No"> <CFTREEITEM VALUE="#LastName#, #FirstName#" PARENT="#LastName#" EXPAND="No" QUERYASROOT="No"> <CFTREEITEM VALUE="#Department#" DISPLAY="Department" PARENT="#Emp_ID#" QUERYASROOT="No" EXPAND="No"> <CFTREEITEM VALUE="#Department#" PARENT="#Department#" EXPAND="No" QUERYASROOT="No"> <CFTREEITEM VALUE="#Phone#" DISPLAY="Phone" PARENT="#Emp_ID#" QUERYASROOT="No" EXPAND="No"> <CFTREEITEM VALUE="#Phone#" PARENT="#Phone#" EXPAND="No"...
  • Page 256: Cftry/Cfcatch

    CFML Language Reference CFTRY/CFCATCH Used with one or more CFCATCH tags, the CFTRY tag allows developers to catch and process exceptions in ColdFusion pages. Exceptions include any event that disrupts the normal flow of instructions in a ColdFusion page such as failed database operations, missing include files, and developer-specified events.
  • Page 257 Chapter 1: ColdFusion Tags TYPE="ANY". The custom_type type designates the name of a user-defined type specified with a CFTHROW tag. CFCATCH has a catch handler that can catch a custom type by pattern, providing the custom type is defined as a series of strings concatenated together by periods, as in .
  • Page 258 CFML Language Reference failing database operations. If no SQLState value was provided, the value of SQLSTATE is -1. ErrNumber — TYPE=Expression only. Internal expression error number. MissingFileName — TYPE=MissingInclude only. Name of the file that could not be included. LockName — TYPE=Lock only. The name of the affected lock (set to anonymous if the lock was unnamed).
  • Page 259 Chapter 1: ColdFusion Tags <CFOUTPUT> <!--- and the diagnostic message from the ColdFusion server ---> <P>#CFCATCH.message#</P> <P>Caught an exception, type = #CFCATCH.TYPE# </P> <P>The contents of the tag stack are:</P> <CFLOOP index=i from=1 to = #ArrayLen(CFCATCH.TAGCONTEXT)#> <CFSET sCurrent = #CFCATCH.TAGCONTEXT[i]#> <BR>#i# #sCurrent["ID"]# (#sCurrent["LINE"]#,#sCurrent["COLUMN"]#) #sCurrent["TEMPLATE"]# </CFLOOP>...
  • Page 260: Cfupdate

    CFML Language Reference CFUPDATE The CFUPDATE tag updates existing records in data sources. Syntax <CFUPDATE DATASOURCE="ds_name" DBTYPE="type" DBSERVER="dbms" DBNAME="database name" TABLENAME="table_name" TABLEOWNER="name" TABLEQUALIFIER="qualifier" USERNAME="username" PASSWORD="password" PROVIDER="COMProvider" PROVIDERDSN="datasource" FORMFIELDS="field_names"> DATASOURCE Required. Name of the data source that contains your table. DBTYPE Optional.
  • Page 261 Chapter 1: ColdFusion Tags TABLENAME Required. Name of the table you want to update. Note the following: ORACLE drivers — This specification must be in uppercase. Sybase driver — This specification is case-sensitive and must be in the same case as that used when the table was created TABLEOWNER Optional.
  • Page 262 CFML Language Reference ---> <CFQUERY NAME="GetCourseInfo" DATASOURCE="cfsnippets"> SELECT Number, Course_ID, Descript FROM Courses <CFIF IsDefined("url.course_ID") is True> WHERE Course_ID = #url.course_ID# </CFIF> ORDER by Number </CFQUERY> <HTML> <HEAD> <TITLE>CFUPDATE Example</TITLE> </HEAD> <BODY bgcolor=silver> <H3>CFUPDATE Example</H3> <!--- if we are updating a record, don’t show the entire list --->...
  • Page 263: Cfwddx

    Chapter 1: ColdFusion Tags CFWDDX The CFWDDX tag serializes and de-serializes CFML data structures to the XML-based WDDX format. You can also use it to generate JavaScript statements instantiating JavaScript objects equivalent to the contents of a WDDX packet or some CFML data structures.
  • Page 264 CFML Language Reference For complete information on WDDX, see the "Programming with XML " chapter in Developing Web Applications with ColdFusion. Example <!--- This snippet shows basic use of the CFWDDX tag. ---> <HTML> <HEAD> <TITLE>CFWDDX Tag</TITLE> </HEAD> <BODY> <!--- Create a simple query --->...
  • Page 265: Chapter 2: Coldfusion Functions

    H A P T E R ColdFusion Functions Chapter 2 This chapter describes each of the functions in the ColdFusion Markup Language (CFML). The introduction contains an alphabetical summary of ColdFusion functions, a list of new functions in ColdFusion 4.5, and a list of functions by category.
  • Page 266: Alphabetical List Of Coldfusion Functions

    CFML Language Reference Alphabetical List of ColdFusion Functions BitMaskRead DatePart GetBaseTagList ACos BitMaskSet GetBaseTemplatePath ArrayAppend BitNot DayOfWeek GetClientVariablesList ArrayAvg BitOr DayOfWeekAsString GetCurrentTemplatePath ArrayClear BitSHLN DayOfYear GetDirectoryFromPath ArrayDeleteAt BitSHRN DaysInMonth GetFileFromPath ArrayInsertAt BitXor DaysInYear GetFunctionList ArrayIsEmpty Ceiling GetLocale ArrayLen DecimalFormat GetMetricData ArrayMax CJustify DecrementValue...
  • Page 267 Chapter 2: ColdFusion Functions IsAuthorized ListLen Minute REReplaceNoCase IsBinary ListPrepend Month Reverse IsBoolean ListQualify MonthAsString Right IsDate ListRest RJustify IsDebugMode ListSetAt NumberFormat Round IsDefined ListSort NumberFormat RTrim IsLeapYear ListToArray ParagraphFormat Second IsNumeric ListValueCount ParameterExists SetLocale IsNumericDate ListValueCountNoCase ParseDateTime SetProfileString IsProtected LJustify SetVariable IsQuery...
  • Page 268 CFML Language Reference ToString URLEncodedFormat WriteOutput TimeFormat Trim XMLFormat ToBase64 UCase ValueList Year ToBinary URLDecode Week YesNoFormat...
  • Page 269: New Functions In Coldfusion 4.5

    Chapter 2: ColdFusion Functions New Functions in ColdFusion 4.5 CreateObject ToBase64 GetFunctionList ToBinary GetMetricData ToString IsBinary URLDecode JSStringFormat XMLFormat Array Functions ArrayAppend ArrayMax ArraySum ArrayAvg ArrayMin ArraySwap ArrayClear ArrayNew ArrayToList ArrayDeleteAt ArrayPrepend IsArray ArrayInsertAt ArrayResize ListToArray ArrayIsEmpty ArraySet ArrayLen ArraySort Authentication Functions AuthenticatedContext IsAuthenticated...
  • Page 270: Date And Time Functions

    CFML Language Reference Date and Time Functions CreateDate DatePart IsLeapYear CreateDateTime IsNumericDate CreateODBCDate DayOfWeek Minute CreateODBCDateTime DayOfWeekAsString Month CreateODBCTime DayOfYear MonthAsString CreateTime DaysInMonth CreateTimeSpan DaysInYear ParseDateTime DateCompare FirstDayOfMonth Quarter DateConvert GetTimeZoneInfo Second DateDiff Hour Week DateFormat IsDate XMLFormat Decision Functions IsArray IsNumericDate IsAuthenticated...
  • Page 271: Display And Formatting Functions

    Chapter 2: ColdFusion Functions Display and Formatting Functions DateFormat LSEuroCurrencyFormat DecimalFormat LSNumberFormat DollarFormat LSTimeFormat FormatBaseN NumberFormat HTMLCodeFormat ParagraphFormat HTMLEditFormat TimeFormat LSCurrencyFormat YesNoFormat LSDateFormat Dynamic Evaluation Functions Evaluate SetVariable International Functions DateConvert LSIsNumeric GetLocale LSNumberFormat GetTimeZoneInfo LSParseCurrency LSCurrencyFormat LSParseDateTime LSDateFormat LSParseEuroCurrency LSEuroCurrencyFormat LSParseNumber LSIsCurrency...
  • Page 272: List Functions

    CFML Language Reference List Functions ArrayToList ListLast ListAppend ListLen ListChangeDelims ListPrepend ListContains ListQualify ListContainsNoCase ListRest ListDeleteAt ListSetAt ListFind ListSort ListFindNoCase ListToArray ListFirst ListValueCount ListGetAt ListValueCountNoCase ListInsertAt Mathematical Functions BitXor ACos Ceiling ASin DecrementValue Rand BitAnd Randomize BitMaskClear RandRange BitMaskRead IncrementValue Round BitMaskSet InputBaseN...
  • Page 273: Query Functions

    Chapter 2: ColdFusion Functions Query Functions IsQuery QuerySetCell QueryAddColumn QuotedValueList QueryAddRow ValueList QueryNew String Functions LJustify Replace ListValueCount ReplaceList CJustify ListValueCountNoCase ReplaceNoCase Compare LSParseCurrency REReplace CompareNoCase LSParseDateTime REReplaceNoCase DayOfWeekAsString LSParseEuroCurrency Reverse FormatBaseN LSParseNumber Right Find LTrim RJustify FindNoCase RTrim FindOneOf MonthAsString SpanExcluding GetToken...
  • Page 274: Structure Functions

    CFML Language Reference Structure Functions IsStruct StructIsEmpty StructClear StructKeyArray StructCopy StructKeyExists StructCount StructKeyList StructDelete StructNew StructFind StructUpdate StructInsert System Functions DirectoryExists GetFileFromPath ExpandPath GetMetricData FileExists GetTempFile GetCurrentTemplatePath GetTemplatePath GetDirectoryFromPath SetProfileString Other Functions CreateObject GetClientVariablesList CreateUUID GetTickCount Decrypt PreserveSingleQuotes DeleteClientVariable QuotedValueList Encrypt StripCR GetBaseTagData...
  • Page 275: Abs

    Chapter 2: ColdFusion Functions Returns the absolute value of a number. The absolute value of a number is the number without its sign. See also Sgn. Syntax Abs( number number Any number. Examples <!--- This example shows how to use the ABS function ---> <HTML>...
  • Page 276: Acos

    CFML Language Reference ACos Returns the arccosine of a number in radians. The arccosine is the angle whose cosine is number. See also Cos, Sin, ASin, Tan, and Pi. Syntax ACos( number ) number Cosine of the angle that is to be calculated. This value must be between -1 and 1, inclusive.
  • Page 277 Chapter 2: ColdFusion Functions </CFIF> <FORM ACTION="acos.cfm" METHOD="POST"> <P>Type in a number to get its arccosine in Radians and Degrees. <BR><INPUT TYPE="Text" NAME="cosNum" size="25"> <P><INPUT TYPE="Submit" NAME=""> <INPUT TYPE="RESET"> </FORM> </BODY> </HTML>...
  • Page 278: Arrayappend

    CFML Language Reference ArrayAppend Appends an array index to the end of the specified array. Returns a Boolean TRUE on successful completion. See also ArrayPrepend. Syntax ArrayAppend( array , value ) array Name of the array to which you want to append an index. value The value you want to place into the specified array in the last index position.
  • Page 279: Arrayavg

    Chapter 2: ColdFusion Functions ArrayAvg Returns the average of the values in the specified array. Syntax ArrayAvg( array ) array Name of the array containing values you want 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 280 CFML Language Reference <tr> <CFOUTPUT> <th align="left">Number #LoopItem#</th> <td><INPUT TYPE="text" NAME="number#LoopItem#"></td> </CFOUTPUT> </tr> </CFLOOP> </table> <INPUT TYPE="submit" NAME="submit" VALUE="get the average"> </FORM> <!--- create an array ---> <CFIF IsDefined("FORM.submit")> <CFSET myNumberArray = ArrayNew(1)> <CFSET Count = 1> <CFLOOP index="ListItem" list="#Form.Fieldnames#"> <CFIF Left(ListItem,3) is "Num">...
  • Page 281: Arrayclear

    Chapter 2: ColdFusion Functions ArrayClear Deletes all data in the specified array. Returns a Boolean TRUE on successful completion. See also ArrayDeleteAt. Syntax ArrayClear( array ) array Name of the array in which you want to delete data. Example <!--- This example shows ArrayClear ---> <HTML>...
  • Page 282: Arraydeleteat

    CFML Language Reference ArrayDeleteAt Deletes data from the specified array at the specified index position. Note that when an array index is deleted, index positions in the array are recalculated. For example, in an array containing the months of the year, deleting index position [5] removes the entry for May.
  • Page 283: Arrayinsertat

    Chapter 2: ColdFusion Functions ArrayInsertAt Inserts data in the specified array at the specified index position. All 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.
  • Page 284: Arrayisempty

    CFML Language Reference ArrayIsEmpty Determines whether the specified array is empty of data. Returns a Boolean TRUE if specified array is empty, FALSE if not empty. See also ArrayLen. Syntax ArrayIsEmpty( array ) array Name of the array you want to check for data. Example <!--- This example shows ArrayIsEmpty --->...
  • Page 285: Arraylen

    Chapter 2: ColdFusion Functions ArrayLen Returns the length of the specified array. See also ArrayIsEmpty. Syntax ArrayLen( array ) array Name of the array whose length you want to return. Example <!--- This example shows ArrayLen ---> <HTML> <HEAD> <TITLE>ArrayLen Example</TITLE> </HEAD>...
  • Page 286: Arraymax

    CFML Language Reference ArrayMax Returns the largest numeric value in the specified array. Syntax ArrayMax( array ) array Name of the array from which you want to return the largest numeric value. Example <!--- This example shows the use of ArrayMax ---> <HTML>...
  • Page 287 Chapter 2: ColdFusion Functions <INPUT TYPE="text" NAME="number2"> <BR> <INPUT TYPE="submit" NAME="submit" VALUE="Maximum Value"> </FORM> </BODY> </HTML>...
  • Page 288: Arraymin

    CFML Language Reference ArrayMin Returns the smallest numeric value in the specified array. Syntax ArrayMin( array ) array Name of the array from which you want to return the smallest numeric value. Example <!--- This example shows the use of ArrayMin ---> <HTML>...
  • Page 289 Chapter 2: ColdFusion Functions <INPUT TYPE="text" NAME="number2"> <BR> <INPUT TYPE="submit" NAME="submit" VALUE="Minimum Value"> </FORM> </BODY> </HTML>...
  • Page 290: Arraynew

    CFML Language Reference ArrayNew Creates an array of between 1 and 3 dimensions. Array elements are indexed with square brackets: [ ]. Note that ColdFusion arrays expand dynamically as data is added. Syntax ArrayNew( dimension ) dimension An integer value between 1 and 3. Examples <!--- This example shows ArrayNew --->...
  • Page 291: Arrayprepend

    Chapter 2: ColdFusion Functions ArrayPrepend Adds an array element to the beginning of the specified array. Returns a Boolean TRUE on successful completion. See also ArrayAppend. Syntax ArrayPrepend( array , value ) array Name of the array to which you want to prepend data. value The value you want to add to the beginning of the specified array.
  • Page 292: Arrayresize

    CFML Language Reference ArrayResize Resets an array to a specified minimum number of elements. ArrayResize can provide some performance gains if used to size an array to its expected maximum. Use ArrayResize immediately after creating an array with ArrayNew for arrays greater than 500 elements.
  • Page 293: Arrayset

    Chapter 2: ColdFusion Functions ArraySet In a one-dimensional array, sets the elements in a specified range to the specified value. Useful in initializing an array after a call to ArrayNew. Returns a Boolean TRUE on successful completion. See also ArrayNew. Syntax ArraySet( array , start_pos , end_pos , value ) array...
  • Page 294: Arraysort

    CFML Language Reference ArraySort Returns the specified array with elements numerically or alphanumerically sorted. Syntax ArraySort( array , sort_type [, sort_order ]) array Name of the array you want to sort. sort_type The type of sort to execute. Sort type can be: —...
  • Page 295: Arraysum

    Chapter 2: ColdFusion Functions ArraySum Returns the sum of values in the specified array. Syntax ArraySum( array ) array Name of the array containing values you want to add together. Example <!--- This example shows the use of ArraySum ---> <HTML>...
  • Page 296 CFML Language Reference <INPUT TYPE="text" NAME="number2"> <BR> <INPUT TYPE="submit" NAME="submit" VALUE="Add"> </FORM> </BODY> </HTML>...
  • Page 297: Arrayswap

    Chapter 2: ColdFusion Functions ArraySwap Swaps array values for the specified array at the specified positions. ArraySwap can be used with greater efficiency than multiple CFSETs. Returns a Boolean TRUE on successful completion. Syntax ArraySwap( array , position1 , position2 ) array Name of the array whose elements you want to swap.
  • Page 298: Arraytolist

    CFML Language Reference ArrayToList Converts the specified one dimensional array to a list, delimited with the character you specify. Syntax ArrayToList( array [, delimiter ]) array Name of the array containing elements you want to use to build a list. delimiter Specify the character(s) you want to use to delimit elements in the list.
  • Page 299: Asc

    Chapter 2: ColdFusion Functions Returns the ASCII value (character code) of the first character of a string. Returns 0 if string is empty. See also Chr. Syntax Asc( string ) string Any string. Examples <!--- This code illustrates ASC ---> <HTML>...
  • Page 300: Asin

    CFML Language Reference ASin Returns the arcsine of a number in radians. The arcsine is the angle whose sine is number. See also Sin, Cos, and Tan. Syntax ASin( number ) number Sine of the angle that is to be calculated. This value must be between 1 and -1. Usage The range of the result is - /2 to /2 radians.
  • Page 301 Chapter 2: ColdFusion Functions <H4>Please enter the sine of the angle that is to be calculated in degrees and radians. This value must be between 1 and -1, inclusive.</H4> </CFIF> </CFIF> <FORM ACTION="asin.cfm" METHOD="POST"> <P>Type in a number to get its arcsine in Radians and Degrees. <BR><INPUT TYPE="Text"...
  • Page 302: Atn

    CFML Language Reference Returns the arctangent of a number. The arctangent is the angle whose tangent is number. See also Tan, Sin, Cos, and Pi. Syntax Atn( number ) number Tangent of the angle you want. Usage The range of the result is - /2 to /2 radians. To convert degrees to radians, multiply degrees by /180.
  • Page 303: Authenticatedcontext

    Chapter 2: ColdFusion Functions AuthenticatedContext Returns the name of the security context. See also IsAuthenticated, AuthenticatedUser, IsAuthorized, and CFAUTHENTICATE. Syntax AuthenticatedContext() Examples <!--- This snippet shows how to use AuthenticatedContext ---> <HTML> <HEAD> <TITLE> AuthenticatedContext Example </TITLE> </HEAD> <BODY BGCOLOR=silver> <H3>AuthenticatedContext Example</H3>...
  • Page 304: Authenticateduser

    CFML Language Reference AuthenticatedUser Returns the name of the authenticated user. See also IsAuthenticated, AuthenticatedContext, and CFAUTHENTICATE. Syntax AuthenticatedUser() Examples <!--- This snippet shows how to use AuthenticatedUser ---> <HTML> <HEAD> <TITLE> AuthenticatedUser Example </TITLE> </HEAD> <BODY BGCOLOR=silver> <H3>AuthenticatedUser Example</H3> <P>Authenticated User: <CFOUTPUT>AuthenticatedUser()</CFOUTPUT>...
  • Page 305: Bitand

    Chapter 2: ColdFusion Functions BitAnd Returns the bitwise AND of two long integers. See also BitNot, BitOr, and BitXor. Syntax BitAnd( number1 , number2 ) number1, number2 Any long integers. Usage Bit functions operate on 32-bit integers. Examples <!--- This example shows BitAnd ---> <HTML>...
  • Page 306: Bitmaskclear

    CFML Language Reference BitMaskClear Returns number bitwise cleared with length bits beginning from start. See also BitMaskRead and BitMaskSet. Syntax BitMaskClear( number , start , length ) number Long integer to be masked. start Integer specifying the starting bit for masking. length Integer specifying the length of mask.
  • Page 307: Bitmaskread

    Chapter 2: ColdFusion Functions BitMaskRead Returns the integer created from length bits of number beginning from start. See also BitMaskClear and BitMaskSet. Syntax BitMaskRead( number , start , length ) number Long integer to be masked. start Integer specifying the starting bit for reading. length Integer specifying the length of mask.
  • Page 308: Bitmaskset

    CFML Language Reference BitMaskSet Returns number bitwise masked with length bits of mask beginning from start. See also BitMaskClear and BitMaskRead. Syntax BitMaskSet( number , mask , start , length ) number Long integer to be masked. mask Long integer specifying the mask. start Integer specifying the starting bit in number for masking.
  • Page 309: Bitnot

    Chapter 2: ColdFusion Functions BitNot Returns the bitwise NOT of a long integer. See also BitAnd, BitOr, and BitXor. Syntax BitNot( number ) number Any long integer. Usage Bit functions operate on 32-bit integers. Examples <!--- This example shows BitNot ---> <HTML>...
  • Page 310: Bitor

    CFML Language Reference BitOr Returns the bitwise OR of two long integers See also BitAnd, BitNot, and BitXor. Syntax BitOr( number1 , number2 ) number1, number2 Any long integers. Usage Bit functions operate on 32-bit integers. Examples <!--- This example shows BitOr ---> <HTML>...
  • Page 311: Bitshln

    Chapter 2: ColdFusion Functions BitSHLN Returns number bitwise shifted without rotation to the left by count bits. See also BitSHRN. Syntax BitSHLN( number , count ) number Long integer to be shifted to the left. count Integer specifying number of bits the number should be shifted. Usage Parameter count must be in the range from 0 to 31.
  • Page 312: Bitshrn

    CFML Language Reference BitSHRN Returns number bitwise shifted without rotation to the right by count bits. See also BitSHLN. Syntax BitSHRN( number , count ) number Long integer to be shifted to the right. count Integer specifying number of bits the number should be shifted. Usage Parameter count must be in the range from 0 to 31.
  • Page 313: Bitxor

    Chapter 2: ColdFusion Functions BitXor Returns bitwise XOR of two long integers. See also BitAnd, BitNot, and BitOr. Syntax BitXor( number1 , number2 ) number1, number2 Any long integers. Usage Bit functions operate on 32-bit integers. Examples <!--- This example shows BitXOr ---> <HTML>...
  • Page 314: Ceiling

    CFML Language Reference Ceiling Returns the closest integer greater than a given number. See also Int, Fix, and Round. Syntax Ceiling( number ) number Any real number. Examples <!--- This example illustrates the CF function ceiling ---> <HTML> <HEAD> <TITLE>Ceiling Example</TITLE> </HEAD>...
  • Page 315: Chr

    Chapter 2: ColdFusion Functions Returns a character of a given ASCII value (character code). See also Asc. Syntax Chr( number ) number Any ASCII value (a number in the range 0 to 255 inclusive). Usage Numbers from 0 to 31 are the standard, nonprintable ASCII codes. For example, Chr(10) returns a linefeed character and Chr(13) returns a carriage return character.
  • Page 316: Cjustify

    CFML Language Reference CJustify Centers a string in the specified field length. See also LJustify and RJustify. Syntax Cjustify( string , length ) string Any string to be centered. length Length of field. Examples <!--- This example shows how to use CJustify ---> <CFPARAM NAME="jstring"...
  • Page 317: Compare

    Chapter 2: ColdFusion Functions Compare Performs a case-sensitive comparison of two strings. Returns a negative number if string1 is less than string2; 0 if string1 is equal to string2; or a positive number if string1 is greater than string2. See also CompareNoCase and Find.
  • Page 318 CFML Language Reference </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" VALUE="Compare these Strings" NAME=""> <INPUT TYPE="RESET"> </FORM> </BODY> </HTML>...
  • Page 319: Comparenocase

    Chapter 2: ColdFusion Functions CompareNoCase 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; or a positive number if string1 is greater than string2. See also Compare and FindNoCase.
  • Page 320: Cos

    CFML Language Reference Returns the cosine of a given angle in radians. See also Sin, Tan, and Pi. Syntax Cos( number ) 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 321: Createdate

    Chapter 2: ColdFusion Functions CreateDate Returns a valid date/time object. See also CreateDateTime and CreateODBCDate. Syntax CreateDate( year , month , day ) year Number representing the year in the range 100–9999. Years from 0 to 29 are interpreted as 21 century values.
  • Page 322 CFML Language Reference <LI>Built with CreateDateTime: #CreateDateTime(FORM.year, FORM.month, FORM.day, 12,13,0)# <LI>Built with CreateODBCDate: #CreateODBCDate(yourDate)# <LI>Built with CreateODBCDateTime: #CreateODBCDateTime(yourDate)# </UL> <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:...
  • Page 323: Createdatetime

    Chapter 2: ColdFusion Functions CreateDateTime Returns a valid date/time object. See also CreateDate, CreateTime, CreateODBCDateTime, and Now. Syntax CreateDateTime( year , month , day , hour , minute , second ) year Number representing the year in the range 100–9999. month Number representing the month of the year, ranging from 1 (January) to 12 (December).
  • Page 324 CFML Language Reference <LI>Built with CreateDateTime: #CreateDateTime(form.year, form.month, form.day, form.hour, form.minute,form.second)# <LI>Built with CreateODBCDate: #CreateODBCDate(yourDate)# <LI>Built with CreateODBCDateTime: #CreateODBCDateTime(yourDate)# </UL> <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")#...
  • Page 325: Createobject

    Chapter 2: ColdFusion Functions CreateObject Allows you tocreate COM, CORBA, and JAVA objects. Note ColdFusion administrators can disable the CFOBJECT tag in the ColdFusion Administrator Basic Security page, which also disables this function. Note On UNIX, COM objects are not currently supported by CreateObject. CreateObject topics CORBA JAVA...
  • Page 326: Corba

    CFML Language Reference OLEView, as well as information about COM and DCOM, can be found at Microsoft’s OLE Development web site http://www.microsoft.com/oledev/. To create COM objects, you need to know the program ID or filename of the object, the methods and properties available through the IDispatch interface, and the arguments and return types of the object’s methods.
  • Page 327: Java

    Chapter 2: ColdFusion Functions "IOR" — ColdFusion uses the Interoperable Object Reference (IOR) to access the CORBA server. "NameService" — ColdFusion uses the naming service to access server. "NameService" is only valid with the InitialContext of a VisiBroker Orb. locale Optional.
  • Page 328 CFML Language Reference valid Java type (simple, arrays, objects). ColdFusion does the appropriate conversions when strings are passed as arguments, but not when they are received as return values. Overloaded methods are supported as long as the number of arguments are different. Future enhancements will let you use cast functions that will allow method signatures to be built more accurately.
  • Page 329: Createodbcdate

    Chapter 2: ColdFusion Functions CreateODBCDate Returns a date in ODBC date format. See also CreateDate and CreateODBCDateTime. Syntax CreateODBCDate( date ) date Date/time object in the period from 100 AD to 9999 AD. Years from 0 to 29 are interpreted as 21 century values.
  • Page 330 CFML Language Reference (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="createODBCdate.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 331: Createodbcdatetime

    Chapter 2: ColdFusion Functions CreateODBCDateTime Returns a date/time object in ODBC timestamp format. See also CreateDateTime, CreateODBCDate, CreateODBCTime, and Now. Syntax CreateODBCDateTime( date ) date Date/time object in the period from 100 AD to 9999 AD. Years from 0 to 29 are interpreted as 21 century values.
  • Page 332 CFML Language Reference <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 333: Createodbctime

    Chapter 2: ColdFusion Functions CreateODBCTime Returns a time object in ODBC time format. See also CreateODBCDateTime and CreateTime. Syntax CreateODBCTime( date ) date Date/time object in the period from 100 AD to 9999 AD. Usage When passing a date/time value as a string, make sure it is enclosed in quotes. Otherwise, it is interpreted as a number representation of a date/time object, returning undesired results.
  • Page 334 CFML Language Reference 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" REQUIRED="Yes"> </PRE> <P><INPUT TYPE="Submit" NAME=""> <INPUT TYPE="RESET"> </CFFORM> </BODY> </HTML>...
  • Page 335: Createtime

    Chapter 2: ColdFusion Functions CreateTime Returns a valid time variable in ColdFusion. See also CreateODBCTime and CreateDateTime. Syntax CreateTime( hour , minute , second ) hour Number representing the hour, ranging from 0 to 23. minute Number representing the minute, ranging from 0 to 59. second Number representing the second, ranging from 0 to 59.
  • Page 336 CFML Language Reference </CFIF> </BODY> </HTML>...
  • Page 337: Createtimespan

    Chapter 2: ColdFusion Functions CreateTimeSpan Creates a date/time object for adding and subtracting other date/time objects. See also CreateDateTime, DateAdd, and DateConvert. Syntax CreateTimeSpan( days , hours , minutes , seconds ) days Number representing the number of days. hours Number representing the number of hours.
  • Page 338: Createuuid

    CFML Language Reference CreateUUID Returns a Universally Unique Identifier (UUID) formatted as ‘XXXXXXXX-XXXX-XXXX- XXXXXXXXXXXXXXX’ where ‘X’ stands for a hexadecimal digit (0-9 or A-F). Syntax CreateUUID() Usage Each UUID returned by the CreateUUID function is a 35-character-string representation of a unique 128-bit integer. Use the CreateUUID function when you need a unique string that you will use as a persistent identifier in a distributed environment.
  • Page 339: Dateadd

    Chapter 2: ColdFusion Functions DateAdd Returns a date to which a specified time interval has been added. See also DateConvert, DatePart, and CreateTimeSpan. Syntax DateAdd( datepart , number , date ) datepart One of the following strings: — Year yyyy —...
  • Page 340 CFML Language Reference <P>This example uses DateAdd to determine when a message in the database will expire. (The value selected is messages older than <CFOUTPUT>#value# <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="w">weekdays</CFCASE> <CFCASE VALUE="ww">weeks</CFCASE> <CFCASE VALUE="h">hours</CFCASE>...
  • Page 341: Datecompare

    Chapter 2: ColdFusion Functions DateCompare Performs a full date/time comparison of two dates. Returns -1 if date1 is less than date2; returns 0 if date1 is equal to date2; returns 1 if date1 is greater than date2. See the description of datePart for information on specifying the precision of the comparison. See also CreateDateTime and DatePart.
  • Page 342 CFML Language Reference <P>The datecompare function compares two date/time values. <CFIF IsDefined("FORM.date1")> <CFIF IsDate(FORM.date1) and IsDate(FORM.date2)> <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>...
  • Page 343 Chapter 2: ColdFusion Functions <BR><INPUT TYPE="Text" NAME="date2" VALUE="<CFOUTPUT>#DateFormat(Now())# #TimeFormat(Now())# </CFOUTPUT>"> <P>Specify precision to the: <BR><select NAME="precision"> <option VALUE="s"> 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"...
  • Page 344: Dateconvert

    CFML Language Reference DateConvert Converts local time to Universal Coordinated Time (UTC ) or UTC to local time based on the specified parameters. This function uses the daylight savings settings in the executing machine to compute daylight savings time, if required. See also GetTimeZoneInfo, CreateDateTime, and DatePart.
  • Page 345 Chapter 2: ColdFusion Functions <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> <CFSET yourUTC = DateConvert("local2utc", yourDate)> <P><CFOUTPUT>Your date and time value, converted into Universal Coordinated Time (UTC): #yourUTC#.</CFOUTPUT></P> <P><CFOUTPUT>Your UTC date and time, converted back to local date and time: #DateConvert("utc2local", yourUTC)#.</CFOUTPUT></P>...
  • Page 346 CFML Language Reference <td><INPUT TYPE="Text" NAME="second" VALUE="0" RANGE="0,59" MESSAGE="You must enter a value for seconds (0-59)" VALIDATE="integer" REQUIRED="Yes"></td> </tr> <tr> <td><INPUT TYPE="Submit" NAME="submit" VALUE="Submit"></td> <td><INPUT TYPE="RESET"></td> </tr> </table> </BODY> </HTML>...
  • Page 347: Datediff

    Chapter 2: ColdFusion Functions DateDiff Returns the number of intervals in whole units of type Datepart by which Date1 is less than Date2. See also DateAdd, DatePart, and CreateTimeSpan. Syntax DateDiff( datepart , date1 , date2 ) datepart One of the following strings: —...
  • Page 348 CFML Language Reference Years from 0 to 29 are interpreted as 21 century values. Years 30 to 99 are interpreted as 20 century values. Examples <!--- This example shows the use of DateDiff ---> <CFIF IsDefined("FORM.date1") and IsDefined("FORM.date2")> <CFIF IsDate(FORM.date1) and IsDate(FORM.date2)> <P>This example uses DateDiff to determine the difference <CFSWITCH EXPRESSION=#type#>...
  • Page 349: Dateformat

    Chapter 2: ColdFusion Functions DateFormat Returns a formatted date/time value. If no mask is specified, DateFormat function returns date value using the dd-mmm-yy format. See also Now, CreateDate, and ParseDateTime. Syntax DateFormat( date [, mask ]) date Date/time object in the period from 1601 AD to 9999 AD. mask Set of characters that are used to show how ColdFusion should display the date: —...
  • Page 350 CFML Language Reference Examples <!--- This example shows the various types of output possible with DateFormat ---> <HTML> <HEAD> <TITLE> DateFormat Example </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 a number of different ways: <CFOUTPUT>...
  • Page 351: Datepart

    Chapter 2: ColdFusion Functions DatePart Returns the specified part of a date as an integer. See also DateAdd and DateConvert. Syntax DatePart( datepart , date ) datepart One of the following strings: — Year yyyy — Quarter — Month — Day of year —...
  • Page 352 CFML Language Reference <P>Using datepart, we can extract an integer representing the various dateparts from that value <CFOUTPUT> <UL> <LI>year: #DatePart("yyyy", todayDate)# <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)#...
  • Page 353: Day

    Chapter 2: ColdFusion Functions Returns the ordinal for the day of the month, ranging from 1 to 31. See also DayOfWeek, DayOfWeekAsString, DayOfYear, DaysInMonth, DaysInYear, and FirstDayOfMonth. Syntax Day( date ) date Any date. Usage Years from 0 to 29 are interpreted as 21 century values.
  • Page 354: Dayofweek

    CFML Language Reference DayOfWeek Returns the ordinal for the day of the week. The day is given as an integer ranging from 1 (Sunday) to 7 (Saturday). See also Day, DayOfWeekAsString, DayOfYear, DaysInMonth, DaysInYear, and FirstDayOfMonth. Syntax DayOfWeek( date ) date Any date.
  • Page 355: Dayofweekasstring

    Chapter 2: ColdFusion Functions DayOfWeekAsString Returns the day of the week corresponding to day_of_week, an integer ranging from 1 (Sunday) to 7 (Saturday). See also Day, DayOfWeek, DayOfYear, DaysInMonth, DaysInYear, and FirstDayOfMonth. Syntax DayOfWeekAsString( day_of_week ) day_of_week Integer representing the day of the week, where 1 is Sunday, 2 is Monday, and so Usage Years from 0 to 29 are interpreted as 21 century values.
  • Page 356: Dayofyear

    CFML Language Reference DayOfYear Returns the ordinal for the day of the year. See also Day, DayOfWeek, DayOfWeekAsString, DaysInMonth, DaysInYear, and FirstDayOfMonth. Syntax DayOfYear( date ) date Any date. Usage DayofYear is aware of leap years. Years from 0 to 29 are interpreted as 21 century values.
  • Page 357: Daysinmonth

    Chapter 2: ColdFusion Functions DaysInMonth Returns the number of days in the specified month (Date). See also Day, DayOfWeek, DayOfWeekAsString, DayOfYear, DaysInYear, and FirstDayOfMonth. Syntax DaysInMonth( date ) date Any date. Usage Years from 0 to 29 are interpreted as 21 century values.
  • Page 358: Daysinyear

    CFML Language Reference DaysInYear Returns the number of days in a year. See also Day, DayOfWeek, DayOfWeekAsString, DayOfYear, DaysInMonth, DaysInYear, FirstDayOfMonth, and IsLeapYear. Syntax DaysInYear( date ) date Any date. Usage DaysInYear is aware of leap years. Years from 0 to 29 are interpreted as 21 century values.
  • Page 359 Chapter 2: ColdFusion Functions Returns its argument with double quotes wrapped around it and all double quotes inside it escaped. The DE (Delay Evaluation) function prevents the evaluation of a string as an expression when it is passed as an argument to IIf or Evaluate. See also Evaluate and IIf.
  • Page 360: Decimalformat

    CFML Language Reference DecimalFormat Returns number as a string formatted with two decimal places and thousands separator. See also DollarFormat and NumberFormat. Syntax DecimalFormat( number ) number Number being formatted. Examples <!--- This code shows the use of DecimalFormat ---> <HTML>...
  • Page 361: Decrementvalue

    Chapter 2: ColdFusion Functions DecrementValue Returns integer part of number decremented by one. See also IncrementValue. Syntax DecrementValue( number ) number Number being decremented. Examples <!--- This shows the use of DecrementValue ---> <HTML> <HEAD> <TITLE> DecrementValue Example </TITLE> </HEAD> <BODY>...
  • Page 362: Decrypt

    CFML Language Reference Decrypt Decrypts an encrypted string. See also Encrypt. Syntax Decrypt( encrypted_string , key ) encrypted_string String to be decrypted. String specifying the key used to encrypt encrypted_string. Examples <!--- This example shows the use of Encrypt and Decrypt ---> <HTML>...
  • Page 363: Deleteclientvariable

    Chapter 2: ColdFusion Functions DeleteClientVariable 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. See also GetClientVariablesList. Syntax DeleteClientVariable("...
  • Page 364: Directoryexists

    CFML Language Reference DirectoryExists Returns YES if the directory specified in the argument does exist; otherwise, it returns See also FileExists. Syntax DirectoryExists( absolute_path ) absolute_path Any absolute path. Examples <!--- This example shows the use of DirectoryExists ---> <HTML> <HEAD>...
  • Page 365: Dollarformat

    Chapter 2: ColdFusion Functions DollarFormat Returns number as a string formatted with two decimal places, thousands separator, dollar sign. Parentheses are used if number is negative. See also DecimalFormat and NumberFormat. Syntax DollarFormat( number ) number Number being formatted. Examples <!--- This example shows the use of DollarFormat --->...
  • Page 366: Encrypt

    CFML Language Reference Encrypt Encrypts a string. See also Decrypt. Syntax Encrypt( string , key ) string String to be encrypted. String specifying the key used to encrypt string. Examples <!--- This example shows the use of Encrypt and Decrypt ---> <HTML>...
  • Page 367: Evaluate

    Chapter 2: ColdFusion Functions Evaluate The function evaluates all of its arguments, left to right, and returns the result of evaluating the last argument. See also and IIf. Syntax Evaluate( string_expression1 [, string_expression2 [, … ] ] ) string_expression1, string_expression2 Valid expressions to be evaluated.
  • Page 368: Exp

    CFML Language Reference Returns e raised to the power of number. The constant e equals 2.71828182845904, the base of the natural logarithm. See also and Log10. Syntax Exp( number ) number Exponent applied to the base e. Usage To calculate powers of other bases, use ^ (the exponentiation operator). Exp is the inverse of Log, the natural logarithm of number.
  • Page 369: Expandpath

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

    CFML Language Reference FileExists Returns YES if the file specified in the argument does exist; otherwise, it returns NO. See also DirectoryExists, ExpandPath, and GetTemplatePath. Syntax FileExists( absolute_path ) absolute_path Any absolute path. Examples <!--- This example shows the use of FileExists ---> <HTML>...
  • Page 371: Find

    Chapter 2: ColdFusion Functions Find 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. See also FindNoCase, Compare, FindOneOf, REFind, and Replace. Syntax Find( substring , string [, start ]) substring...
  • Page 372: Findnocase

    CFML Language Reference FindNoCase 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. See also Find, CompareNoCase, FindOneOf, REFind, and Replace functions.
  • Page 373: Findoneof

    Chapter 2: ColdFusion Functions FindOneOf Return the first index of the occurrence of any character from set in string. Returns 0 if no characters are found. The search is case-sensitive. See also Find, Compare, and REFind functions. Syntax FindOneOf( set , string [, start ]) String containing one or more characters being sought.
  • Page 374: Firstdayofmonth

    CFML Language Reference FirstDayOfMonth Returns the ordinal (the day’s number in the year) for the first day of the specified month. See also Day, DayOfWeek, DayOfWeekAsString, DayOfYear, DaysInMonth, and DaysInYear. Syntax FirstDayOfMonth( date ) date Any date. Usage Years from 0 to 29 are interpreted as 21 century values.
  • Page 375: Fix

    Chapter 2: ColdFusion Functions 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. See also Ceiling, Int, and Round. Syntax Fix( number ) number Any number.
  • Page 376: Formatbasen

    CFML Language Reference FormatBaseN Converts a number to a string in the base specified by radix. See also InputBaseN. Syntax FormatBaseN( number , radix ) number Number to be converted. radix Base of the result. Examples <!--- This example shows FormatBaseN and InputBaseN---> <HTML>...
  • Page 377: Getbasetagdata

    Chapter 2: ColdFusion Functions GetBaseTagData Returns an object that contains data (variables, scopes, etc.) from a specified ancestor tag. By default the closest ancestor is returned. If there is no ancestor by the specified name, or if the ancestor does not expose any data (for example, CFIF), an exception will be thrown.
  • Page 378: Getbasetaglist

    CFML Language Reference GetBaseTagList Returns a comma-delimited list of uppercase ancestor tag names. The first element of the list is the parent tag. If you call this function for a top-level tag, it returns an empty string. See also GetBaseTagData. Syntax GetBaseTagList() Example...
  • Page 379: Getbasetemplatepath

    Chapter 2: ColdFusion Functions GetBaseTemplatePath Returns the fully specified path of the base template. See also GetCurrentTemplatePath, FileExists and ExpandPath. Syntax GetBaseTemplatePath() Example <!--- This example uses GetBaseTemplatePath to show the template path of the current page ---> <HTML> <HEAD> <TITLE>...
  • Page 380: Getclientvariableslist

    CFML Language Reference GetClientVariablesList Returns a comma-delimited list of non-readonly client variables available to a template. See also DeleteClientVariable. Syntax GetClientVariablesList() Example <!--- This view-only example shows GetClientVariablesList ---> <HTML> <HEAD> <TITLE>GetClientVariablesList Example</TITLE> </HEAD> <BODY> <!--- this example is view only ---> <H3>GetClientVariablesList Example</H3>...
  • Page 381: Getcurrenttemplatepath

    Chapter 2: ColdFusion Functions GetCurrentTemplatePath Returns the fully specified path of the template containing the call to this function. See also GetBaseTemplatePath, FileExists and ExpandPath. Syntax GetCurrentTemplatePath() Usage This function differs from GetBaseTemplatePath in that it will return the template path of an included template if the call is made from a template included with a CFINCLUDE tag;...
  • Page 382: Getdirectoryfrompath

    CFML Language Reference GetDirectoryFromPath Extracts the directory (with a \ (backslash)) from a fully specified path. See also ExpandPath and GetFileFromPath. Syntax GetDirectoryFromPath( path ) path Fully specified path (drive, directory, filename, and extension). Examples <!--- This example shows the use of GetDirectoryFromPath ---> <HTML>...
  • Page 383: Getfilefrompath

    Chapter 2: ColdFusion Functions GetFileFromPath Extracts the filename from a fully specified path. See also ExpandPath and GetCurrentTemplatePath. Syntax GetFileFromPath( path ) path Fully qualified path (drive, directory, filename, and extension). Examples <!--- This example shows the use of GetFileFromPath---> <HTML>...
  • Page 384: Getfunctionlist

    CFML Language Reference GetFunctionList Returns a structure of functions that are available in ColdFusion. Syntax GetFunctionList( ) Examples <!--------------------------------------------------------------- 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> </cflooP>...
  • Page 385: Getlocale

    Chapter 2: ColdFusion Functions GetLocale 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. See also SetLocale.
  • Page 386 CFML Language Reference request. Locales are determined by the native operating system. <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> </BODY>...
  • Page 387: Getmetricdata

    Chapter 2: ColdFusion Functions GetMetricData On Windows NT, GetMetricData returns all the internal data that is otherwise displayed in the Windows NT PerfMonitor. On UNIX, GetMetricData returns all of the internal data found by using CFStat. For it to work on NT you need to have turned on the PerfMonitor feature from the ColdFusion Administrator.
  • Page 388 CFML Language Reference ReqRunning: #pmData.ReqRunning# <P> ReqTimedOut: #pmData.ReqTimedOut# <P> BytesIn: #pmData.BytesIn# <P> BytesOut: #pmData.BytesOut# <P> AvgQueueTime: #pmData.AvgQueueTime# <P> AvgReqTime: #pmData.AvgReqTime# <P> AvgDBTime: #pmData.AvgDBTime# <P> CachePops: #pmData.CachePops# <P> </CFOUTPUT>...
  • Page 389: Getprofilestring

    Chapter 2: ColdFusion Functions GetProfileString 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 need to be set when the system boots, the operating system comes up, or an application starts.
  • Page 390 CFML Language Reference <!--- If you do not have an entry in an initialization file, nothing will be displayed ---> <P>Timeout is set to: <CFOUTPUT>#timeout#</CFOUTPUT>.</P> </CFIF> <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"...
  • Page 391: Gettempdirectory

    Chapter 2: ColdFusion Functions GetTempDirectory Returns the full path name of a directory, including the trailing slash. The directory that is returned depends on the account under which ColdFusion is running as well as a variety of other factors. Before using this function in an application, test to see the directory it returns under your account.
  • Page 392: Gettempfile

    CFML Language Reference GetTempFile Creates and returns the name of a temporary file in a directory whose name starts with (at most) the first three characters of prefix. See also GetTempDirectory. Syntax GetTempFile( dir , prefix ) Directory name. prefix Prefix of a temporary file to be created in the directory specified by dir.
  • Page 393: Gettemplatepath

    Chapter 2: ColdFusion Functions GetTemplatePath Returns the fully specified path of the base template. Note For backward compatibility, GetTemplatePath is still supported. However, GetBaseTemplatePath supersedes this function, and should be used in place of it in all code written after the release of ColdFusion 4.0. See also GetBaseTemplatePath, FileExists and ExpandPath.
  • Page 394: Gettickcount

    CFML Language Reference GetTickCount Returns a millisecond clock counter that can be used for timing sections of CFML code or any other aspects of page processing. Syntax GetTickCount() Usage The absolute value of the counter has no meaning. Generate useful timing values by taking differences between the results of GetTickCount() at specified points during page processing.
  • Page 395: Gettimezoneinfo

    Chapter 2: ColdFusion Functions GetTimeZoneInfo Returns a structure containing time zone information for the machine on which this function is executed. The structure contains four elements with the following keys. utcTotalOffset — total offset of the local time in minutes from UTC (Universal Coordinated Time).
  • Page 396: Gettoken

    CFML Language Reference GetToken Returns the specified token in a string. Default delimiters are spaces, tabs, and newline characters. If index is greater than the number of tokens in string, GetToken returns an empty string. See also Left, Right, Mid, SpanExcluding, and SpanIncluding. Syntax GetToken( string , index [, delimiters ]) string...
  • Page 397: Hour

    Chapter 2: ColdFusion Functions Hour Returns the ordinal value for the hour, ranging from 0 to 23. See also DatePart, Minute, and Second. Syntax Hour( date ) date Any date. Usage Years from 0 to 29 are interpreted as 21 century values.
  • Page 398: Htmlcodeformat

    CFML Language Reference HTMLCodeFormat Returns HTML escaped string enclosed in tags. All carriage returns <PRE> </PRE> are removed from string, and all special characters (> < " &) are escaped. See also HTMLEditFormat. Syntax HTMLCodeFormat( string [, version ]) string String being HTML escaped and preformatted.
  • Page 399 Chapter 2: ColdFusion Functions <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 400: Htmleditformat

    CFML Language Reference HTMLEditFormat Returns HTML escaped string. All carriage returns are removed from string, and all special characters (> < " &) are escaped. See also HTMLCodeFormat. Syntax HTMLEditFormat( string [, version ]) string String being HTML escaped. version The specific HTML version to use in replacing special characters with their entity references.
  • Page 401 Chapter 2: ColdFusion Functions <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:/ /"> <!--- 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 402: Iif

    CFML Language Reference The function evaluates its condition as a Boolean. If the result is TRUE, it returns the value of Evaluate(string_expression1); otherwise, it returns the value of Evaluate(string_expression2). Prior to using IIf, please read the Usage section and Note carefully. The IIf function is primarily intended for the conditional processing of dynamic expressions.
  • Page 403 Chapter 2: ColdFusion Functions error ’Error Resolving Parameter’ if there is an undefined variable in string_expression1. For example, “LocalVar” is undefined, however, the following logic functions as you would expect if you do not use pound signs around “LocalVal”: <CFOUTPUT> #IIf(IsDefined(“LocalVar”), “LocalVar”, DE(“The variable is not defined.”))# </CFOUTPUT>...
  • Page 404 CFML Language Reference DE("It is morning"))# </CFOUTPUT> </P> </BODY> </HTML>...
  • Page 405: Incrementvalue

    Chapter 2: ColdFusion Functions IncrementValue Returns integer part of number incremented by one. See also DecrementValue. Syntax IncrementValue( number ) number Number being incremented. Examples <!--- This shows the use of IncrementValue ---> <HTML> <HEAD> <TITLE> IncrementValue Example </TITLE> </HEAD> <BODY>...
  • Page 406: Inputbasen

    CFML Language Reference InputBaseN Returns the number obtained by converting string using the base specified by radix, an integer ranging from 2 to 36. See also FormatBaseN. Syntax InputBaseN( string , radix ) string Any string representing number in base specified by radix. radix Base of number represented by string ranging from 2 to 36.
  • Page 407: Insert

    Chapter 2: ColdFusion Functions Insert Inserts a substring in a string after a specified character position. Prepends the substring if position is equal to 0. See also RemoveChars and Len. Syntax Insert( substring , string , position ) substring String to be inserted. string String to be inserted into.
  • Page 408: Int

    CFML Language Reference Returns the closest integer smaller than a number. See also Ceiling, Fix, and Round. Syntax Int( number ) number Real number you want to round down to an integer. Examples <!--- This example shows the use of Int ---> <HTML>...
  • Page 409: Isarray

    Chapter 2: ColdFusion Functions IsArray Returns TRUE if value is an array. See also “Array Functions” on page 245. Syntax IsArray( value [, number ]) value Variable name or array name. number Tests if the array has exactly the specified dimension. Examples <!--- This example shows IsArray --->...
  • Page 410: Isauthenticated

    CFML Language Reference IsAuthenticated Returns TRUE if the user has been authenticated for any ColdFusion security context. If you specify the name of the security context, IsAuthenticated returns TRUE if the user has been authenticated for the specified ColdFusion security context. See also CFAUTHENTICATE, AuthenticatedContext, AuthenticatedUser, and IsAuthorized.
  • Page 411: Isauthorized

    Chapter 2: ColdFusion Functions IsAuthorized Returns TRUE if the user is authorized to perform the specified action on the specified ColdFusion resource. See also IsAuthenticated. Syntax IsAuthorized( resourcetype , resourcename [, action ]) resourcetype String specifying the type of resource: Application CFML File...
  • Page 412 CFML Language Reference action String specifying the action for which authorization is requested. Do not specify this parameter for COMPONENT and CUSTOMTAG. For all other resource types, this parameter is required. resourcetype specification Possible ACTIONs APPLICATION USECLIENTVARIABLES CFML Valid actions for the tag specified by resourcename FILE READ WRITE...
  • Page 413 Chapter 2: ColdFusion Functions #Customer# - #BalanceDue#<BR> </CFOUTPUT> </CFIF> </BODY> </HTML>...
  • Page 414: Isbinary

    CFML Language Reference IsBinary Returns TRUE if value is binary; otherwise, the function returns FALSE. See also ToBinary, ToBase64, IsNumeric and YesNoFormat. Syntax IsBinary( value ) value Any value. Examples <!------------------------------------------------------------------ This example shows the use of IsBinary. It assumes that another page in a syndication program has passed this page the value of the variable data_var, which can hold either character data or binary data.
  • Page 415: Isboolean

    Chapter 2: ColdFusion Functions IsBoolean Returns TRUE if value can be converted to a Boolean; otherwise, FALSE. See also IsNumeric and YesNoFormat. Syntax IsBoolean( value ) value Any number or string. Examples <!--- This example shows the use of IsBoolean ---> <HTML>...
  • Page 416: Isdate

    CFML Language Reference IsDate Returns TRUE if string can be converted to a date/time value; otherwise, FALSE. Note that ColdFusion converts the Boolean return value to its string equivalent, "Yes" and "No." See also ParseDateTime, CreateDateTime, and IsNumericDate. Syntax IsDate( string ) string Any string value.
  • Page 417: Isdebugmode

    Chapter 2: ColdFusion Functions IsDebugMode Returns TRUE if debugging mode was set via the ColdFusion Administrator and FALSE if debugging mode is disabled. Syntax IsDebugMode() Examples <!--- This example shows the use of IsDebugMode ---> <HTML> <HEAD> <TITLE> IsDebugMode Example </TITLE>...
  • Page 418: Isdefined

    CFML Language Reference IsDefined Evaluates a string value to determine if the variable named in the string value exists. IsDefined returns TRUE if the specified variable is found, FALSE if not found. IsDefined provides an alternative to the ParameterExists function, eliminating the need for cumbersome expressions used to test for the existence of a variable: Evaluate("ParameterExists(#var_name#)") See also Evaluate.
  • Page 419: Isleapyear

    Chapter 2: ColdFusion Functions IsLeapYear Returns TRUE if the year is a leap year; otherwise, FALSE. See also DaysInYear. Syntax IsLeapYear( year ) year Number representing the year. Examples <!--- This example shows the use of IsLeapYear ---> <HTML> <HEAD> <TITLE>...
  • Page 420: Isnumeric

    CFML Language Reference IsNumeric Returns TRUE if string can be converted to a number; otherwise, FALSE. See also IsBinary. Syntax IsNumeric( string ) string Any string value. Examples <!--- This example shows the use of IsNumeric ---> <HTML> <HEAD> <TITLE> IsNumeric Example </TITLE>...
  • Page 421: Isnumericdate

    Chapter 2: ColdFusion Functions IsNumericDate Evaluates "real value" of date/time object. Returns TRUE if the number represents "real value" of the date/time object; otherwise, FALSE. See also IsDate and ParseDateTime. Syntax IsNumericDate( number ) number Real number. Examples <!--- This example shows the use of IsNumericDate ---> <HTML>...
  • Page 422: Isprotected

    CFML Language Reference IsProtected Returns TRUE if the resource is protected in the security context of the authenticated user. See also IsAuthorized. Syntax IsProtected( resourcetype, resourcename [ , action ]) resourcetype String specifying the type of resource: Application CFML File DataSource Component CustomTag...
  • Page 423 Chapter 2: ColdFusion Functions action String specifying the action for which authorization is requested. Do not specify this parameter for COMPONENT and CUSTOMTAG. For all other resource types, this parameter is required. resourcetype specification Possible ACTIONs APPLICATION USECLIENTVARIABLES CFML Valid actions for the tag specified by resourcename FILE READ WRITE...
  • Page 424 CFML Language Reference <CFIF IsAuthorized("DATASOURCE", "Orders", "select")> <CFQUERY NAME="GetList" datasource="Orders"> SELECT * FROM Orders </CFQUERY> <CFOUTPUT QUERY="GetList"> Authorization Succeeded. Order information follows: #Customer# - #BalanceDue#<BR> </CFOUTPUT> </CFIF> </CFIF> </BODY> </HTML>...
  • Page 425: Isquery

    Chapter 2: ColdFusion Functions IsQuery Returns TRUE if value is a query. See also QueryAddRow. Syntax IsQuery( value ) value Query variable. Example <!--- Shows an example of IsQuery and IsSimpleValue ---> <HTML> <HEAD> <TITLE> IsQuery Example </TITLE> </HEAD> <BODY BGCOLOR=silver> <H3>IsQuery Example</H3>...
  • Page 426: Issimplevalue

    CFML Language Reference IsSimpleValue Returns TRUE if value is a string, number, Boolean, or date/time value. Syntax IsSimpleValue( value ) value Variable or expression. Example <!--- Shows an example of IsQuery and IsSimpleValue ---> <HTML> <HEAD> <TITLE> IsSimpleValue Example </TITLE> </HEAD>...
  • Page 427: Isstruct

    Chapter 2: ColdFusion Functions IsStruct Returns TRUE if variable is a structure. See also “Structure Functions” on page 250. Syntax IsStruct( variable ) variable Variable name. Examples <!--- 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 428: Jsstringformat

    CFML Language Reference JSStringFormat Returns a string that is safe to use with JavaScript. Syntax JSStringFormat( string ) string Any string. Usage JSStringFormat escapes special JavaScript characters, such as the single quote (’), double quotes ("), and newline character so that you can put arbitrary strings safely into JavaScript.
  • Page 429: Lcase

    Chapter 2: ColdFusion Functions LCase Returns string converted to lowercase. See also UCase. Syntax LCase( string ) string String being converted to lowercase. Examples <!--- This example shows the use of LCase ---> <HTML> <HEAD> <TITLE> LCase Example </TITLE> </HEAD> <BODY BGCOLOR=silver>...
  • Page 430: Left

    CFML Language Reference Left Returns the count of characters from the beginning of a string argument. See also Right, Mid, and Len. Syntax Left( string , count ) string String from which the leftmost characters are retrieved. count Positive integer indicating how many characters to return. Examples <!--- This example shows the use of Left --->...
  • Page 431: Len

    Chapter 2: ColdFusion Functions Returns the length of a string or a binary object. See also ToBinary, Left, Right, and Mid. Syntax Len( string or binary object ) string Any string or binary object. Examples <!--- This example shows the use of Len ---> <HTML>...
  • Page 432: Listappend

    CFML Language Reference ListAppend Returns list with value appended behind its last element. See also ListPrepend, ListInsertAt, and ListSetAt. Syntax ListAppend( list , value [, delimiters ]) list Any list. value Number or list being appended. delimiters Set of delimiters used in list. Usage When appending an element into a list, ColdFusion needs to insert a delimiter.
  • Page 433: Listchangedelims

    Chapter 2: ColdFusion Functions ListChangeDelims Returns list with all delimiter characters changed to new_delimiter string. See also ListFirst and ListQualify. Syntax ListChangeDelims( list , new_delimiter [, delimiters ]) list List of delimiters being changed. new_delimiter String being used as a new delimiter. delimiters Set of delimiters used in list.
  • Page 434: Listcontains

    CFML Language Reference ListContains Returns the index of the first item that contains the specified substring. The search is case-sensitive. If the substring is not found in any of the list items, it returns zero (0). See also ListContainsNoCase and ListFind. Syntax ListContains( list , substring [, delimiters ]) list...
  • Page 435 Chapter 2: ColdFusion Functions <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> <CFOUTPUT> The string "two" is in <b>Item #ListContains(aList, "two")#</b> of the list. </CFOUTPUT>...
  • Page 436: Listcontainsnocase

    CFML Language Reference ListContainsNoCase Returns the index of the first element of a list that contains the specified substring within elements. The search is case-insensitive. If no element is found, returns 0. See also ListContains and ListFindNoCase. Syntax ListContainsNoCase( list , substring [, delimiters ]) list List being searched.
  • Page 437: Listdeleteat

    Chapter 2: ColdFusion Functions ListDeleteAt Returns list with element deleted at the specified position. See also ListGetAt, ListSetAt, and ListLen. Syntax ListDeleteAt( list , position [, delimiters ]) list Any list. position Positive integer indicating the position of the element being deleted. The starting position in a list is denoted by the number 1, not 0.
  • Page 438: Listfind

    CFML Language Reference ListFind 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. See also ListContains and ListFindNoCase. Syntax ListFind( list , value [, delimiters ]) list List being searched.
  • Page 439 Chapter 2: ColdFusion Functions <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> <CFOUTPUT> The string "two" is in <b>Item #ListContains(aList, "two")#</b> of the list. </CFOUTPUT>...
  • Page 440: Listfindnocase

    CFML Language Reference ListFindNoCase 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. See also ListContains and ListFind. Syntax ListFindNoCase( list , value [, delimiters ]) list List being searched.
  • Page 441: Listfirst

    Chapter 2: ColdFusion Functions ListFirst Returns the first element of the list. See also ListGetAt, ListLast, and ListQualify. Syntax ListFirst( list [, delimiters ]) list List whose first element is being retrieved. delimiters Set of delimiters used in list. Examples <!--- This example shows ListFirst, ListLast, and ListRest --->...
  • Page 442: Listgetat

    CFML Language Reference ListGetAt Returns the element at a given position. See also ListFirst, ListLast, ListQualify, and ListSetAt. Syntax ListGetAt( list , position [, delimiters ]) list List whose element is being retrieved. position Positive integer indicating the position of the element being retrieved. delimiters Set of delimiters used in list.
  • Page 443: Listinsertat

    Chapter 2: ColdFusion Functions ListInsertAt Returns list with value inserted at the specified position. See also ListDeleteAt, ListAppend, ListPrepend, and ListSetAt. Syntax ListInsertAt( list , position , value [, delimiters ]) list Any list. position Position where the value is being inserted. The first position in a list is denoted by the number 1, not 0.
  • Page 444: Listlast

    CFML Language Reference ListLast Returns the last element of the list. See also ListGetAt and ListFirst. Syntax ListLast( list [, delimiters ]) list List whose last element is being retrieved. delimiters Set of delimiters used in list. Examples <!--- This example shows ListFirst, ListLast, and ListRest ---> <HTML>...
  • Page 445: Listlen

    Chapter 2: ColdFusion Functions ListLen Returns the number of elements in the list. See also ListAppend, ListDeleteAt, ListInsertAt, and ListPrepend. Syntax ListLen( list [, delimiters ]) list Any list. delimiters Set of delimiters used in list. Examples <!--- This example shows ListGetAt and ListLen ---> <HTML>...
  • Page 446: Listprepend

    CFML Language Reference ListPrepend Returns list with value inserted at the first position, shifting all other elements one to the right. See also ListAppend, ListInsertAt, and ListSetAt. Syntax ListPrepend( list , value [, delimiters ]) list Any list. value Number or list being prepended. delimiters Set of delimiters used in list.
  • Page 447: Listqualify

    Chapter 2: ColdFusion Functions ListQualify Returns a list with a qualifying character around each item in the list, such as double or single quotes. See the List Functions table. Syntax ListQualify( list , qualifier [, delimiters ] [, elements ]) list Any list of items or a variable that names a list.
  • Page 448 CFML Language Reference <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> <P>The contents of the unqualified list are as follows:</P> #myList# </CFOUTPUT>...
  • Page 449: Listrest

    Chapter 2: ColdFusion Functions ListRest Returns list without its first element. Returns an empty list (empty string) if list has only one element. See also ListFirst, ListGetAt, and ListLast. Syntax ListRest( list [, delimiters ]) list List whose elements are being retrieved. delimiters Set of delimiters used in list.
  • Page 450: Listsetat

    CFML Language Reference ListSetAt Returns list with value assigned to its element at specified position. See also ListDeleteAt, ListGetAt, and ListInsertAt. Syntax ListSetAt( list , position , value [, delimiters ]) list Any list. position Any position. The first position in a list is denoted by the number 1, not 0. value Any value.
  • Page 451 Chapter 2: ColdFusion Functions <CFSET TempToo = ListSetAt(temp, 2, "I changed this subject", ",")> <UL> <CFLOOP From="1" To="#ListLen(temptoo)#" INDEX="Counter"> <CFOUTPUT><LI>(#Counter#) SUBJECT: #ListGetAt(temptoo, Counter)# </CFOUTPUT> </CFLOOP> </UL> <P>Note that item 2, "<CFOUTPUT>#changedItem#</CFOUTPUT>", has been altered to "I changed this subject" using ListSetAt. </BODY>...
  • Page 452: Listsort

    CFML Language Reference ListSort Sorts and delimits the items in a list according to the specified sort type and sort order. Syntax ListSort( list, sort_type [ , sort_order ] [, delimiter ]) list List to be sorted. The items in the list must be separated by commas or otherwise delimited.
  • Page 453 Chapter 2: 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 both negative and positive numbers, as well as decimal numbers.
  • Page 454: Listtoarray

    CFML Language Reference ListToArray Converts the specified list into an array. See also ArrayToList. Syntax ListToArray( list [, delimiter ]) list Name of the list variable that contains the elements to be used to build an array. You can define a list variable with a CFSET statement. The items in the list must be separated by commas or otherwise delimited.
  • Page 455: Listvaluecount

    Chapter 2: ColdFusion Functions ListValueCount Returns the number of instances of a specified value in a list. The underlying search that finds the instances is case-sensitive. See also ListValueCountNoCase. Syntax ListValueCount( list, value [, delimiters ]) list A list or the name of a list that is to be searched. value The string or number that the function is to find and count.
  • Page 456 CFML Language Reference </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)> <CFIF numberInDepartment is 0> <H3>There are no employees in <CFOUTPUT>#FORM.departmentName#</ CFOUTPUT></H3>...
  • Page 457: Listvaluecountnocase

    Chapter 2: ColdFusion Functions ListValueCountNoCase Returns the number of instances of a specified value in a list. The underlying search that finds the instances is not case-sensitive. See also ListValueCount. Syntax ListValueCountNoCase( list, value [, delimiters ]) list A list or the name of a list that is to be searched. value The string or number that the function is to find and count.
  • Page 458 CFML Language Reference </OPTION> </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)> <CFIF numberInDepartment is 0> <H3>There are no employees in <CFOUTPUT>#FORM.departmentName#</ CFOUTPUT></H3>...
  • Page 459: Ljustify

    Chapter 2: ColdFusion Functions LJustify Returns left-justified string of the specified field length. See also CJustify and RJustify. Syntax LJustify( string , length ) string String to be left-justified. length Length of field. Example <!--- This example shows how to use LJustify ---> <CFPARAM NAME="jstring"...
  • Page 460: Log

    CFML Language Reference Returns the natural logarithm of a number. Natural logarithms are based on the constant e (2.71828182845904). See also and Log10. Syntax Log( number ) number Positive real number for which you want the natural logarithm. Examples <!--- This example shows how to use Log ---> <HTML>...
  • Page 461: Log10

    Chapter 2: ColdFusion Functions Log10 Returns the logarithm of number to base 10. See also and Log. Syntax Log10( number ) number Positive real number for which you want the logarithm. Examples <!--- This example shows how to use Log10 ---> <HTML>...
  • Page 462: Lscurrencyformat

    CFML Language Reference LSCurrencyFormat Returns a currency value using the locale convention. Default value is "local." See, also, LSEuroCurrencyFormat. Syntax LSCurrencyFormat( number [, type ]) number The currency value. type Currency type. Valid arguments are: — (For example, 10.00) none —...
  • Page 463 Chapter 2: ColdFusion Functions Locale Format Type Output (Continued) Local: $100,000.00 English (US) International: USD100,000.00 None: 100,000.00 French (Belgian) Local: 100.000,00 FB International: BEF100.000,00 None: 100.000,00 Local: 100 000,00 $ French (Canadian) International: CAD100 000,00 None: 100 000,00 French (Standard) Local: 100 000,00 F International: FRF100 000,00 None: 100 000,00...
  • Page 464 CFML Language Reference Locale Format Type Output (Continued) Local: $100,000.00 Spanish (Mexican) International: MXN100,000.00 None: 100,000.00 Spanish (Modern) Local: 10.000.000 Pts International: ESP10.000.000 None: 10.000.000 Local: 10.000.000 Pts Spanish (Standard) International: ESP10.000.000 None: 10.000.000 Swedish Local: 100.000,00 kr International: SEK100.000,00 None: 100.000,00 Example <!--- This shows LSCurrencyFormat --->...
  • Page 465: Lsdateformat

    Chapter 2: ColdFusion Functions LSDateFormat Formats the date portion of a date/time value using the locale convention. Like DateFormat LSDateFormat returns a formatted date/time value. If no mask is specified, LSDateFormat returns a date value using the locale-specific format. Syntax LSDateFormat( date [, mask ]) date Date/time object in the period from 100 AD to 9999 AD.
  • Page 466 CFML Language Reference <!--- loop through a list of possible 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> #LSDateFormat(Now(), "mmm-dd-yyyy")#<BR> #LSDateFormat(Now(), "mmmm d, yyyy")#<BR> #LSDateFormat(Now(), "mm/dd/yyyy")#<BR> #LSDateFormat(Now(), "d-mmm-yyyy")#<BR> #LSDateFormat(Now(), "ddd, mmmm dd, yyyy")#<BR> #LSDateFormat(Now(), "d/m/yy")#<BR>...
  • Page 467: Lseurocurrencyformat

    Chapter 2: ColdFusion Functions LSEuroCurrencyFormat Returns a currency value using the convention of the locale and the Euro as the currency symbol. Default value is "local." Note The locale is set with the SetLocale function. See, also, LSParseEuroCurrency, LSCurrencyFormat, and SetLocale. Syntax LSEuroCurrencyFormat( currency-number [, type ]) currency-number...
  • Page 468 CFML Language Reference Currency Output by Locale (Continued) Locale Format Type Output English (Australian) Local: 100,000.00 International: EUR100,000.00 None: 100,000.00 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...
  • Page 469 Chapter 2: ColdFusion Functions Currency Output by Locale (Continued) Locale Format Type Output Italian (Swiss) Local: 100’000.00 International: EUR100’000.00 None: 100’000.00 Norwegian (Bokmal) Local: 100 000,00 International: EUR100 000,00 None: 100 000,00 Norwegian (Nynorsk) Local: 100 000,00 International: EUR100 000,00 None: 100 000,00 Portuguese (Brazilian) Local:...
  • Page 470 CFML Language Reference <CFLOOP LIST="#Server.Coldfusion.SupportedLocales#" INDEX="locale" DELIMITERS=","> <CFSET oldlocale = SetLocale(locale)> <CFOUTPUT><P><B><I>#locale#</I></B><BR> Local: #LSEuroCurrencyFormat(100000, "local")#<BR> International: #LSEuroCurrencyFormat(100000, "international")#<BR> None: #LSEuroCurrencyFormat(100000, "none")#<BR> <Hr noshade> </CFOUTPUT> </CFLOOP> </BODY> </HTML>...
  • Page 471: Lsiscurrency

    Chapter 2: ColdFusion Functions LSIsCurrency Checks whether a string is a locale-specific currency string. Returns TRUE if string is a currency string, FALSE otherwise. Syntax LSIsCurrency( string ) string The locale-specific currency string. Example <!--- This example shows LSIsCurrency ---> <HTML>...
  • Page 472: Lsisdate

    CFML Language Reference LSIsDate Like the IsDate function, LSIsDate returns TRUE if string can be converted to a date/ time value in the current locale, FALSE otherwise. Syntax LSIsDate( string ) string Any string value. Usage Years less than 100 are interpreted as 20 century values.
  • Page 473: Lsisnumeric

    Chapter 2: ColdFusion Functions LSIsNumeric Like the IsNumeric function, LSIsNumeric returns TRUE if string can be converted to a number in the current locale; otherwise, FALSE. Syntax LSIsNumeric( string ) string Any string value. Examples <!--- This example shows LSIsNumeric ---> <HTML>...
  • Page 474: Lsnumberformat

    CFML Language Reference LSNumberFormat Formats a number using the locale convention. If mask is omitted, the number is formatted as an integer. Syntax LSNumberFormat( number [, mask ]) number The number you want to format. mask All LSNumberFormat mask characters apply except that ($) dollar, (,) comma, and (.) dot are mapped to their locale-specific counterparts.
  • Page 475 Chapter 2: ColdFusion Functions and negative numbers in your application, use either the space or use - (hyphen) to force a space in front of positive numbers and a minus sign in front of negative numbers. Usage The position of codes in format masks determines where those codes will have effect. For example, if you place a dollar sign character at the far left of a format mask, ColdFusion displays a dollar sign at the very left edge of the formatted number.
  • Page 476 CFML Language Reference Number Mask Result 3.21 C(__^)__ "( 3.21) " 3.21 C__(^)__ " (3.21) " 12345678 12345678 Examples <!--- 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 possible locales and show number values --->...
  • Page 477: Lsparsecurrency

    Chapter 2: ColdFusion Functions LSParseCurrency Converts a locale-specific currency string to a number. Attempts conversion through each of the three default currency formats (none, local, international). Returns the number matching the value of string. See, also, LSCurrencyFormat and LSParseEuroCurrency. Syntax LSParseCurrency( string ) string The locale-specific string you want to convert to a number.
  • Page 478 CFML Language Reference Currency Output by Locale (Continued) Locale Format Type Output Local: 100.000,00 FB French (Belgian) International: BEF100.000,00 None: 100.000,00 French (Canadian) Local: 100 000,00 $ International: CAD100 000,00 None: 100 000,00 Local: 100 000,00 F French (Standard) International: FRF100 000,00 None: 100 000,00 Local: SFr.
  • Page 479 Chapter 2: ColdFusion Functions Currency Output by Locale (Continued) Locale Format Type Output Local: $100,000.00 Spanish (Mexican) International: MXN100,000.00 None: 100,000.00 Spanish (Modern) Local: 10.000.000 Pts International: ESP10.000.000 None: 10.000.000 Local: 10.000.000 Pts Spanish (Standard) International: ESP10.000.000 None: 10.000.000 Local: 100.000,00 kr Swedish International: SEK100.000,00 None: 100.000,00...
  • Page 480: Lsparsedatetime

    CFML Language Reference LSParseDateTime A locale-specific version of the ParseDateTime function, except that there is no option for POP date/time object parsing. Returns a date/time object. See also ParseDateTime and SetLocale. Syntax LSParseDateTime( date-time-string ) date-time-string String being converted to date/time object. This string must be in a form that is readable in the current locale setting.
  • Page 481 Chapter 2: ColdFusion Functions <P>LSParseDateTime returns a locale-specific date/time object. <!--- loop through a list of possible 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> <P>Locale-specific formats: <BR>#LSDateFormat(Now(), "mmm-dd-yyyy")# #LSTimeFormat(Now())#<BR> #LSDateFormat(Now(), "mmmm d, yyyy")# #LSTimeFormat(Now())#<BR> #LSDateFormat(Now(), "mm/dd/yyyy")# #LSTimeFormat(Now())#<BR>...
  • Page 482: Lsparseeurocurrency

    CFML Language Reference LSParseEuroCurrency Converts a locale-specific currency string that contains the Euro symbol ( ) or sign (EUR) to a number. Attempts conversion through each of the three default currency formats (none, local, international). Returns the number matching the value of string. See, also, LSParseCurrency, LSEuroCurrencyFormat and SetLocale.
  • Page 483 Chapter 2: ColdFusion Functions </CFOUTPUT> </CFLOOP> </BODY> </HTML>...
  • Page 484: Lsparsenumber

    CFML Language Reference LSParseNumber Converts a locale-specific string to a number. Returns the number matching the value of string. Syntax LSParseNumber( string ) string String being converted to a number. Examples <!--- This shows LSParseNumber ---> <HTML> <HEAD> <TITLE>LSParseNumber Example</TITLE> </HEAD>...
  • Page 485: Lstimeformat

    Chapter 2: ColdFusion Functions LSTimeFormat Returns a custom-formatted time value using the locale convention. See also LSParseDateTime. Syntax LSTimeFormat( time [, mask ]) string Any date/time value or string convertible to a time value. mask A set of masking characters determining the format: —...
  • Page 486 CFML Language Reference INDEX="locale" DELIMITERS=","> <CFSET oldlocale = SetLocale(locale)> <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 487: Ltrim

    Chapter 2: ColdFusion Functions LTrim Returns string with leading spaces removed. See also RTrim and ToBase64. Syntax LTrim( string ) string String being left-trimmed. Examples <!--- This example shows the use of LTrim ---> <HTML> <HEAD> <TITLE> LTrim Example </TITLE> </HEAD>...
  • Page 488: Max

    CFML Language Reference Returns the maximum, or higher, value of two numbers. See also Min. Syntax Max( number1 , number2 ) number1, number2 Any numbers. Examples <!--- This example shows the Max and Min of two numbers ---> <HTML> <HEAD> <TITLE>...
  • Page 489: Mid

    Chapter 2: ColdFusion Functions Returns count characters from string beginning at start position. See also Left, Len, and Right. Syntax Mid( string , start , count ) string Any string. start Starting position for count. count Number of characters being returned. Examples <!--- This example shows the use of Mid --->...
  • Page 490: Min

    CFML Language Reference Returns the minimum, or smaller, value of two numbers. See also Max. Syntax Min( number1 , number2 ) number1, number2 Any numbers. Examples <!--- This example shows the Max and Min of two numbers ---> <HTML> <HEAD> <TITLE>...
  • Page 491: Minute

    Chapter 2: ColdFusion Functions Minute Returns the ordinal for the minute, ranging from 0 to 59. See also DatePart, Hour, and Second. Syntax Minute( date ) date Any date. Usage Years from 0 to 29 are interpreted as 21 century values. Years 30 to 99 are interpreted as 20 century values.
  • Page 492: Month

    CFML Language Reference Month Returns the ordinal for the month, ranging from 1 (January) to 12 (December). See also DatePart, MonthAsString, and Quarter. Syntax Month( Date ) date Any date. Usage Years from 0 to 29 are interpreted as 21 century values.
  • Page 493: Monthasstring

    Chapter 2: ColdFusion Functions MonthAsString Returns the name of the month corresponding to month_number. See also DatePart, Month, and Quarter. Syntax MonthAsString( month_number ) month_number An integer ranging from 1 to 12. Examples <!--- shows the value of the MonthAsString function ---> <HTML>...
  • Page 494: Now

    CFML Language Reference Returns the current date and time as a valid date time object. See also CreateDateTime and DatePart. Syntax Now() Examples <!--- This example shows Now() ---> <HTML> <HEAD> <TITLE>Now Example</TITLE> </HEAD> <BODY> <H3>Now Example</H3> <P>Now returns the current date and time as a valid date/time object.
  • Page 495: Numberformat

    Chapter 2: ColdFusion Functions NumberFormat Creates a custom-formatted number value. If no mask is specified, returns the value as an integer with a thousands separator. See also DecimalFormat, DollarFormat, and IsNumeric. Syntax NumberFormat( number [, mask ]) number The number you want to format. mask Set of characters that are used to show how ColdFusion should display the number.
  • Page 496 CFML Language Reference Note If you do not specify a sign for the mask, positive and negative numbers will not align in columns. As a result, if you expect to display both positive and negative numbers in your application, use either the space or use - (minus sign) to force a space in front of positive numbers and a minus sign in front of negative numbers.
  • Page 497 Chapter 2: ColdFusion Functions of fields they are located in. The following example shows how to use the field to determine exactly where to place parentheses to display negative numbers: Number Mask Result 3.21 C(__^__) "( 3.21 )" 3.21 C__(^__) "...
  • Page 498: Paragraphformat

    CFML Language Reference ParagraphFormat Returns string with converted single newline characters (CR/LF sequences) into spaces and double newline characters into HTML paragraph markers (<P>). See also StripCR. Syntax ParagraphFormat( string ) string String being converted to the HTML paragraph format. Usage ParagraphFormat is useful for displaying data entered into TEXTAREA fields.
  • Page 499: Parameterexists

    Chapter 2: ColdFusion Functions ParameterExists 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 500: Parsedatetime

    CFML Language Reference ParseDateTime Returns a date/time object from a string. See also LSParseDateTime, IsDate and IsNumericDate. Syntax ParseDateTime( date-time-string [, pop-conversion ] ) date-time-string String being converted to date/time object. pop-conversion POP or STANDARD. If you specify POP, the function takes the date/time string passed from a POP mail server and converts it to GMT (Greenwich Mean Time) for the English (US) locale.
  • Page 501 Chapter 2: ColdFusion Functions <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 502 CFML Language Reference Returns the number 3.14159265358979, the mathematical constant , accurate to 15 digits. See also ASin, Cos, Sin, and Tan. Syntax Pi() Examples <!--- This shows the use of Pi ---> <HTML> <HEAD> <TITLE> Pi Example </TITLE> </HEAD> <BODY>...
  • Page 503: Preservesinglequotes

    Chapter 2: ColdFusion Functions PreserveSingleQuotes Prevents ColdFusion from automatically “escaping” single quotes contained in variable. Syntax PreserveSingleQuotes( variable ) variable Variable containing the string for which single quotes are preserved. Usage PreserveSingleQuotes is useful in SQL statements. Example <!--- This example shows the use of PreserveSingleQuotes ---> <HTML>...
  • Page 504: Quarter

    CFML Language Reference Quarter Returns the number of the quarter, an integer ranging from 1 to 4. See also DatePart and Month. Syntax Quarter( date ) date Any date. Usage Years from 0 to 29 are interpreted as 21 century values. Years 30 to 99 are interpreted as 20 century values.
  • Page 505: Queryaddcolumn

    Chapter 2: ColdFusion Functions QueryAddColumn Adds a new column to a specified query and populates the column’s rows with the contents of a one-dimensional array. Returns the query object with the additional column. Padding is added, if necessary, on the query columns to ensure that all columns have the same number of rows.
  • Page 506 CFML Language Reference <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 507: Queryaddrow

    Chapter 2: ColdFusion Functions QueryAddRow Adds a specified number of empty rows to the specified query. Returns the total number of rows in the query that you are adding rows to. See also QueryNew, QueryAddColumn and QuerySetCell. Syntax QueryAddRow( query [, number ]) query Name of the query already executed.
  • Page 508: Querynew

    CFML Language Reference QueryNew Returns an empty query with a set of columns or an empty query with no columns. See Usage for more information. See also QueryAddColumn, QueryAddRow and QuerySetCell. Syntax QueryNew( columnlist ) columnlist Comma-separated list of columns you want to add to the new query or an empty string.
  • Page 509: Querysetcell

    Chapter 2: ColdFusion Functions QuerySetCell Sets the cell in a specified column to a specified value. If no row number is specified, the cell on the last row will be set. Returns TRUE. See also QueryAddColumn and QueryAddRow. Syntax QuerySetCell( query , column_name , value [, row_number ]) query Name of the query already executed.
  • Page 510 CFML Language Reference "Description of variable #Countvar#")> </CFLOOP> <P>After the QueryAddRow action, the query has <CFOUTPUT>#GetCourses.RecordCount#</CFOUTPUT> records. <CFOUTPUT query="GetCourses"> <PRE>#Course_ID##Number##Descript#</PRE> </CFOUTPUT> </BODY> </HTML>...
  • Page 511: Quotedvaluelist

    Chapter 2: ColdFusion Functions QuotedValueList 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. See also ValueList. Syntax QuotedValueList( query.column [, delimiter ]) query.column Name of an already executed query and column.
  • Page 512: Rand

    CFML Language Reference Rand Returns a random decimal number in the range 0 to 1. See also Randomize and RandRange. Syntax Rand() Usage To ensure even greater randomness, call Randomize before calling Rand. Example <!--- This example shows the use of Rand() ---> <HTML>...
  • Page 513: Randomize

    Chapter 2: ColdFusion Functions Randomize Seeds the random number generator in ColdFusion with the integer part of a number. By seeding the random number generator with a variable value, you help to ensure that the Rand function generates highly random numbers. See also Rand and RandRange.
  • Page 514: Randrange

    CFML Language Reference RandRange Returns a random integer between two specified numbers. Note that requests for random integers greater than 100,000,000 will result in non-random behavior. This restriction prevents overflow during internal computations. See also Rand and Randomize. Syntax RandRange( number1 , number2 ) number1, number2 Integer numbers less than 100,000,000.
  • Page 515: Refind

    Chapter 2: ColdFusion Functions REFind Returns the position of the first occurrence of a regular expression in a string starting from the specified position. Returns 0 if no occurrences are found. This 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 516 CFML Language Reference length of the first instance of each subexpression within the regular expression are returned in subsequent elements of the arrays. Examples <!--- This example shows the use of REFind ---> <HTML> <HEAD> <TITLE> REFind Example </TITLE> </HEAD> <BODY>...
  • Page 517 Chapter 2: ColdFusion Functions <P>In order to create this structure you can use a CFSET statement, for example: </P> &lt;CFSET st = REFind("[[:alpha:]]",testString,1,"TRUE")&gt; <CFSET st = REFind("[[: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 in the regular expression.</b></P>...
  • Page 518: Refindnocase

    CFML Language Reference REFindNoCase Returns the position of the first occurrence of a regular expression in a string starting from the 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 519 Chapter 2: ColdFusion Functions length of the first instance of each subexpression within the regular expression are returned in subsequent elements of the arrays. Examples <!--- This example shows the use of REFindNoCase ---> <HTML> <HEAD> <TITLE> REFindNoCase Example </TITLE> </HEAD>...
  • Page 520 CFML Language Reference <P>In order 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 521: Removechars

    Chapter 2: ColdFusion Functions RemoveChars Returns string with count characters removed from the specified starting position. Return 0 if no characters are found. See also Insert and Len. Syntax RemoveChars( string , start , count ) string Any string. start Starting position for the search.
  • Page 522: Repeatstring

    CFML Language Reference RepeatString Returns a string created from string being repeated a specified number of times. See also CJustify, LJustify, and RJustify. Syntax RepeatString( string , count ) string String being repeated. count Number of repeats. Examples <!--- This example shows RepeatString ---> <HTML>...
  • Page 523: Replace

    Chapter 2: ColdFusion Functions Replace Returns string with occurrences of substring1 being replaced with substring2 in the specified scope. See also Find, ReplaceNoCase, ReplaceList, and REReplace. Syntax Replace( string , substring1 , substring2 [, scope ]) string Any string. substring1 String to be replaced.
  • Page 524: Replacelist

    CFML Language Reference ReplaceList Returns string with all occurrences of the elements from the specified comma- delimited list being replaced with their corresponding elements from another comma- delimited list. The search is case-sensitive. See also Find, Replace, and REReplace. Syntax ReplaceList( string , list1 , list2 ) string Any string.
  • Page 525 Chapter 2: ColdFusion Functions <P>String 1 <BR><INPUT TYPE="Text" VALUE="My Test String" NAME="MyString"> <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"> <P><INPUT TYPE="Submit" VALUE="Replace and display" NAME=""> </FORM>...
  • Page 526: Replacenocase

    CFML Language Reference ReplaceNoCase Returns string with occurrences of substring1 being replaced regardless of case matching with substring2 in the specified scope. See also Find, Replace, ReplaceList, and REReplace. Syntax ReplaceNoCase( string , substring1 , substring2 [, scope ]) string Any string.
  • Page 527: Rereplace

    Chapter 2: ColdFusion Functions REReplace Returns string with a regular expression being replaced with substring in the specified scope. This is a case-sensitive search. See also REFind, Replace, ReplaceList, and REReplaceNoCase. Syntax REReplace( string , reg_expression , substring [, scope ]) string Any string.
  • Page 528: Rereplacenocase

    CFML Language Reference REReplaceNoCase Returns string with a regular expression being replaced with substring in the specified scope. The search is case-insensitive. See also REFind, REFindNoCase, Replace, and ReplaceList. Syntax REReplaceNoCase( string , reg_expression , substring [, scope ]) string Any string.
  • Page 529: Reverse

    Chapter 2: ColdFusion Functions Reverse Returns string with reversed order of characters. See also Left, Mid, and Right. Syntax Reverse( string ) string String being reversed. Examples <!--- This example shows the use of Reverse ---> <HTML> <HEAD> <TITLE> Reverse Example </TITLE>...
  • Page 530: Right

    CFML Language Reference Right Returns the rightmost count characters of a string. See also Left, Len, and Mid. Syntax Right( string , count ) string String from which the rightmost characters are retrieved. count Integer indicating how many characters to return. Examples <!--- This example shows the use of Right --->...
  • Page 531: Rjustify

    Chapter 2: ColdFusion Functions RJustify Returns right-justified string in the specified field length. See also CJustify and LJustify. Syntax RJustify( string , length ) string String to be right-justified. length Length of field. Example <!--- This example shows how to use RJustify ---> <CFPARAM NAME="jstring"...
  • Page 532: Round

    CFML Language Reference Round Rounds a number to the closest integer. See also Ceiling, Fix, and Int. Syntax Round( number ) number Number being rounded. Examples <!--- This example shows the use of Round ---> <HTML> <HEAD> <TITLE> Round Example </TITLE>...
  • Page 533: Rtrim

    Chapter 2: ColdFusion Functions RTrim Returns string with removed trailing spaces. See also LTrim and Trim. Syntax RTrim( string ) string String being right-trimmed. Examples <!--- This example shows the use of RTrim ---> <HTML> <HEAD> <TITLE> RTrim Example </TITLE> </HEAD>...
  • Page 534: Second

    CFML Language Reference Second For a date/time value, returns the ordinal for the second, an integer from 0 to 59. See also DatePart, Hour, and Minute. Syntax Second( date ) date Any date. Usage When passing a date/time value as a string, make sure it is enclosed in quotes. Otherwise, it is interpreted as a number representation of a date/time object, returning undesired results.
  • Page 535: Setlocale

    Chapter 2: ColdFusion Functions SetLocale Sets the locale to the specified new locale for the current session. Note SetLocale returns the old locale in case it needs to be restored. See also GetLocale. Syntax SetLocale( new_locale) new_locale The name of the locale you want to set. Locale support ColdFusion can be expected to support the following locales in a default Windows NT installation::...
  • Page 536 CFML Language Reference <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 537: Setprofilestring

    Chapter 2: ColdFusion Functions SetProfileString Sets the value of a profile entry in an initialization file. This function returns an empty string if the operation succeeds or an error message if the operation fails. See also GetProfileString. Syntax SetProfileString( iniPath, section, entry, value ) iniPath Fully qualified path (drive, directory, filename, and extension) of the initialization file.
  • Page 538 CFML Language Reference <CFIF MyTimeout Greater Than 0> <hr size="2" color="#0000A0"> <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 539: Setvariable

    Chapter 2: ColdFusion Functions SetVariable The function sets the variable specified by name to value and returns the new value of the variable. See also DeleteClientVariable and GetClientVariablesList. Syntax SetVariable( name , value ) name Valid variable name. value String or number assigned to the variable. Usage When setting client variables, it is required that the client variable exists prior to the using of this function and the ClientManagement attribute of CFAPPLICATION tag has...
  • Page 540: Sgn

    CFML Language Reference Determines the sign of a number. Returns 1 if number is positive; 0 if number is 0; and -1 if number is negative. See also Abs. Syntax Sgn( number ) number Any number. Examples <!--- This example shows the use of Sgn ---> <HTML>...
  • Page 541: Sin

    Chapter 2: ColdFusion Functions Returns the sine of the given angle. See also ASin, Atn, Cos, and Tan. Syntax Sin( number ) 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 542: Spanexcluding

    CFML Language Reference SpanExcluding Returns all characters from string from its beginning until it reaches a character from the set of characters. The search is case-sensitive. See also GetToken and SpanIncluding. Syntax SpanExcluding( string , set ) string Any string. String containing one or more characters being sought.
  • Page 543: Spanincluding

    Chapter 2: ColdFusion Functions SpanIncluding Returns all characters from string from its beginning until it reaches a character that is not included in the specified set of characters. The search is case-sensitive. See also GetToken and SpanExcluding. Syntax SpanIncluding( string , set ) string Any string.
  • Page 544: Sqr

    CFML Language Reference Returns a positive square root. See also Abs. Syntax Sqr( number ) number Number for which you want the square root. Usage Number must be greater than or equal to 0. Examples <!--- This example shows Sqr ---> <HTML>...
  • Page 545: Stripcr

    Chapter 2: ColdFusion Functions StripCR Returns string with all carriage return characters removed. See also ParagraphFormat. Syntax StripCR( string ) string String being formatted. Usage Function StripCR is useful for preformatted HTML display of data (PRE) entered into TEXTAREA fields. Example <!--- This example shows StripCR --->...
  • Page 546: Structclear

    CFML Language Reference StructClear Removes all data from the specified structure. Always returns Yes. See also StructDelete, StructFind, StructInsert, StructIsEmpty, StructKeyArray, StructCount, StructKeyArray, and StructUpdate. Syntax StructClear( structure ) structure Structure to be cleared. Example <!--- This example shows how to use the StructClear function.
  • Page 547: Structcopy

    Chapter 2: ColdFusion Functions StructCopy Returns a new structure with all the keys and values of the specified structure. See also StructClear, StructDelete, StructFind, StructInsert, StructIsEmpty, StructKeyArray, StructKeyArray, and StructUpdate. Syntax StructCopy( structure ) structure Structure to be copied. Usage This function throws an exception if structure does not exist.
  • Page 548: Structcount

    CFML Language Reference StructCount Returns the number of keys in the specified structure. See also StructClear, StructDelete, StructFind, StructInsert, StructIsEmpty, StructKeyArray, StructKeyArray, and StructUpdate. Syntax StructCount( structure ) structure Structure to be accessed. Usage This function throws an exception if structure does not exist. Example <!--- This view-only example illustrates usage of StructCount.
  • Page 549: Structdelete

    Chapter 2: ColdFusion Functions StructDelete Removes the specified item from the specified structure. See also StructClear, StructFind, StructInsert, StructIsEmpty, StructKeyArray, StructCount, StructKeyArray, and StructUpdate. Syntax StructDelete( structure , key [, indicatenotexisting ]) structure Structure containing the item to be removed. Item to be removed.
  • Page 550 CFML Language Reference </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; <select NAME="field">...
  • Page 551: Structfind

    Chapter 2: ColdFusion Functions StructFind Returns the value associated with the specified key in the specified structure. See also StructClear, StructDelete, StructInsert, StructIsEmpty, StructKeyArray, StructCount, StructKeyArray, and StructUpdate. Syntax StructFind( structure , key ) structure Structure containing the value to be returned. Key whose value is returned.
  • Page 552: Structinsert

    CFML Language Reference StructInsert Inserts the specified key-value pair into the specified structure. Returns Yes if the insert was successful and No if an error occurs. See also StructClear, StructDelete, StructFind, StructIsEmpty, StructKeyArray, StructCount, StructKeyArray, and StructUpdate. Syntax StructInsert( structure , key , value [, allowoverwrite ] ) structure Structure to contain the new key-value pair.
  • Page 553 Chapter 2: ColdFusion Functions StructInsert(employee, "lastname", FORM.lastname); StructInsert(employee, "email", FORM.email); StructInsert(employee, "phone", FORM.phone); 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 --->...
  • Page 554: Structisempty

    CFML Language Reference StructIsEmpty Indicates whether the specified structure contains data. Returns TRUE if structure is empty and FALSE if it contains data. See also StructClear, StructDelete, StructFind, StructInsert, StructKeyArray, StructCount, StructKeyArray, and StructUpdate. Syntax StructIsEmpty( structure ) structure Structure to be tested. Usage This function throws an exception if structure does not exist.
  • Page 555: Structkeyarray

    Chapter 2: ColdFusion Functions StructKeyArray Returns an array of the keys in the specified ColdFusion structure. See also StructClear, StructDelete, StructFind, StructInsert, StructIsEmpty, StructKeyList, StructKeyExists, StructCount, and StructUpdate. Syntax StructKeyArray( structure ) structure Structure from which the list of keys is to be extracted. Usage The array of keys returned by StructKeyArray is not in any particular order.
  • Page 556 CFML Language Reference </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. After you have entered employee information into the structure, the example uses the <b>StructKeyArray</b>...
  • Page 557 Chapter 2: ColdFusion Functions <P><CFOUTPUT>Value#i# is #employee[keysToStruct[i]]#</CFOUTPUT> </P> </CFLOOP> </CFIF> </BODY> </HTML>...
  • Page 558: Structkeyexists

    CFML Language Reference StructKeyExists Returns TRUE if the specified key is in the specified structure and FALSE if it is not. See also StructClear, StructDelete, StructFind, StructInsert, StructIsEmpty, StructCount, StructKeyArray, and StructUpdate. Syntax StructKeyExists( structure , key ) structure Structure to be tested. Key to be tested.
  • Page 559: Structkeylist

    Chapter 2: ColdFusion Functions StructKeyList Returns the list of keys that are in the specified ColdFusion structure. See also StructKeyArray, StructClear, StructDelete, StructFind, StructInsert, StructIsEmpty, StructCount, and StructUpdate. Syntax StructKeyList( structure , [ delimiter ]) structure Structure from which the list of keys are to be extracted. delimiter Optional.
  • Page 560 CFML Language Reference <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" and its fields are filled with the contents of the following form.
  • Page 561 Chapter 2: ColdFusion Functions </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. If they are not correct, you should consider rewriting your application.
  • Page 562: Structnew

    CFML Language Reference StructNew Returns a new structure. See also StructClear, StructDelete, StructFind, StructInsert, StructIsEmpty, StructKeyArray, StructCount, and StructUpdate. Syntax StructNew() Example <!---------------------------------------------------------------------- This example shows how to use the StructNew function. It calls the CF_ADDEMPLOYEE custom tag, which uses the addemployee.cfm file to add the employee record to a database.
  • Page 563: Structupdate

    Chapter 2: ColdFusion Functions StructUpdate Updates the specified key with the specified value. Returns Yes if the function is successful and throws an exception if an error occurs. See also StructClear, StructDelete, StructFind, StructInsert, StructIsEmpty, StructKeyArray, StructCount, and StructKeyArray. Syntax StructUpdate( structure , key , value ) structure Structure to be updated.
  • Page 564: Tan

    CFML Language Reference Returns the tangent of a given angle. See also Atn, ASin, Cos, Sin, and Pi. Syntax Tan( number ) 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. Examples <!--- This example shows Tan --->...
  • Page 565: Timeformat

    Chapter 2: ColdFusion Functions TimeFormat Returns a custom-formatted time value. If no mask is specified, the TimeFormat function returns time value using the hh:mm tt format. See also CreateTime, Now, and ParseDateTime. Syntax TimeFormat( time [, mask ]) time Any date/time value or string convertible to a time value. mask A set of masking characters determining the format: —...
  • Page 566 CFML Language Reference <P>Using Timeformat, we can display that date/time value in a number of different ways: <CFOUTPUT> <UL> <LI>#TimeFormat(todayDate)# <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 567: Tobase64

    Chapter 2: ColdFusion Functions ToBase64 Returns the Base 64 representation of the string or binary object. Base64 is a format that uses printable characters, allowing binary data to be sent in forms and Email, and stored in a database or file. See also CFFILE for information about loading and reading binary data,...
  • Page 568 CFML Language Reference <CFOUTPUT>#charData#</CFOUTPUT> </P> <!---------------------------------------------------------------------- Create a Base 64 representation of this string. -----------------------------------------------------------------------> <CFSET data64=toBase64(charData)> <!---------------------------------------------------------------------- Convert string to binary. -----------------------------------------------------------------------> <CFSET binaryData=toBinary(data64)> <!---------------------------------------------------------------------- Convert binary back to Base 64. -----------------------------------------------------------------------> <CFSET another64=toBase64(binaryData)> <!---------------------------------------------------------------------- Compare another64 with data64 to ensure that they are equal. ----------------------------------------------------------------------->...
  • Page 569: Tobinary

    Chapter 2: ColdFusion Functions ToBinary Returns the binary representation of Base64 encoded data. CFFILE for information about loading and reading binary data, CFWDDX information about serializing and deserializing binary data, and IsBinary ToBase64 for checking for binary data and converting it into printable form. See also for determining the length of a binary object.
  • Page 570 CFML Language Reference <!---------------------------------------------------------------------- Create a Base 64 representation of this string. -----------------------------------------------------------------------> <CFSET data64=toBase64(charData)> <!---------------------------------------------------------------------- Convert string to binary. -----------------------------------------------------------------------> <CFSET binaryData=toBinary(data64)> <!---------------------------------------------------------------------- Convert binary back to Base 64. -----------------------------------------------------------------------> <CFSET another64=toBase64(binaryData)> <!---------------------------------------------------------------------- Compare another64 with data64 to ensure that they are equal. ----------------------------------------------------------------------->...
  • Page 571: Tostring

    Chapter 2: ColdFusion Functions ToString Attempts to convert a value of any type, including a binary value, into a string. Syntax ToString( any_value ) any_value The value that is to be converted into a string. Usage If ToString cannot convert the value into a string, it throws an exception. All simple values can be converted into a string, even binary values that do not contain byte zero can be converted.
  • Page 572 CFML Language Reference <!---------------------------------------------------------------------- Create a binary representation of Base 64 data. -----------------------------------------------------------------------> <CFSET dataBinary=toBinary(data64)> <!---------------------------------------------------------------------- Create the string repesentation of the binary data. -----------------------------------------------------------------------> <CFSET dataString=toString(dataBinary)> <P> The following is the string representation of the binary data.<BR> <CFOUTPUT>#dataString#</CFOUTPUT> </P> </BODY>...
  • Page 573: Trim

    Chapter 2: ColdFusion Functions Trim Returns string with both leading and trailing spaces removed. See also LTrim and RTrim. Syntax Trim( string ) string String being trimmed. Examples <!--- This example shows the use of Trim ---> <HTML> <HEAD> <TITLE> Trim Example </TITLE>...
  • Page 574: Ucase

    CFML Language Reference UCase Returns string converted to uppercase. See also LCase. Syntax UCase( string ) string String being converted to uppercase. Examples <!--- This example shows the use of UCase ---> <HTML> <HEAD> <TITLE> UCase Example </TITLE> </HEAD> <BODY BGCOLOR=silver> <H3>UCase Example</H3>...
  • Page 575: Urldecode

    Chapter 2: ColdFusion Functions URLDecode Decodes a URL-encoded string. See also URLEncodedFormat. 85/'HFRGH XUO(QFRGHG6WULQJ Syntax urlEncodedString A string that has been URL-encoded. Usage URL encoding refers to a data format where all high ASCII and non-alphanumeric characters are encoded using a percent sign followed by the two character hexadecimal representation of the character code.
  • Page 576: Urlencodedformat

    CFML Language Reference URLEncodedFormat Returns a URL-encoded string. Spaces are replaced with + and all non-alphanumeric characters with equivalent hexadecimal escape sequences. This function enables you to pass arbitrary strings within a URL, because ColdFusion automatically decodes all URL parameters that are passed to the template. See also URLDecode.
  • Page 577: Val

    Chapter 2: ColdFusion Functions Returns a number that the beginning of a string can be converted to. Returns 0 if conversion is not possible. See also IsNumeric. Syntax Val( string ) string Any string. Examples <!--- This example shows Val ---> <HTML>...
  • Page 578: Valuelist

    CFML Language Reference ValueList Returns a comma-separated list of the values of each record returned from a previously executed query. See also QuotedValueList. Syntax ValueList( query.column [, delimiter ]) query.column Name of an already executed query and column. Separate query name and column name with a period ( .
  • Page 579: Week

    Chapter 2: ColdFusion Functions Week Returns the ordinal for the week number in a year; an integer ranging from 1 to 53. See also DatePart. Syntax Week( date ) date Any date/time value or string convertible to date. Usage Years from 0 to 29 are interpreted as 21 century values.
  • Page 580: Writeoutput

    CFML Language Reference WriteOutput Appends text to the page output stream. Although you can call this function anywhere within a page, it is most useful inside a CFSCRIPT block. Note When within the CFQUERY and CFMAIL tags, the WriteOutput function does not output to the current page, but instead writes to the current SQL statement or mail text.
  • Page 581: Xmlformat

    Chapter 2: ColdFusion Functions XMLFormat Returns a string that is safe to use with XML. Syntax XMLFormat( string ) string Any string. Usage XMLFormat escapes special XML characters so that you can put arbitrary strings safely into XML. The characters that are escaped by XMLFormat include the following: greater than sign (>) less than sign (<) single quotation mark (’)
  • Page 582: Year

    CFML Language Reference Year Returns the year corresponding to date. See also DatePart and IsLeapYear. Syntax Year( date ) date Any date/time value or string convertible to date. Usage Years from 0 to 29 are interpreted as 21 century values. Years 30 to 99 are interpreted as 20 century values.
  • Page 583: Yesnoformat

    Chapter 2: ColdFusion Functions YesNoFormat Returns Boolean data as YES or NO. See also IsBinary and IsNumeric. Syntax YesNoFormat( value ) value Any number or Boolean value. Usage The YesNoFormat function returns all non-zero values as YES and zero values as NO. Examples <!--- This example shows the YesNoFormat --->...
  • Page 584 CFML Language Reference...
  • Page 585: Chapter 3: Wddx Javascript Objects

    H A P T E R WDDX JavaScript Objects Chapter 3 This chapter provides information about JavaScript objects and functions used when implementing WDDX in a ColdFusion application. Contents WddxSerializer Object..................562 WddxRecordset Object................... 565...
  • Page 586: Wddxserializer Object

    CFML Language Reference WddxSerializer Object The WddxSerializer object includes functions that serialize any JavaScript data structure. The only function that developers typically call is serialize. serialize Creates a WDDX packet for a passed WddxRecordset instance. Syntax object .serialize( rootobj ) object Instance name of the WddxSerializer object.
  • Page 587: Serializevalue

    Chapter 3: WDDX JavaScript Objects object Instance name of the WddxSerializer object. name Property to be serialized. Instance name of the value to be serialized. Return Boolean. Returns True if serialization was successful and False if an error occurs. value Usage Internal.
  • Page 588: Write

    CFML Language Reference object Instance name of the WddxSerializer object. Instance name of the WddxRecordset object to be serialized. Return Boolean. Returns True if obj was serialized successfully and False if an error occurs. value Usage Internal. You do not typically call this function. Example This example is from the WddxSerializer serialize function: this.wddxPacket = "";...
  • Page 589: Wddxrecordset Object

    Chapter 3: WDDX JavaScript Objects else if (typeof(obj) == "number") // Number value this.write("<number>" + obj + "</number>"); else if (typeof(obj) == "boolean") // Boolean value this.write("<boolean value=’" + obj + "’/>"); WddxRecordset Object The WddxRecordset object includes functions that you call as needed when constructing a WDDX recordset.
  • Page 590: Addrows

    CFML Language Reference // newValue is a previously defined variable rs.setField(0, "NewColumn", newValue); addRows Adds the specified number of rows to all columns in the WddxRecordset instance. Syntax object .addRows( n ) object Instance name of the WddxRecordset object. Integer specifying the number of rows to add. Return None.
  • Page 591: Getrowcount

    Chapter 3: WDDX JavaScript Objects Integer or string specifying the column of the value to be returned. Return Returns the value in the specified row/column position. value Usage Call this function to access a value in a WDDX record set. Example This example calls the getField function (the variable r is a reference to a WddxRecordset instance):...
  • Page 592: Setfield

    CFML Language Reference setField Sets the element in the specified row/column position. Syntax object .setField( row , col , value ) object Instance name of the WddxRecordset object. Integer specifying the row containing the element to be set. Integer or string specifying the column containing the element to be set. value Value to be set.
  • Page 593 Chapter 3: WDDX JavaScript Objects WddxSerializer instance. Return Boolean. Returns True if serialization was successful and False if an error occurs. value Usage Internal. You do not typically call this function. Example This example is from the WddxSerializer serializeValue function: else if (typeof(obj) == "object") if (obj == null) // Null values become empty strings...
  • Page 594 CFML Language Reference...
  • Page 595: Chapter 4: Coldfusion Expressions: Operators And Other Constructs

    H A P T E R ColdFusion Expressions: Chapter 4 Operators and Other Constructs This chapter describes ColdFusion expressions — language constructs that allow you to create sophisticated applications. Contents Elements of ColdFusion Expressions ............572 Operators ......................576 Operator Precedence ..................579 Function Syntax....................
  • Page 596: Elements Of Coldfusion Expressions

    CFML Language Reference Elements of ColdFusion Expressions The following objects can be used to build expressions: Objects Used to Build ColdFusion Expressions Type Description Integers Numbers with no decimal point. Real numbers Numbers with a decimal part. Also known as floating point numbers.
  • Page 597 Chapter 4: ColdFusion Expressions: Operators and Other Constructs Objects Used to Build ColdFusion Expressions Type Description Time values You can directly enter a date-and-time object in any of the following formats: "October 30, 1999 02:34:12" "October 30, 1999 2:34a" "October 30, 1999 2:34am" "October 30, 1999 02:34am"...
  • Page 598: Notes On Date-And-Time Values

    CFML Language Reference Objects Used to Build ColdFusion Expressions Type Description Queries ColdFusion queries can be referenced as objects by assigning a query to a variable: <CFQUERY NAME=myquery DATASOURCE=mydata SELECT * FROM CUSTOMERS </CFQUERY> <CFSET myquery2=myquery> In this case (unlike the same operation with arrays) the query is not copied.
  • Page 599: Notes On Using Variables

    Chapter 4: ColdFusion Expressions: Operators and Other Constructs century dates Two-digit years from 00 to 29 are treated as 21 century dates; 30 to 99 are treated as century dates. "October 30, 2015" "October 30, 15" Note Internally to ColdFusion, date-and-time values are represented on a time line as a subset of the real numbers.
  • Page 600: Operators

    CFML Language Reference (Client.MyVariable). Qualifiers are also known as scopes. Thus MyVariable is said to belong to the Form scope. In some cases, a variable must have pounds signs around it to allow ColdFusion to distinguish it from string or HTML text and to insert its value as opposed to its name. For more information on how to use pound signs in expressions see Pound Signs.
  • Page 601: String Operators

    Chapter 4: ColdFusion Expressions: Operators and Other Constructs Arithmetic Operators (Continued) Operator Description Divides two integer values. Use the \ (trailing slash) to separate the integers. The right operand cannot be zero. For example, 9 \ 4 is 2. Returns the result of a number raised to a power (exponent). Use the ^ (caret) to separate the number from the power.
  • Page 602 CFML Language Reference Decision Operators (Continued) Operator Description GREATER THAN OR EQUAL TO Checks to see if the value on the left is greater than or equal to the value on the right and returns true if it is. LESS THAN OR EQUAL TO Checks to see if the value on the left is less than or equal to the value on the right and returns true if it Shorthand notation for Boolean operators...
  • Page 603: Boolean Operators

    Chapter 4: ColdFusion Expressions: Operators and Other Constructs Boolean operators Boolean, or Logical, operators perform logical connective and negation operations. The operands of Boolean operators are Boolean (TRUE/FALSE) values. Boolean Operators Operator Description Reverses the value of an argument. For example, NOT TRUE is FALSE and vice versa.
  • Page 604: Function Syntax

    CFML Language Reference To enforce a specific non-standard order of evaluation, you must parenthesize expressions. For example: 6 - 3 * 2 is equal to 0 (6 - 3) * 2 is equal to 6 Parenthesized expressions can be arbitrarily nested. When in doubt about the order in which operators in an expression will be evaluated, always use parentheses.
  • Page 605: Pound Signs

    Chapter 4: ColdFusion Expressions: Operators and Other Constructs Pound Signs Pound signs (#) have special meaning in ColdFusion. When a CFML application page is processed, ColdFusion treats text delimited by pound signs differently from plain text. Two simple and very important points about pound signs in CFML are: Use pound signs to distinguish expressions from plain text.
  • Page 606: Pound Signs Inside Strings

    CFML Language Reference Complex expressions Complex expressions involving one or more operators cannot be inserted inside CFOUTPUT tags. The following example will produce an error. <CFOUTPUT>1 + 1 is #1 + 1#</CFOUTPUT> To insert the value of a complex expression in the output generated by a CFOUTPUT statement, use CFSET to set a variable to the value of the expression and use that variable inside the CFOUTPUT statement, as is shown below: <CFSET Result=1 + 1>...
  • Page 607: Pound Signs Inside Tag Attribute Values

    Chapter 4: ColdFusion Expressions: Operators and Other Constructs To insert the value of a complex expression inside a string, use CFSET to set some variable to the value of the expression and use that variable inside the string, or use the string concatenation operator: <CFSET Result=1 + 1>...
  • Page 608: Pound Signs In General Expressions

    CFML Language Reference All of the above statements result in errors. As a general rule, never put pound signs around function arguments. Pound signs in general expressions Allaire recommends that pound signs be used only where necessary. The following example demonstrates the preferred method for referencing variables. <CFSET SomeVar=Var1 + Max(Var2, 10 * Var3) + Var4>...

This manual is also suitable for:

Coldfusion 4.5

Table of Contents