background image

Chapter 2:  ColdFusion Functions

433

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. 

delimiter

Optional. Specify the character(s) used to delimit elements in the list. The default 
is a comma ( , ). 

Example

<!--- This example uses ListValueCountNoCase to see how many 

  employees are in a department --->

<HTML>
<HEAD>
<TITLE>ListValueCountNoCase Example</TITLE>
</HEAD>

<body  bgcolor="#FFFFD5">

<CFQUERY NAME="SearchByDepartment" DATASOURCE="cfsnippets">
SELECT Department
FROM Employees
</CFQUERY>

<H3>ListValueCountNoCase Example</H3>
<P>This example uses ListValueCountNoCase to see how many employees 
are in a department.

<FORM ACTION="listvaluecountnocase.cfm" METHOD="POST">
<P>Select a department:</P>

<select NAME="departmentName">

<option VALUE="Accounting">

Accounting

</OPTION>
<option VALUE="Administration">

Administration

</OPTION>
<option VALUE="Engineering">

Engineering

</OPTION>
<option VALUE="Sales">

Sales

Summary of Contents for COLDFUSION 4.5-CFML LANGUAGE

Page 1: ...Allaire Corporation CFML Language Reference ColdFusion 4 5...

Page 2: ...ication may be reproduced stored in a retrieval system or transmitted in any form or by any means electronic mechanical recording or otherwise without the prior written permission of Allaire Corporati...

Page 3: ...tures xix Using Examples xix Using Code Snippets xix Using End Tags xx Developer Resources xx About ColdFusion Documentation xxi Documentation updates xxi ColdFusion manuals xxi ColdFusion Server onli...

Page 4: ...tes 46 CFFILE ACTION Upload 47 Evaluating the results of a file upload 49 CFFILE ACTION Move 51 CFFILE ACTION Rename 52 CFFILE ACTION Copy 53 CFFILE ACTION Delete 54 CFFILE ACTION Read 54 CFFILE ACTIO...

Page 5: ...FMAIL 135 CFMAILPARAM 138 CFMODULE 140 CFOBJECT 143 CFOBJECT TYPE attributes 143 CFOBJECT Type COM 144 CFOBJECT Type CORBA 146 CFOBJECT Type JAVA 147 CFOUTPUT 149 CFPARAM 151 CFPOP 154 CFPROCESSINGDIR...

Page 6: ...242 New Functions in ColdFusion 4 5 245 Array Functions 245 Authentication Functions 245 Date and Time Functions 246 Decision Functions 246 Display and Formatting Functions 247 Dynamic Evaluation Fun...

Page 7: ...itSHLN 287 BitSHRN 288 BitXor 289 Ceiling 290 Chr 291 CJustify 292 Compare 293 CompareNoCase 295 Cos 296 CreateDate 297 CreateDateTime 299 CreateObject 301 Object Types 301 COM 301 CORBA 302 JAVA 303...

Page 8: ...N 352 GetBaseTagData 353 GetBaseTagList 354 GetBaseTemplatePath 355 GetClientVariablesList 356 GetCurrentTemplatePath 357 GetDirectoryFromPath 358 GetFileFromPath 359 GetFunctionList 360 GetLocale 361...

Page 9: ...ListDeleteAt 413 ListFind 414 ListFindNoCase 416 ListFirst 417 ListGetAt 418 ListInsertAt 419 ListLast 420 ListLen 421 ListPrepend 422 ListQualify 423 ListRest 425 ListSetAt 426 ListSort 428 ListToAr...

Page 10: ...QueryAddColumn 481 QueryAddRow 483 QueryNew 484 QuerySetCell 485 QuotedValueList 487 Rand 488 Randomize 489 RandRange 490 REFind 491 REFindNoCase 494 RemoveChars 497 RepeatString 498 Replace 499 Repl...

Page 11: ...50 URLDecode 551 URLEncodedFormat 552 Val 553 ValueList 554 Week 555 WriteOutput 556 XMLFormat 557 Year 558 YesNoFormat 559 Chapter 3 WDDX JavaScript Objects 561 WddxSerializer Object 562 serialize 56...

Page 12: ...on 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 in...

Page 13: ...ness systems Developing applications with ColdFusion does not require coding in a traditional programming language instead you build applications by combining standard HTML with a straightforward serv...

Page 14: ...enhanced fundamental features including email integration server side FTP and HTTP advanced security scheduling and database connectivity again giving you more reliability and new functionality The f...

Page 15: ...d for clustering 150 MB hard disk space ColdFusion Server 4 5 Professional Edition for Windows Windows 95 98 or Windows NT 4 0 Intel Pentium or above 50 MB hard disk space 32 MB RAM 128 MB recommended...

Page 16: ...functions instantly and inline as you code Image Map Editor Create image maps right in ColdFusion Studio with a new easy to use visual tool Configuration Wizard Setup your work environment so it meet...

Page 17: ...downloads of unchanged pages and improve overall site performance Programmatically control refresh of client side cache to ensure users see most up to date output White Space Removal Reduce white spa...

Page 18: ...attachments Improved Server Side HTTP Use URL redirection SSL cookies return headers and more robust server side HTTP support for building distributed Web applications Security enhancements General OS...

Page 19: ...larity and to conserve space HTML documentation Each tag or function displays an examples button that you click to execute that element The online example displays two frames one that runs the example...

Page 20: ...te is designed to give you quick access to the entire range of online resources Allaire Developer Services Resource Description Allaire Web site www allaire com General information about Allaire produ...

Page 21: ...tions and Allaire products and services For ColdFusion Studio users you can access the documentation update page by clicking on the Help resource tab and browsing your way through the online help tree...

Page 22: ...u don t have a product CD you can download ColdFusion documentation from the Allaire web site by visiting http www allaire com developer and clicking the Documentation link ColdFusion Studio online do...

Page 23: ...particular programming problems is to tap into the vast expertise of the ColdFusion developer community on the Allaire Forums Other ColdFusion developers on the forum can help you figure out how to do...

Page 24: ...61 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...

Page 25: ...mainder of this chapter provides complete descriptions of each tag listed alphabetically Contents Alphabetical List of ColdFusion Tags 2 New Tags in ColdFusion 4 5 5 ColdFusion Forms Tags 6 Database M...

Page 26: ...the base tag CFAUTHENTICATE Authenticates a user and sets the security context for an application CFBREAK Breaks out of a CFML looping construct CFCACHE Caches ColdFusion pages CFCOL Defines table col...

Page 27: ...AM Used with CFHTTP to specify parameters necessary for a CFHTTP POST operation CFIF CFELSEIF CFELSECFIF CFELSEIF CFELSE Used to create IF THEN ELSE constructs CFIMPERSONATE Allows you to impersonate...

Page 28: ...access the result set from a stored procedure CFQUERY Passes SQL to a database CFQUERYPARAM Reads writes and deletes keys and values in the system registry CFREGISTRY Reads writes and deletes keys and...

Page 29: ...line text entry box in a CFFORM CFTHROW Raises a developer specified exception CFTRANSACTION Groups CFQUERYs into a single transaction performs rollback processing CFTREE Used in CFFORM to create a tr...

Page 30: ...andling Tags CFAPPLET CFINPUT CFFORM CFSELECT CFGRID CFSLIDER CFGRIDCOLUMN CFTEXTINPUT CFGRIDROW CFTREE CFGRIDUPDATE CFTREEITEM CFINSERT CFQUERYPARAM CFPROCPARAM CFSTOREDPROC CFPROCRESULT CFTRANSACTIO...

Page 31: ...rotocol Tags CFCOLLECTION CFSEARCH CFEXECUTE CFSERVLET CFINDEX CFSERVLETPARAM CFOBJECT CFWDDX CFREPORT CFDIRECTORY CFFILE CFABORT CFLOOP CFBREAK CFSWITCH CFCASE CFDEFAULTCASE CFEXECUTE CFTHROW CFIF CF...

Page 32: ...Manipulation Tags Web Application Framework Tags Other Tags CFOBJECT CFSERVLETPARAM CFSERVLET CFCOOKIE CFSCRIPT CFPARAM CFSET CFAPPLICATION CFERROR CFASSOCIATE CFLOCK CFAUTHENTICATE CFASSOCIATE CFREP...

Page 33: ...wn all the way up to the line containing the CFABORT tag When using CFABORT with SHOWERROR by itself that is without defining an error page using CFERROR page processing stops once the CFABORT tag is...

Page 34: ...3 CFSET myVariable 3 now perform a loop that increments this value CFLOOP FROM 1 TO 4 INDEX Counter on the second time through the loop CFABORT CFIF Counter is 2 CFABORT the processing is stopped and...

Page 35: ..._variable_name HEIGHT pixels WIDTH pixels VSPACE pixels HSPACE pixels ALIGN alignment NOTSUPPORTED text param_1 value param_2 value param_n value APPLETSOURCE Required The name of the registered apple...

Page 36: ...ministrator Usage Since Java applets must be pre registered the CFAPPLET tag can be very simple taking the default parameter values as they were registered in the ColdFusion Administrator You can also...

Page 37: ...Optional Yes or No Enables client variables Default is No CLIENTSTORAGE Optional Specifies the mechanism for storing client variables datasourcename ColdFusion stores client variables in the specifie...

Page 38: ...APPLICATION enables application variables unless they have been disabled in the ColdFusion Administrator Using the SESSIONMANAGEMENT attribute to enable session variables is also overridden by the Adm...

Page 39: ...n variables that will be used by E Turtleneck Use the session scope for the session variables CFLOCK SCOPE Session TIMEOUT 30 TYPE Exclusive CFIF NOT IsDefined session size CFSET session size CFIF CFI...

Page 40: ...name is AssocAttribs Use the DataCollection attribute to specify a non default structure name Specify a non default structure name when the base tag can have multiple sub tags and you want to segrega...

Page 41: ...d its contents include user name security context browser remote address and the HTTP user agent THROWONFAILURE Optional Default is Yes Indicates whether ColdFusion throws an exception of type SECURIT...

Page 42: ...MLLanguageReference 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 Pers...

Page 43: ...CFQUERY HTML HEAD TITLE CFBREAK Example TITLE HEAD BODY bgcolor silver H1 CFBREAK Example H1 P This example uses CFLOOP to cycle through a query to find a desired value In our example a list of values...

Page 44: ...esh the cached page If you specify FLUSH you can also specify the DIRECTORY and EXPIREURL attributes CLIENTCACHE Specifies browser caching OPTIMAL Specifies optimal caching through a combination of se...

Page 45: ...on resources because the browser stores the pages in its own cache thus improving performance The advantage of using a combination of the two forms of caching is that it optimizes performance if the b...

Page 46: ...hed file is found only one request is required Debug settings have no effect on CFCACHE unless the template explicitly turns it on When generating a cached file CFCACHE uses CFSETTING SHOWDEBUGOUTPUT...

Page 47: ...can consist of a combination of literal text HTML tags and query record set field references This means you can embed hyperlinks image references and even input controls within table columns Example...

Page 48: ...nd 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 CFCOL HEAD...

Page 49: ...e depends on the ACTION that you specify ACTION What happens CREATE CFCOLLECTION creates a directory for the use of Verity The directory path is composed of the directory path specified in the PATH at...

Page 50: ...tool other than ColdFusion The ACTION COLLECTION and PATH attributes are required The path must point to a valid Verity collection mapping does not validate the path Deleting a mapped collection unreg...

Page 51: ...UE Repair CFCOLLECTION ACTION REPAIR COLLECTION FORM CollectionName H3 Collection repaired H3 CFCASE CFCASE VALUE Optimize CFCOLLECTION ACTION OPTIMIZE COLLECTION FORM CollectionName H3 Collection opt...

Page 52: ...ter the download operation Defaults to No This attribute only applies if you are specifying a file with the FILE attribute FILE Optional Denotes the name of the file being retrieved RESET Optional Yes...

Page 53: ...BODY HTML This example shows how the RESET attribute changes textual output HTML HEAD TITLE CFCONTENT Example 2 TITLE HEAD BODY H3 CFCONTENT Example 2 H3 P This example shows how the RESET attribute c...

Page 54: ...URLs within the specified domain to which this cookie applies PATH services login Separate multiple entries with a semicolon DOMAIN Specifies the domain for which the cookie is valid and to which the...

Page 55: ...Posted FROM Comments CFQUERY HTML HEAD TITLE CFCOOKIE Example TITLE HEAD BODY bgcolor silver H3 CFCOOKIE Example H3 if the URL variable delcookie exists set the cookie s expiration date to NOW CFIF I...

Page 56: ...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 de...

Page 57: ...refer to Administering ColdFusion Server for more information about securing ColdFusion tags Syntax CFDIRECTORY ACTION directory action DIRECTORY directory name NAME query name FILTER list filter MODE...

Page 58: ...s the default For example SORT dirname ASC filename2 DESC size datelastmodified NEWDIRECTORY Required for ACTION Rename Ignored for all other actions The new name of the directory specified in the DIR...

Page 59: ...3 CFDIRECTORY Example H3 use CFDIRECTORY to give the contents of the snippets directory order by name and size you may need to modify this path CFDIRECTORY DIRECTORY c inetpub wwwroot cfdocs snippets...

Page 60: ...rocessing of a page Request is the default See the table under CFERROR Error Variables for information about the variables and other constructs available from the templates used to handle each type of...

Page 61: ...mplate specified in the TEMPLATE attribute of the CFERROR tag may contain one or more error variables which will be substituted by ColdFusion when an error is displayed Types and Their Corresponding C...

Page 62: ...r Error MailTo Email address of administrator who should be notified corresponds to the value set in the MAILTO attribute of CFERROR Error DateTime Date and time when the error occurred Error Browser...

Page 63: ...OR is still a good safeguard against general errors P You can also use CFERROR within the Application cfm to specify error handling responsibilities for an entire application Example of CFERROR call w...

Page 64: ...quotes If ARGUMENTS is passed as an array it is processed as follows On Windows systems the array elements will be concatenated into a string of tokens separated by spaces This string is then passed t...

Page 65: ...Output File Cannot be opened will be thrown If the effective user of the ColdFusion executing thread does not have permissions to execute the process a security exception will be thrown The time out...

Page 66: ...custom tag Usage If a CFEXIT tag is encountered outside the context of a custom tag for example in the base page or an included page the tag acts exactly like CFABORT CFEXIT can help simplify error c...

Page 67: ...t the appropriate sections inside the CFUSION customtags directory MyCustomTag cfm This simple custom tag checks for the existence of myValue1 and myValue2 If they are both defined the tag adds them a...

Page 68: ...f 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 C...

Page 69: ...These settings are managed using the Basic Security page in the ColdFusion Administrator In order for CFFILE to execute it needs to be enabled on the Basic Security page If you write ColdFusion applic...

Page 70: ...ions that follow describe these values and attributes in greater detail Attributes Used with CFFILE ACTIONs ACTION Attributes Upload ACCEPT DESTINATION FILEFIELD NAMECONFLICT MODE ATTRIBUTES Move SOUR...

Page 71: ...neath the root of the Web server document directory NAMECONFLICT Optional Default is error Determines how the file should be handled if its name conflicts with the name of a file that already exists i...

Page 72: ...le attributes are supported ReadOnly Temporary Archive Hidden System Normal If ATTRIBUTES is not used the file s attributes are maintained If Normal is specified as well as any other attributes Normal...

Page 73: ...file for example myfile txt ClientDirectory Directory location of the file uploaded from the client s system ClientFile Name of the file uploaded from the client s sys tem ClientFileExt Extension of t...

Page 74: ...d file and makes permissions read write rw for all 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...

Page 75: ...ON Required The full path name of the directory to which the file will be moved If you do not specify the file name a trailing slash must be included in the target when moving a file Use the backward...

Page 76: ...ION Rename SOURCE full_path_name DESTINATION full_path_name ATTRIBUTES file_attributes SOURCE Required The full path name of the file to rename DESTINATION Required The full path name including the ne...

Page 77: ...st include the trailing slash On Windows use the backward slash On UNIX use the forward slash ATTRIBUTES Optional A comma delimited list of file attributes to be set on the file being copied The follo...

Page 78: ...ynamic parameter you can use anywhere in the page like any other dynamic parameter For example you could read a text file and then insert its contents into a database Or you could read a text file and...

Page 79: ...ould first convert it to Base 64 see ToBase64 Syntax CFFILE ACTION ReadBinary FILE full_path_name VARIABLE var_name FILE Required The full path name of the file to be read VARIABLE Required The name o...

Page 80: ...issions for all ADDNEWLINE Optional Yes or No If this attribute is set to Yes a new line character is appended to the text that is written to the file If this attribute is set to No no new line charac...

Page 81: ...ory and the file would contain the text Created By World B Frueh Date 10 30 98 We had a wonderful time in Cambridgeport This following examples show the use of the MODE attribute for UNIX The first cr...

Page 82: ...haracter is appended to the text The default value is Yes ATTRIBUTES Optional A comma delimited list of file attributes to be set on the file being appended The following file attributes are supported...

Page 83: ...ing the page users are asked if they want to download the CAB file ONSUBMIT Optional JavaScript function to execute after other input validation returns Use this attribute to execute JavaScript for pr...

Page 84: ...reating a form If you specify a value in quotation marks you must escape the quotation marks by doubling them for example PASSTHROUGH readonly YES The ENABLECAB attribute is supported only for MS Inte...

Page 85: ...eckbox Test H3 Your checkbox answer was no CFIF CFIF IsDefined form textSample is True AND form textSample is not H3 Results of Credit Card Input H3 Your credit card number CFOUTPUT form textSample CF...

Page 86: ...er a Credit Card Number VALIDATE creditcard REQUIRED No TD TR TR TD H4 This example shows the use of the CFSLIDER tag H4 P Rate your approval of this example from 1 to 10 by sliding the control P 1 CF...

Page 87: ...f you write ColdFusion applications designed to run on a server that is used by multiple customers you need to consider the security of the files that the customer can move Please refer to Administeri...

Page 88: ...he the current FTP connection or to reuse connection information from a previous connection of the same name All calls to CFFTP with the same connection name will reuse the same FTP connection informa...

Page 89: ...TML HEAD TITLE CFFTP Example TITLE HEAD BODY H3 CFFTP Example H3 P CFFTP allows users to implement File Transfer Protocol operations By default CFFTP caches an open connection to an FTP server P CFFTP...

Page 90: ...d to respecify the connection attributes USERNAME PASSWORD SERVER Syntax CFFTP ACTION action USERNAME name PASSWORD password NAME query_name SERVER server ASCIIEXTENSIONLIST extensions TRANSFERMODE mo...

Page 91: ...presentation of UNIX permissions for example 777 when appropriate Note also that there is a CFFTP ReturnValue variable that provides the return value for some of these actions The actions for which th...

Page 92: ...ith the same connection name will reuse the same FTP connection information ASCIIEXTENSIONLIST Optional A semicolon delimited list of file extensions that force ASCII transfer mode when TRANSFERMODE A...

Page 93: ...condition PROXYSERVER Optional A string that contains the name of the proxy server or servers to use if proxy access was specified If this parameter is NULL the tag reads proxy information from the re...

Page 94: ...e is one of the columns returned in the query object as shown in the following table Row is the row number for each file directory entry returned by the ListDir operation A separate row is created for...

Page 95: ...hed Note that keeping a connection open prevents others from using the FTP server therefore you should close the connection as soon as possible Note Changes to a cached connection such as changing RET...

Page 96: ...R 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 Las...

Page 97: ...column_font FONTSIZE size ITALIC Yes No BOLD Yes No HREF URL HREFKEY column_name TARGET URL_target APPENDKEY Yes No HIGHLIGHTHREF Yes No ONVALIDATE javascript_function ONERROR text GRIDDATAALIGN posit...

Page 98: ...ue Valid entries are Top Left Bottom Baseline Texttop Absbottom Middle Absmiddle Right QUERY Optional The name of the query associated with the grid control INSERT Optional Yes or No Yes allows end us...

Page 99: ...the value of the selected tree item in the URL to the application page specified in the CFFORM ACTION attribute Default is Yes HIGHLIGHTHREF Optional Yes highlights links associated with a CFGRID wit...

Page 100: ...text in boldface Default is No ROWHEADERWIDTH Optional The width in pixels of the row header column COLHEADERS Optional Yes or No Yes displays column headers in the grid control Defaults to Yes COLHE...

Page 101: ...the grid 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 Fo...

Page 102: ...or the selected row When SELECTMODE Browse no selection data is returned Using SELECTMODE Edit When SELECTMODE Edit one dimensional arrays are used to store data about changes to the grid cells For ex...

Page 103: ...GRIDUPDATE tags in action use a query to show the useful qualities of CFGRID If the gridEntered form field has been tripped perform the gridupdate on the table specified in the database Using the defa...

Page 104: ...TAALIGN LEFT BOLD No ITALIC No SELECT No DISPLAY No HEADERBOLD No HEADERITALIC No CFGRIDCOLUMN NAME Dept_ID HEADER Department HEADERALIGN LEFT DATAALIGN LEFT BOLD Yes ITALIC No SELECT Yes DISPLAY Yes...

Page 105: ...ADERBOLD Yes No DATAALIGN position HEADERALIGN position NUMBERFORMAT format NAME Required A name for the grid column element If the grid uses a query the column name must specify the name of a query c...

Page 106: ...grid control When No the column cannot be edited even if the CFGRID INSERT or DELETE attributes are enabled The value of the SELECT attribute is ignored if the CFGRID SELECTMODE attribute is set to R...

Page 107: ...in boldface Default is No DATAALIGN Optional Alignment for column data Valid entries are Left Center or Right Default is Left HEADERALIGN Optional Alignment for the column header text Valid entries ar...

Page 108: ...NAME Dept_ID HEADER Department HEADERALIGN LEFT DATAALIGN LEFT BOLD Yes ITALIC No SELECT Yes DISPLAY Yes HEADERBOLD No HEADERITALIC Yes CFGRIDCOLUMN NAME CorNumber HEADER Course HEADERALIGN LEFT DATA...

Page 109: ...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...

Page 110: ...ntax CFGRIDROW DATA col1 col2 DATA Required A comma separated list of column values If a column value contains a comma character it must be escaped with a second comma character Example use a CFLOOP t...

Page 111: ...RID form element that is the source for the update action DATASOURCE Required The name of the data source for the update action DBTYPE Optional The database driver type ODBC default ODBC driver Oracle...

Page 112: ...overrides the password value specified in the ODBC setup TABLEOWNER Optional For data sources that support table ownership such as SQL Server Oracle and Sybase SQL Anywhere use this field to specify t...

Page 113: ...ered 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 previo...

Page 114: ...ion with the NAME attribute STATUSCODE Required if you do not specify the NAME attribute A number that sets the HTTP status code STATUSTEXT Optional Text that explains the status code This attribute i...

Page 115: ...quotation marks is placed in the HEAD section Example This example shows the use of CFHTMLHEAD CFHTMLHEAD TEXT TITLE This is an example of a generated header TITLE BASE HREF http www allaire com HTML...

Page 116: ...agent THROWONERROR Yes No REDIRECT Yes No TIMEOUT timeout_period CFHTTP Note Terminate CFHTTP POST operations with CFHTTP Termination is not required with CFHTTP GET operations URL Required Full URL o...

Page 117: ...at is accessed For GET operations defaults to the name specified in URL Enter path information in the PATH attribute DELIMITER Required for creating a query Valid characters are a tab or comma Default...

Page 118: ...YES execution stops if CFHTTP fails and the status code and associated error message are returned in the variable CFHTTP StatusCode To see where execution would have been redirected use the variable...

Page 119: ...variables returned by CFHTTP GET file into a query To download a file in a ColdFusion page so that a query can be built using the file the file must be either comma separated or tab delimited Althoug...

Page 120: ...s of a web page from the Internet and shows how you can get the following information by using CFHTTP variables P UL LI display the page fileContent LI derive the MIME type of the page mimeType LI fin...

Page 121: ...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 RESPON...

Page 122: ...pecifies the value of the URL FormField Cookie File or CGI variable being passed FILE Required for TYPE File Example This example shows the use of CFHTTPPARAM HTML HEAD TITLE CFHTTPPARAM Example TITLE...

Page 123: ...PUT BODY HTML CFOUTPUT H3 For CFHTTPPARAM code see right frame H3 P CFHTTP METHOD POST URL http localhost someotherfile cfm CFHTTPPARAM NAME form_test TYPE FormField VALUE This is a form variable CFHT...

Page 124: ...re is a switch that provides fast date time parsing If you have enabled this switch you must refer to dates in expressions in the following order month day and year For example CFIF 11 23 1998 GT 11 1...

Page 125: ...a Ana H4 Featured Center in CFIF city is San Diego San Diego CFELSE Santa Ana CFIF H4 B Name Address B Name Address1 City State BR B Contact B Contact BR CFELSE BR I Name City I CFIF CFOUTPUT P Finall...

Page 126: ...hat you want to impersonate TYPE Required The type of impersonation needed This attribute can have the value CF for impersonation at the application level or OS for impersonation at the operating syst...

Page 127: ...ed calls in the code to protect each resource Refer to Administering ColdFusion Server for more information about Advanced Security Example This example shows the use of CFIMPERSONATE to impersonate a...

Page 128: ...ks the directory in which the current page lives Searches directories explicitly mapped in the ColdFusion Administrator for the included file Example This example shows the use of CFINCLUDE to paste p...

Page 129: ...XTERNAL Yes No LANGUAGE language COLLECTION Required Specifies a collection name If you are indexing an external collection EXTERNAL is Yes specify the collection name including fully qualified path C...

Page 130: ...other TYPE argument BODY Optional ASCII text to index or a query column name Required if TYPE Custom Ignored for TYPE File and TYPE Path Invalid if TYPE Delete Specifies one of the following The ASCII...

Page 131: ...fies that directories below the path specified in KEY when TYPE Path will be included in the indexing operation EXTERNAL Optional Yes or No Yes indicates that the collection specified in COLLECTION wa...

Page 132: ...ection 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...

Page 133: ...type ONVALIDATE javascript_function MESSAGE validation_msg ONERROR text SIZE integer MAXLENGTH integer CHECKED Yes No PASSTHROUGH HTML_attributes TYPE Optional Valid entries are Text Creates a text en...

Page 134: ...er input The form object input object and input object value are passed to the specified routine which should return true if validation succeeds and false otherwise When used the VALIDATE attribute is...

Page 135: ...nter telephone number formatted xxx xxx xxxx e g 617 761 2000 VALIDATE telephone REQUIRED Yes font size 1 color red Required FONT zip code validation P Zip Code Validation enter a properly formatted z...

Page 136: ...er Using this option the ColdFusion Server computer must have Oracle 8 0 or greater client software installed Sybase11 Sybase System 11 native database driver Using this option the ColdFusion Server c...

Page 137: ...ier refers to the directory where the DBF files are located USERNAME Optional If specified USERNAME overrides the username value specified in the ODBC setup PASSWORD Optional If specified PASSWORD ove...

Page 138: ...ref mailto Email FromUser A TD TD valign top Subject TD TD valign top CommtType TD TD valign top FONT SIZE 2 Left MessText 125 FONT TD TD valign top Posted TD TR CFOUTPUT TABLE P Next we ll offer the...

Page 139: ...e and or desc or asc DN distinguished_name STARTROW row_number MODIFYTYPE REPLACE or ADD or DELETE REBIND Yes No REFERRAL number_of_allowed_hops SECURE multi_field_security_string SEPARATOR separator_...

Page 140: ...es OneLevel Default Searches all entries one level beneath the entry specified in the START attribute Base Searches only the entry specified in the START attribute Subtree Searches the entry specified...

Page 141: ...actions Example cn Barbara Jensen o Ace Industry c US STARTROW Optional Used in conjunction with ACTION Query Specifies the first row of the LDAP query that is to be inserted into the ColdFusion quer...

Page 142: ...rectory is C cfusion ldap Refer to the Usage section for information about the differences between the two types of security CFSSL_BASIC and CFSSL_CLIENT_AUTH types SEPARATOR Optional Specifies the ch...

Page 143: ...e all the clients must have certificates which the server must be able to validate and all the certificates must have keys associated with them and passwords to protect those keys Example This example...

Page 144: ...n 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...

Page 145: ...value of Yes appends client variable information to the URL you specify in the URL argument Example This view only example shows the use of CFLOCATION HTML HEAD TITLE CFLOCATION Example TITLE HEAD BO...

Page 146: ...cation or Server or Session NAME lockname THROWONTIMEOUT Yes No TYPE ReadOnly Exclusive CFML to be synchronized CFLOCK TIMEOUT Required Specifies the maximum amount of time in seconds to wait to obtai...

Page 147: ...tiple concurrently executing requests do not manipulate shared data structures files or CFXs in an inconsistent manner Note the following Using CFLOCK around CFML constructs that modify shared data en...

Page 148: ...onse time may increase if an application has multiple frames that can be refreshed at once thus causing multiple requests to have to queue up and wait to be processed For an analysis of best practices...

Page 149: ...ocks should do so in a well specified order and name the locks consistently In particular if you need to lock access to the server application and session scopes you must do so in the following order...

Page 150: ...ncy of data updates to variables in the Application Server and Session scopes You should copy the following code into an Application cfm file in the snippets directory HTML HEAD TITLE Define Session a...

Page 151: ...tleneck is proud to say that we have sold application number turtlenecks to date CFOUTPUT CFLOCK End of Application cfm HEAD TITLE CFLOCK Example TITLE HEAD BASEFONT FACE Arial Helvetica SIZE 2 BODY b...

Page 152: ...icate the color and size that you wish to buy P table cellspacing 2 cellpadding 2 border 0 tr td Select a color td td SELECT TYPE Text NAME color OPTION red OPTION white OPTION blue OPTION turquoise O...

Page 153: ...FOR loops as in loop FOR this range of values Syntax CFLOOP INDEX parameter_name FROM beginning_value TO ending_value STEP increment HTML or CFML code to execute CFLOOP INDEX Required Defines the para...

Page 154: ...The loop index is 2 The loop index is 1 Conditional Loops A conditional loop iterates over a set of instructions while a given condition is TRUE To use this type of loop correctly the instructions mu...

Page 155: ...RTROW row_num ENDROW row_num QUERY Required Specifies the query that will control the loop STARTROW Optional Specifies the first row of the query that will be included in the loop ENDROW Optional Spec...

Page 156: ...etTemplate DATASOURCE Library MAXROWS 5 SELECT TemplateName FROM Templates CFQUERY CFLOOP QUERY TemplateName CFINCLUDE TEMPLATE TemplateName CFLOOP Looping over a List Looping over a list offers the o...

Page 157: ...ing over a COM Collection or Structure The CFLOOP COLLECTION attribute allows you to loop over a structure or a COM DCOM collection object A COM DCOM collection object is a set of similar items refere...

Page 158: ...ough a structure used as an associative array Create a structure and loop through its contents CFSET Departments StructNew CFSET val StructInsert Departments John Sales CFSET val StructInsert Departme...

Page 159: ...tains address information such as TO EMail In the latter case an individual email message is sent for every row returned by the query FROM Required The sender of the email message This attribute may b...

Page 160: ...single email message For example if you send a set of billing statements out to your customers you might group on Customer_ID The GROUP attribute which is case sensitive eliminates adjacent duplicates...

Page 161: ...This message was sent by an automatic mailer built with CFMAIL form body CFMAIL H3 Thank you H3 P Thank you CFOUTPUT mailfrom your message subject has been sent to mailto CFOUTPUT CFIF CFIF P FORM AC...

Page 162: ...UE header value CFMAIL FILE Required if you do not specify the NAME attribute Attaches the specified file to the message This attribute is mutually exclusive with the NAME attribute NAME Required if y...

Page 163: ...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...

Page 164: ...e of the custom tag in the form Name Name Name that uniquely identifies a subdirectory containing the custom tag page under the root directory for CF custom tags For example CFMODULE NAME Allaire Foru...

Page 165: ...sion custom tags in the Cfusion CustomTags directory For more information about using Custom Tags please refer to i Developing Web Applications i P show the code in the custom tag P Here is the code i...

Page 166: ...ustom tag using the NAME attribute P CFOUTPUT HTMLCodeFormat CFMODULE NAME myTag X 3 attributeCollection attrCollection1 Y 4 CFOUTPUT P The result CFOUTPUT result CFOUTPUT Call the tag using the short...

Page 167: ...FOBJECT Type COM CFOBJECT Type CORBA CFOBJECT Type JAVA CFOBJECT TYPE attributes Depending on the value you assign to the TYPE attribute of CFOBJECT there are several additional attributes you can set...

Page 168: ...n for most COM objects Syntax CFOBJECT TYPE COM ACTION action CLASS program_ID NAME text CONTEXT context SERVER server_name ACTION Required One of the following Create Use Create to instantiate a COM...

Page 169: ...e called using empty parenthesis CFSET obj Init This object is a collection object and should support at a minimum Property Count Method Item inarg outarg and a special property called _NewEnum CFOUTP...

Page 170: ...SS Required Specifies different information depending on the CONTEXT specification If CONTEXT is IOR Specifies the name of a file that contains the stringified version of the IOR ColdFusion must be ab...

Page 171: ...ension EJB objects This support is currently only for NT but will be extended to Solaris in the next release Syntax CFOBJECT ACTION Create TYPE Java CLASS Java class NAME object name ACTION Required S...

Page 172: ...create and call all the appropriate EJB objects use CFOBJECT The sequence in the second example assumes that the Weblogic JNDI is used to register and find EJBHome instances Example of Java Object Thi...

Page 173: ...e GROUP attribute which is case sensitive eliminates adjacent duplicates in the case where the data is sorted by the specified field See the GROUPCASESENSITIVE attribute for information about specifyi...

Page 174: ...UTPUT DateFormat Now CFOUTPUT P In addition CFOUTPUT may be used to show the results of a query operation or only a partial result as shown P There are CFOUTPUT getCourses recordCount CFOUTPUT total r...

Page 175: ...does not exist TYPE Optional The type of parameter that is required The default value is any DEFAULT Optional Default value to set the parameter to if it does not exist Type Values Type Value Descript...

Page 176: ...d set to the value of the DEFAULT attribute Example This example shows how CFPARAM operates CFPARAM NAME storeTempVar DEFAULT my default value CFPARAM NAME tempVar DEFAULT my default value check if fo...

Page 177: ...Chapter 1 ColdFusion Tags 153 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: ...s PASSWORD Optional Password corresponds to user name ACTION Optional Specifies the mail action There are three possible values GetHeaderOnly Default Returns message header information only GetAll Ret...

Page 179: ...d ATTACHMENTPATH is specified no attachment files are written to the server TIMEOUT Optional Specifies the maximum amount of time in seconds to wait for mail processing Defaults to 60 seconds MAXROWS...

Page 180: ...ent row of the query being processed by CFOUTPUT queryname ColumnList The list of the column names in the query CFPOP Query Variables Continued Variable Names Description Message Header and Body Colum...

Page 181: ...allowing you to display the mail headers in a POP3 mailbox P Simply uncomment this code and run with a mail enabled CF Server to see this feature in action CFIF IsDefined form server make sure server...

Page 182: ...t 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 I...

Page 183: ...tag s settings within the body of the inner tag where they differ If the enclosing tag specifies settings that the inner tag does not those settings remain in effect within the inner tag s scope CFPR...

Page 184: ...use to reference the value that the output parameter represents after the call is made to the stored procedure DBVARNAME Required if named notation is desired This is the parameter name This correspon...

Page 185: ...the order in which they are defined Named notation If named notation is used the DBVarName for the parameter must correspond to the variable name in the stored procedure on the server Output variables...

Page 186: ...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 R...

Page 187: ...esult set Usage Specify one or more CFPROCRESULT tags to enable access to data returned by the stored procedure RESULTSET must be unique within the scope of the CFSTOREDPROC tag If you specify the sam...

Page 188: ...TPUT 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 RS...

Page 189: ...r in the page to reference the query s record set DATASOURCE Required The name of the data source from which this query should retrieve data DBTYPE Optional The database driver type ODBC default ODBC...

Page 190: ...to 100 This parameter applies to ORACLE native database drivers and to ODBC drivers Certain ODBC drivers may dynamically reduce the block factor at runtime TIMEOUT Optional Lets you specify a maximum...

Page 191: ...onal Used for debugging queries Specifying this attribute causes the SQL statement actually submitted to the data source and the number of records returned from the query to be output Usage In additio...

Page 192: ...Name State CFQUERY build HTML table to display query TABLE cellpadding 1 cellspacing 1 TR TD colspan 2 bgcolor f0f0f0 B I Park Name I B TD TD bgcolor f0f0f0 B I Region I B TD TD bgcolor f0f0f0 B I Sta...

Page 193: ...offer a link to the same page with the StartRow value incremented by MaxRows in the case of this example incremented by 10 TR TD colspan 4 CFIF StartRow MaxRows LTE GetParks RecordCount a href cfquer...

Page 194: ...value CFSQLType parameter type MAXLENGTH maximum parameter length SCALE number of decimal places DBNAME database name NULL Yes No AND OR additional criteria of the WHERE clause CFQUERY VALUE Required...

Page 195: ...parameters If a database does not support bind parameters ColdFusion still performs validation and substitutes the validated parameter value back into the string If validation fails an error message i...

Page 196: ...UERYPARAM VALUE Course_ID CFSQLType CF_SQL_INTEGER CFQUERY CFOUTPUT QUERY getFirst P Course Number number br Description descript P CFOUTPUT BODY HTML This example shows the use of CFQUERYPARAM when i...

Page 197: ...t h3 CFSET LastName Peterson DELETE employees WHERE LastName Peterson Note that for string input you must specify the MAXLENGTH attribute for validation CFQUERY NAME getFirst DATASOURCE cfsnippets SEL...

Page 198: ...e Basic Security page Please refer to Administering ColdFusion Server for more information about securing ColdFusion tags CFREGISTRY topics CFREGISTRY ACTION GetAll CFREGISTRY ACTION Get CFREGISTRY AC...

Page 199: ...urn keys and values NAME Required The name of the record set to contain returned keys and values SORT Optional Sorts query column data case insensitive Sorts on Entry Type and Value columns as text Sp...

Page 200: ...e b WIDTH 10 TEXT RegQuery Type CFCOL HEADER B Value b WIDTH 35 TEXT RegQuery Value CFTABLE BODY HTML CFREGISTRY ACTION Get Use CFREGISTRY with the Get action to access a registry value and store it i...

Page 201: ...PE String VARIABLE RegValue H1 CFREGISTRY ACTION Get H1 CFOUTPUT P Java ClassPath value is RegValue CFOUTPUT BODY HTML CFREGISTRY ACTION Set Use CFREGISTRY with the Set action to add a registry key ad...

Page 202: ...ne here CFSET FileName dummy cfm CFREGISTRY ACTION Set BRANCH HKEY_LOCAL_MACHINE Software cflangref ENTRY LastCFM01 TYPE String VALUE FileName H1 CFREGISTRY ACTION Set H1 BODY HTML CFREGISTRY ACTION D...

Page 203: ...ed 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 HEAD BODY CFREGISTRY ACTION Delete BRANC...

Page 204: ...ion Administrator PASSWORD Optional The password that corresponds to a username required for database access Overrides the default settings for the data source in the ColdFusion Administrator FORMULA...

Page 205: ...P This example would run a report called monthlysales rpt and pass it an optional filter condition to show only the information for a certain subset of the report CFREPORT REPORT reports monthlysales...

Page 206: ...W HTML HEAD TITLE CFRETHROW Example TITLE HEAD BASEFONT FACE Arial Helvetica SIZE 2 BODY bgcolor FFFFD5 H3 CFRETHROW Example H3 Rethrow a DATABASE exception CFTRY CFTRY CFQUERY NAME myQuery1 DATASOURC...

Page 207: ...Chapter 1 ColdFusion Tags 183 CFCATCH CFTRY BODY HTML...

Page 208: ...se require CFSET statements For more information on CFScript see Developing Web Applications with ColdFusion Example This example shows the use of CFSCRIPT HTML HEAD TITLE CFSCRIPT Example TITLE HEAD...

Page 209: ...th fully qualified path Collection names are defined either through the CFCOLLECTION tag or in the ColdFusion Administrator Verity page Multiple ColdFusion collections can be specified in a comma sepa...

Page 210: ...s assumed Every search conducted with the CFSEARCH tag returns as part of the record set a number of result columns you can reference in your CFOUTPUT URL Returns the value of the URLPATH attribute de...

Page 211: ...DocSearch SCORE Example This example shows how to utilize CFSEARCH to search an existing populated collection HTML HEAD TITLE CFSEARCH Example TITLE HEAD BODY bgcolor silver H3 CFSEARCH Example H3 To...

Page 212: ...dsSearched 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 CF...

Page 213: ...A name for the form you are creating SIZE Optional Size of the drop down list box in number of entries REQUIRED Optional Yes or No If Yes a list element must be selected when the form is submitted De...

Page 214: ...oubling them for example PASSTHROUGH readonly YES CFSELECT supports the JavaScript onClick event in the same manner as the HTML INPUT tag CFSELECT NAME dept MESSAGE You must select a department name Q...

Page 215: ...ABLECAB 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 to see expande...

Page 216: ...efault JRun listens at port 8081 TIMEOUT Optional Specifies how many seconds JRun should wait for the servlet to complete before timing out WRITEOUTPUT Optional Boolean specifying if the text output o...

Page 217: ...reloaded by JRun if they change Example CFSERVLET CODE MyServletName JRUNPROXY 236 3 3 4 8083 TIMEOUT 300 WRITEOUTPUT YES CFSERVLETPARAM NAME Param1 VALUE Value1 CFSERVLETPARAM NAME Param2 VALUE Valu...

Page 218: ...al The value of a name value pair to be passed to the servlet as a parameter VARIABLE Optional The name of a ColdFusion variable See the Usage section for details on passing parameters The value of wh...

Page 219: ...value of the ColdFusion variable The VARIABLE attribute represents the name not the value of a ColdFusion variable This ability to directly share ColdFusion variables with a servlet is a powerful exte...

Page 220: ...me 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 BO...

Page 221: ...variable names In this example the variable name is itself a variable CFSET myvariable current_value CFSET myvariable 5 COM objects In this example a COM object is created A CFSET defines a value for...

Page 222: ...ddition CFSET can be used to pass variables from other pages such as this example which takes the url parameter Test from this link a href cfset cfm test CFOUTPUT URLEncodedFormat hey you get off of m...

Page 223: ...uctured exception handling introduces a subtle upwards incompatibility In 4 0 x an exception was handled by the first CFCATCH block that could handle that type of exception In 4 5 the structured excep...

Page 224: ...200 CFMLLanguageReference CFOUTPUT P Text within CFOUTPUT is always shown CFOUTPUT BODY HTML...

Page 225: ...ENT 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 CFSET a 100 CFSET b 99 CFSET c b...

Page 226: ...NVALIDATE script_name MESSAGE text ONERROR text HEIGHT integer WIDTH integer VSPACE integer HSPACE integer ALIGN alignment GROOVECOLOR color BGCOLOR color TEXTCOLOR color FONT font_name FONTSIZE integ...

Page 227: ...00 and so on VALUE Optional Determines the default slider setting Must be within the values specified in RANGE Defaults to the minimum value specified in RANGE ONVALIDATE Optional The name of a valid...

Page 228: ...the slider box moves Valid entries are black magenta cyan orange darkgray pink gray white lightgray yellow A hex value can be entered in the form GROOVECOLOR xxxxxx Where x is 0 9 or A F Use either t...

Page 229: ...s specified the following message appears B Browser must support Java to BR view ColdFusion Java Applets B Example This example shows how to use CFSLIDER within CFFORM HTML HEAD TITLE CFSLIDER Example...

Page 230: ...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...

Page 231: ...ta source that points to the database containing the stored procedure USERNAME Optional If specified USERNAME overrides the username value specified in the data source setup PASSWORD Optional If speci...

Page 232: ...a variable called CFSTOREDPROC ExecutionTime This variable contains the number of milliseconds that it took the stored procedure to execute Stored procedures represent an advanced feature found in hi...

Page 233: ...Y 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 RecordC...

Page 234: ...If a value matches the expression CFSWITCH executes the code between the CFCASE start and end tags Separate multiple values with a comma or an alternative delimiter as specified in the DELIMITERS par...

Page 235: ...ng CFSWITCH we can classify the output without using a CFLOOP construct CFOUTPUT QUERY GetEmployees CFSWITCH EXPRESSION Department each time the case is fulfilled the specific information is printed i...

Page 236: ...DER COLHEADERS STARTROW row_number CFTABLE QUERY Required The name of the CFQUERY from which you want to draw data MAXROWS Optional Specifies the maximum number of rows you want to display in the tabl...

Page 237: ...l Phone Department FROM Employees CFQUERY HTML HEAD TITLE CFTABLE Example TITLE HEAD BODY H3 CFTABLE Example H3 Note the use of the HTMLTABLE attribute to display the CFTABLE as an HTML table rather s...

Page 238: ...RROR text SIZE integer FONT font_name FONTSIZE integer ITALIC Yes No BOLD Yes No HEIGHT integer WIDTH integer VSPACE integer HSPACE integer ALIGN alignment BGCOLOR color TEXTCOLOR color MAXLENGTH inte...

Page 239: ...laced with a blank ONVALIDATE Optional The name of a valid JavaScript function used to validate user input The form object input object and input object value are passed to the specified routine which...

Page 240: ...ue Valid entries are Top Left Bottom Baseline TextTop AbsBottom Middle AbsMiddle Right BGCOLOR Optional Background color of the control Valid entries are black magenta cyan orange darkgray pink gray w...

Page 241: ...of CFTEXTINPUT HTML HEAD TITLE CFTEXTINPUT Example TITLE HEAD BODY bgcolor silver H3 CFTEXTINPUT Example H3 CFTEXTINPUT can be used to provide simple validation for text fields in CFFORM and to have...

Page 242: ...pe is the default CFCATCH type MESSAGE Optional A message that describes the exceptional event DETAIL Optional A detailed description of the event The ColdFusion server appends the position of the err...

Page 243: ...H3 CFTHROW Example H3 open a CFTRY block CFTRY define a condition upon which to throw the error CFIF NOT IsDefined URL myID throw the error CFTHROW MESSAGE ID is not defined CFIF perform the error ca...

Page 244: ...ad_Committed Repeatable_Read Serializable Usage A transaction block is created within these tags CFTRANSACTION queries to be executed CFTRANSACTION Within the transaction block you can commit a transa...

Page 245: ...ansaction in a CFTRY CFCATCH block in order to catch database errors and make commitment or rollback or the transaction contingent on the errors received CFTRY Initialize commitIt to Yes CFSET commitI...

Page 246: ...ption 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...

Page 247: ...ALIDATE script_name MESSAGE text ONERROR text FONT font FONTSIZE size ITALIC Yes No BOLD Yes No HEIGHT integer WIDTH integer VSPACE integer HSPACE integer ALIGN alignment BORDER Yes No HSCROLL Yes No...

Page 248: ...erwise MESSAGE Optional Message text to appear if validation fails ONERROR Optional The name of a valid JavaScript function you want to execute in the event of a failed validation FONT Optional Font n...

Page 249: ...appears B Browser must support Java to BR view ColdFusion Java Applets B Example This example shows the use of CFTREE in a CFFORM The query takes a list of employees and uses CFTREE and CFSELECT to d...

Page 250: ...Loop through the query to create each branch of the CFTREE H3 CFTREE Presentation of Data H3 H4 Click on the folders to drill down and reveal information H4 P CFTREEITEM is used to create the branche...

Page 251: ...pter 1 ColdFusion Tags 227 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 CFTR...

Page 252: ...is submitted When populating a CFTREE with data from a CFQUERY columns are specified in a comma separated list VALUE dept_id emp_id DISPLAY Optional The label for the tree item Default is VALUE When...

Page 253: ...l HTML HREF When populating a CFTREE with data from a CFQUERY HREFs can be specified in a comma separated list HREF http dept_server http emp_server TARGET Optional Target attribute for HREF URL When...

Page 254: ...LECT to present the contents of the query by column H3 CFSELECT Presentation of Data H3 H4 Click on an employee s last name and hit see information for this employee to see expanded information H4 CFS...

Page 255: ...ASROOT 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 Ph...

Page 256: ...atabase Template Security Object MissingInclude Expression Lock Custom_type Any default Usage You must code at least one CFCATCH tag within a CFTRY block Code CFCATCH tags at the end of the CFTRY bloc...

Page 257: ...s having the APPLICATION type in the CFTHROW tag that defines them The tags that throw an exception of TYPE TEMPLATE are CFINCLUDE CFMODULE and CFERROR An exception raised within a CFCATCH block canno...

Page 258: ...tom error message Note In order to see the tag stack displayed by TagContext use the ColdFusion Administrator to enable the CFML stack trace Under Debugging in the ColdFusion Administrator choose the...

Page 259: ...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 sCurre...

Page 260: ...er Using this option the ColdFusion Server computer must have Oracle 8 0 or greater client software installed Sybase11 Sybase System 11 native database driver Using this option the ColdFusion Server c...

Page 261: ...directory where the DBF files are located USERNAME Optional If specified USERNAME overrides the username value specified in the ODBC setup PASSWORD Optional If specified PASSWORD overrides the passwor...

Page 262: ...ts of this record and then click submit to use CFUPDATE and alter the database H3 P Course Number INPUT TYPE Text NAME number VALUE CFOUTPUT GetCourseInfo number CFOUTPUT P Course Description BR TEXTA...

Page 263: ...t of the operation This attribute is required for ACTION WDDX2CFML For all other actions if this attribute is not provided the result of the WDDX processing is outputted in the HTML stream TOPLEVELVAR...

Page 264: ...id Username from messages CFQUERY The recordset data is P CFOUTPUT QUERY q Message_ID Thread_ID Username br CFOUTPUT P Serialize data to WDDX format Serializing CFML data P CFWDDX ACTION cfml2wddx inp...

Page 265: ...provides complete descriptions of each function listed alphabetically Contents Alphabetical List of ColdFusion Functions 242 New Functions in ColdFusion 4 5 245 Array Functions 245 Authentication Fun...

Page 266: ...icData ArrayMin Compare Decrypt GetTempDirectory ArrayNew CompareNoCase DeleteClientVariable GetTempFile ArrayPrepend Cos DirectoryExists GetTemplatePath ArrayResize CreateDate DollarFormat GetTickCou...

Page 267: ...LSCurrencyFormat QueryAddColumn SpanExcluding JSStringFormat LSDateFormat QueryAddRow SpanIncluding LCase LSEuroCurrencyFormat QueryNew Sqr Left LSIsCurrency QuerySetCell StripCR Len LSIsDate QuotedV...

Page 268: ...244 CFMLLanguageReference Tan ToString URLEncodedFormat WriteOutput TimeFormat Trim Val XMLFormat ToBase64 UCase ValueList Year ToBinary URLDecode Week YesNoFormat...

Page 269: ...oBinary GetMetricData ToString IsBinary URLDecode JSStringFormat XMLFormat ArrayAppend ArrayMax ArraySum ArrayAvg ArrayMin ArraySwap ArrayClear ArrayNew ArrayToList ArrayDeleteAt ArrayPrepend IsArray...

Page 270: ...eODBCTime DayOfYear MonthAsString CreateTime DaysInMonth Now CreateTimeSpan DaysInYear ParseDateTime DateCompare FirstDayOfMonth Quarter DateConvert GetTimeZoneInfo Second DateDiff Hour Week DateForma...

Page 271: ...t LSTimeFormat FormatBaseN NumberFormat HTMLCodeFormat ParagraphFormat HTMLEditFormat TimeFormat LSCurrencyFormat YesNoFormat LSDateFormat DE IIf Evaluate SetVariable DateConvert LSIsNumeric GetLocale...

Page 272: ...ListRest ListDeleteAt ListSetAt ListFind ListSort ListFindNoCase ListToArray ListFirst ListValueCount ListGetAt ListValueCountNoCase ListInsertAt Abs BitXor Max ACos Ceiling Min ASin Cos Pi Atn Decre...

Page 273: ...ify ListValueCountNoCase ReplaceNoCase Compare LSParseCurrency REReplace CompareNoCase LSParseDateTime REReplaceNoCase DayOfWeekAsString LSParseEuroCurrency Reverse FormatBaseN LSParseNumber Right Fin...

Page 274: ...StructUpdate StructInsert DirectoryExists GetFileFromPath ExpandPath GetMetricData FileExists GetTempFile GetCurrentTemplatePath GetTemplatePath GetDirectoryFromPath SetProfileString CreateObject Get...

Page 275: ...Syntax Abs number number Any number Examples This example shows how to use the ABS function HTML HEAD TITLE Abs Example TITLE HEAD BODY BGCOLOR silver H3 Abs Example H3 P The absolute value of the fol...

Page 276: ...shows how to use ACos HTML HEAD TITLE ACos Example TITLE HEAD BODY BGCOLOR silver H3 ACos Example H3 output its arccosine value CFIF IsDefined FORM CosNum CFIF IsNumeric FORM CosNum CFIF FORM CosNum L...

Page 277: ...sion Functions 253 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...

Page 278: ...TITLE HEAD BODY H3 ArrayAppend Example H3 CFQUERY NAME GetEmployeeNames DATASOURCE cfsnippets SELECT FirstName LastName FROM Employees CFQUERY create an array CFSET myArray ArrayNew 1 set element one...

Page 279: ...F Form Submit is More CFSET FormElem ListLen Form Fieldnames CFIF CFIF HTML HEAD TITLE ArrayAvg Example TITLE HEAD BODY H3 ArrayAvg Example H3 P This example uses ArrayAvg to find the average of the n...

Page 280: ...yNew 1 CFSET Count 1 CFLOOP index ListItem list Form Fieldnames CFIF Left ListItem 3 is Num CFSET myNumberArray Count Val Evaluate number Count CFSET count IncrementValue Count CFIF CFLOOP CFIF Form S...

Page 281: ...TLE HEAD BODY H3 ArrayClear Example H3 create a new array CFSET MyArray ArrayNew 1 populate an element or two CFSET MyArray 1 Test CFSET MyArray 2 Other Test output the contents of the array P Your ar...

Page 282: ...also ArrayInsertAt Syntax ArrayDeleteAt array position array Name of the array in which you want to delete index data specified in position position Array position containing the data you want to dele...

Page 283: ...ant to insert the data specified in value value The value of the data you want to insert into the array Example This example shows ArrayInsertAt HTML HEAD TITLE ArrayInsertAt Example TITLE HEAD BODY H...

Page 284: ...y Example TITLE HEAD BODY H3 ArrayIsEmpty Example H3 create a new array CFSET MyArray ArrayNew 1 populate an element or two CFSET MyArray 1 Test CFSET MyArray 2 Other Test output the contents of the a...

Page 285: ...ets SELECT FirstName LastName FROM Employees CFQUERY create an array CFSET myArray ArrayNew 1 set element one to show where we are CFSET myArray 1 Test Value loop through the query and append these na...

Page 286: ...een submitted the following code creates an array and assigns the form fields to the first two elements in the array CFIF IsDefined FORM submit CFSET myNumberArray ArrayNew 1 CFSET myNumberArray 1 num...

Page 287: ...Chapter 2 ColdFusion Functions 263 INPUT TYPE text NAME number2 BR INPUT TYPE submit NAME submit VALUE Maximum Value FORM BODY HTML...

Page 288: ...submitted the following code creates an array and assigns the form fields to the first two elements in the array CFIF IsDefined FORM submit CFSET myNumberArray ArrayNew 1 CFSET myNumberArray 1 FORM nu...

Page 289: ...Chapter 2 ColdFusion Functions 265 INPUT TYPE text NAME number2 BR INPUT TYPE submit NAME submit VALUE Minimum Value FORM BODY HTML...

Page 290: ...ple H3 Make an array CFSET MyNewArray ArrayNew 1 Note that ArrayToList will not function properly if the Array has not been initialized with ArraySet CFSET temp ArraySet MyNewArray 1 6 set some elemen...

Page 291: ...E GetEmployeeNames DATASOURCE cfsnippets SELECT FirstName LastName FROM Employees CFQUERY create an array CFSET myArray ArrayNew 1 set element one to show where we are CFSET myArray 1 Test Value loop...

Page 292: ...ray minimum_size array Name of the array you want to resize minimum_size Minimum size of the specified array Example This example shows the use of ArrayResize HTML HEAD TITLE ArrayResize Example TITLE...

Page 293: ...nding position in the specified array If this value exceeds the array length elements are accordingly added to the array value The value you want to add to the range of elements in the specified array...

Page 294: ...to enforce asc Default Ascending sort order desc Descending sort order Example This example shows ArraySort HTML HEAD TITLE ArraySort Example TITLE HEAD BODY CFQUERY NAME GetEmployeeNames DATASOURCE c...

Page 295: ...ee if the form has been submitted the following code creates an array and assigns the form fields to the first two elements in the array CFIF IsDefined FORM submit CFSET myNumberArray ArrayNew 1 CFSET...

Page 296: ...272 CFMLLanguageReference INPUT TYPE text NAME number2 BR INPUT TYPE submit NAME submit VALUE Add FORM BODY HTML...

Page 297: ...tion2 array Name of the array whose elements you want to swap position1 Position of the first element you want to swap position2 Position of the second element you want to swap Example This example sh...

Page 298: ...LastName FROM Employees CFQUERY create an array CFSET myArray ArrayNew 1 loop through the query and append these names successively to the last element CFLOOP query GetEmployeeNames CFSET temp ArrayA...

Page 299: ...R silver H3 Asc Example H3 if the character string is not empty then output its ascii value CFIF IsDefined FORM charVals CFIF FORM charVals is not CFOUTPUT Left FORM charVals 1 Asc FORM charVals CFOUT...

Page 300: ...efined FORM SinNum CFIF IsNumeric FORM SinNum CFIF FORM SinNum LESS THAN OR EQUAL TO 1 CFIF FORM SinNum GREATER THAN OR EQUAL TO 1 ASin CFOUTPUT FORM SinNum CFOUTPUT CFOUTPUT Evaluate ASin FORM sinNum...

Page 301: ...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 TY...

Page 302: ...nippet shows how to use Atn HTML HEAD TITLE Atn Example TITLE HEAD BODY BGCOLOR silver H3 Atn Example H3 output its Atn value CFIF IsDefined FORM AtnNum CFIF IsNumeric FORM atnNum Atn CFOUTPUT FORM at...

Page 303: ...AuthenticatedUser IsAuthorized and CFAUTHENTICATE Syntax AuthenticatedContext Examples This snippet shows how to use AuthenticatedContext HTML HEAD TITLE AuthenticatedContext Example TITLE HEAD BODY...

Page 304: ...nticated AuthenticatedContext and CFAUTHENTICATE Syntax AuthenticatedUser Examples This snippet shows how to use AuthenticatedUser HTML HEAD TITLE AuthenticatedUser Example TITLE HEAD BODY BGCOLOR sil...

Page 305: ...2 Any long integers Usage Bit functions operate on 32 bit integers Examples This example shows BitAnd HTML HEAD TITLE BitAnd Example TITLE HEAD BODY H3 BitAnd Example H3 P Returns the bitwise AND of t...

Page 306: ...h of mask Usage Parameters start and length must be in the range from 0 to 31 Bit functions operate on 32 bit integers Examples This example shows BitMaskClear HTML HEAD TITLE BitMaskClear Example TIT...

Page 307: ...the length of mask Usage Parameters start and length must be in the range from 0 to 31 Bit functions operate on 32 bit integers Examples This example shows BitMaskRead HTML HEAD TITLE BitMaskRead Exa...

Page 308: ...nteger specifying the length of mask Usage Parameters start and length must be in the range from 0 to 31 Bit functions operate on 32 bit integers Examples This example shows BitMaskSet HTML HEAD TITLE...

Page 309: ...x BitNot number number Any long integer Usage Bit functions operate on 32 bit integers Examples This example shows BitNot HTML HEAD TITLE BitNot Example TITLE HEAD BODY H3 BitNot Example H3 Returns th...

Page 310: ...mber2 Any long integers Usage Bit functions operate on 32 bit integers Examples This example shows BitOr HTML HEAD TITLE BitOr Example TITLE HEAD BODY H3 BitOr Example H3 Returns the bitwise OR of two...

Page 311: ...d Usage Parameter count must be in the range from 0 to 31 Bit functions operate on 32 bit integers Examples This example shows BitSHLN HTML HEAD TITLE BitSHLN Example TITLE HEAD BODY H3 BitSHLN Exampl...

Page 312: ...be shifted Usage Parameter count must be in the range from 0 to 31 Bit functions operate on 32 bit integers Examples This example shows BitSHRN HTML HEAD TITLE BitSHRN Example TITLE HEAD BODY H3 BitS...

Page 313: ...Any long integers Usage Bit functions operate on 32 bit integers Examples This example shows BitXOr HTML HEAD TITLE BitXOr Example TITLE HEAD BODY H3 BitXOr Example H3 Returns the bitwise XOR of two...

Page 314: ...er number Any real number Examples This example illustrates the CF function ceiling HTML HEAD TITLE Ceiling Example TITLE HEAD BODY BGCOLOR silver H3 Ceiling Example H3 CFOUTPUT P The ceiling of 3 4 i...

Page 315: ...ne string Examples This code illustrates CHR HTML HEAD TITLE CHR Example TITLE HEAD BODY BGCOLOR silver H3 CHR Example H3 if the character string is not empty then output its CHR value CFIF IsDefined...

Page 316: ...stify CFPARAM NAME jstring DEFAULT CFIF IsDefined FORM justifyString CFSET jstring Cjustify FORM justifyString 35 CFIF HTML HEAD TITLE CJustify Example TITLE HEAD BODY BGCOLOR silver H3 CJustify H3 P...

Page 317: ...tion they appear listed in dictionary order Examples This example shows the use of Compare HTML HEAD TITLE Compare Example TITLE HEAD BODY BGCOLOR silver H3 Compare Example H3 P The compare function p...

Page 318: ...ce 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 TY...

Page 319: ...reNoCase Example TITLE HEAD BODY BGCOLOR silver H3 CompareNoCase Example H3 P The compare function performs a I case insensitive I comparison of two strings CFIF IsDefined FORM string1 CFSET compariso...

Page 320: ...Cos HTML HEAD TITLE Cos Example TITLE HEAD BODY BGCOLOR silver H3 Cos Example H3 output its Cos value CFIF IsDefined FORM CosNum CFIF IsNumeric FORM CosNum Cos CFOUTPUT FORM CosNum CFOUTPUT CFOUTPUT C...

Page 321: ...December day Number representing the day of the month ranging from 1 to 31 Usage CreateDate is a subset of CreateDateTime Time in the returned object is set to 00 00 00 Examples This example shows how...

Page 322: ...year FORM month FORM day 12 13 0 LI Built with CreateODBCDate DateFormat CreateODBCDate yourDate mmmm d yyyy LI Built with CreateODBCDateTime DateFormat CreateODBCDateTime yourDate d m yy UL CFOUTPUT...

Page 323: ...to 23 minute Number representing the minute ranging from 0 to 59 second Number representing the second ranging from 0 to 59 Usage Years from 0 to 29 are interpreted as 21st century values Years 30 to...

Page 324: ...createdatetime cfm METHOD POST P Please enter the year month and day in integer format for the date value you would like to view PRE Year CFINPUT TYPE Text NAME year VALUE 1998 VALIDATE integer REQUI...

Page 325: ...the type parameter there are several additional parameters you can use This table shows which parameters you can use with each object type Sections that follow describe these values and parameters in...

Page 326: ...name using UNC Universal Naming Convention or DNS Domain Name Server conventions in one of the following forms SERVER lanserver SERVER lanserver SERVER http www servername com SERVER www servername co...

Page 327: ...and method signatures User defined types for example structures are not supported JAVA CFOBJECT allows you to create and use JAVA objects and by extension EJB objects This support is currently only fo...

Page 328: ...e 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...

Page 329: ...face Arial Helvetica size 2 body bgcolor FFFFD5 H3 CreateODBCDate Example H3 CFIF IsDefined FORM year Your date value presented using different CF date functions CFSET yourDate CreateDateTime FORM yea...

Page 330: ...year VALUE 1998 VALIDATE integer REQUIRED Yes Month CFINPUT TYPE Text NAME month VALUE 6 RANGE 1 12 MESSAGE Please enter a month 1 12 VALIDATE integer REQUIRED Yes Day CFINPUT TYPE Text NAME day VALUE...

Page 331: ...use CreateDate CreateDateTime and createODBCDateTime HTML HEAD TITLE CreateODBCDateTime Example TITLE HEAD BODY BGCOLOR silver H3 CreateODBCDateTime Example H3 CFIF IsDefined FORM year Your date value...

Page 332: ...IDATE integer REQUIRED Yes Month CFINPUT TYPE Text NAME month VALUE 6 RANGE 1 12 MESSAGE Please enter a month 1 12 VALIDATE integer REQUIRED Yes Day CFINPUT TYPE Text NAME day VALUE 8 RANGE 1 31 MESSA...

Page 333: ...AD BODY BGCOLOR silver H3 CreateODBCTime Example H3 CFIF IsDefined FORM hour Your time value presented using different CF time functions CFSET yourTime CreateTime FORM hour FORM minute FORM second CFO...

Page 334: ...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 TYP...

Page 335: ...time variable is set to December 30 1899 Examples This code illustrates CreateTime and CreateODBCTime HTML HEAD TITLE CreateTime Example TITLE HEAD basefont face Arial Helvetica size 2 body bgcolor F...

Page 336: ...312 CFMLLanguageReference CFIF BODY HTML...

Page 337: ...nly be used to add and subtract from other date time objects or with the CFQUERY CACHEDWITHIN attribute Examples This example shows how to CreateTimeSpan CFIF IsDefined FORM year set variables for the...

Page 338: ...such as DCE RPC COM and CORBA With ColdFusion you can use UUIDs as primary table keys for applications where data is stored on a number of shared databases In such cases using numeric keys may cause...

Page 339: ...ates in the past date Date time object in the period from 100 AD to 9999 AD Years from 0 to 29 are interpreted as 21st century values Years 30 to 99 are interpreted as 20th century values Usage The da...

Page 340: ...CASE VALUE m months CFCASE CFCASE VALUE y days of year CFCASE CFCASE VALUE w weekdays CFCASE CFCASE VALUE ww weeks CFCASE CFCASE VALUE h hours CFCASE CFCASE VALUE n minutes CFCASE CFCASE VALUE s secon...

Page 341: ...The precision of the comparison This parameter can have any of the following values s precise to the second n precise to the minute h precise to the hour d precise to the day m precise to the month yy...

Page 342: ...CASE CFCASE VALUE 0 H3 CFOUTPUT DateFormat FORM date1 TimeFormat FORM date1 CFOUTPUT Date 1 is equal to CFOUTPUT DateFormat FORM date2 TimeFormat FORM date2 CFOUTPUT Date 2 H3 I The dates are equal I...

Page 343: ...PUT 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 Day OPTION option VALUE m Month OPTION optio...

Page 344: ...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 Examples This ex...

Page 345: ...POST P Please enter the year month and day in integer format for the date value you would like to view table cellspacing 2 cellpadding 2 border 0 tr td Year td td INPUT TYPE Text NAME year VALUE 1998...

Page 346: ...d 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 R...

Page 347: ...f Year y or Day d When datepart is Weekday w DateDiff returns the number of weeks between the two dates If date1 falls on a Monday DateDiff counts the number of Mondays until date2 It counts date2 but...

Page 348: ...ASE VALUE w weekdays CFCASE CFCASE VALUE ww weeks CFCASE CFCASE VALUE h hours CFCASE CFCASE VALUE n minutes CFCASE CFCASE VALUE s seconds CFCASE CFDEFAULTCASE years CFDEFAULTCASE CFSWITCH dateparts be...

Page 349: ...ding zero for years less than 10 yy Year as last two digits with a leading zero for years less than 10 yyyy Year represented by four digits gg Period era string Currently ignored but reserved for futu...

Page 350: ...le H3 P Today s date is CFOUTPUT todayDate CFOUTPUT P Using DateFormat we can display that date in a number of different ways CFOUTPUT UL LI DateFormat todayDate LI DateFormat todayDate mmm dd yyyy LI...

Page 351: ...sage Years from 0 to 29 are interpreted as 21st century values Years 30 to 99 are interpreted as 20th century values When passing a date time value as a string make sure it is enclosed in quotes Other...

Page 352: ...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 Da...

Page 353: ...rning undesired results Examples This example shows the value of the Day function HTML HEAD TITLE Day Example TITLE HEAD BODY BGCOLOR silver H3 Day Example H3 CFIF IsDefined FORM year More information...

Page 354: ...object returning undesired results Examples This example shows the value of the DayOfWeek function HTML HEAD TITLE DayofWeek Example TITLE HEAD BODY BGCOLOR silver H3 DayOfWeek Example H3 CFIF IsDefi...

Page 355: ...hows the value of the dayOfWeekAsString function HTML HEAD TITLE DayOfWeekAsString Example TITLE HEAD BODY BGCOLOR silver H3 DayOfWeekAsString Example H3 CFIF IsDefined FORM year More information abou...

Page 356: ...returning undesired results Examples shows the value of the DayOfYear function HTML HEAD TITLE DayOfYear Example TITLE HEAD BODY BGCOLOR silver H3 DayOfYear Example H3 CFIF IsDefined FORM year More in...

Page 357: ...g undesired results Examples shows the value of the DaysInMonth function HTML HEAD TITLE DaysInMonth Example TITLE HEAD BODY BGCOLOR silver H3 DaysInMonth Example H3 CFIF IsDefined FORM year More info...

Page 358: ...preted as a number representation of a date time object returning undesired results Examples shows the value of the DaysInYear function HTML HEAD TITLE DaysInYear Example TITLE HEAD BODY BGCOLOR silve...

Page 359: ...E DE Example TITLE HEAD BODY BGCOLOR silver H3 DE Example H3 CFIF IsDefined FORM myExpression H3 The Expression Result H3 CFTRY Evaluate the expression CFSET myExpression Evaluate FORM myExpression Us...

Page 360: ...cimalFormat number number Number being formatted Examples This code shows the use of DecimalFormat HTML HEAD TITLE DecimalFormat Example TITLE HEAD BODY BGCOLOR silver H3 DecimalFormat Function H3 P R...

Page 361: ...emented Examples This shows the use of DecrementValue HTML HEAD TITLE DecrementValue Example TITLE HEAD BODY H3 DecrementValue Example H3 P Returns the integer part of a number decremented by one P De...

Page 362: ...own string and a key of your own choosing and seeing the results CFIF IsDefined FORM myString CFSET string FORM myString CFSET key FORM myKey CFSET encrypted encrypt string key CFSET decrypted decrypt...

Page 363: ...TML HEAD TITLE DeleteClientVariable Example TITLE HEAD BODY this example is view only H3 DeleteClientVariable Example H3 P This view only example deletes a client variable called User_ID if it exists...

Page 364: ...oryExists Example TITLE HEAD BODY BGCOLOR silver H3 DirectoryExists Example H3 CFSET thisPath ExpandPath CFSET thisDirectory GetDirectoryFromPath thisPath CFSET thisDirectory Left thisDirectory Evalua...

Page 365: ...ML HEAD TITLE DollarFormat Example TITLE HEAD BODY BGCOLOR silver H3 DollarFormat Example H3 CFLOOP from 8 to 50 index counter CFSET full counter CFSET quarter Evaluate counter 1 4 CFSET half Evaluate...

Page 366: ...of your own choosing and seeing the results CFIF IsDefined FORM myString CFSET string FORM myString CFSET key FORM myKey CFSET encrypted encrypt string key CFSET decrypted decrypt encrypted key CFOUTP...

Page 367: ...more complicated to write because they are inside a string In particular if the string expression is double quoted double quotes inside the expression must be escaped Examples This shows the use of D...

Page 368: ...ber BR FORM number raised to the E power exp FORM number CFIF FORM number LTE 0 BR You must enter a positive real number to see the natural logarithm of that number CFELSE BR The natural logarithm of...

Page 369: ...h ExpandPath converts relative directory references and to an absolute path The function throws an error if this argument or the resulting absolute path is invalid Examples This example shows the use...

Page 370: ...of FileExists HTML HEAD TITLE FileExists Example TITLE HEAD BODY BGCOLOR silver H3 FileExists Example H3 CFSET thisPath ExpandPath CFSET thisDirectory GetDirectoryFromPath thisPath CFOUTPUT The curre...

Page 371: ...sought string String being searched start Starting position for the search Examples depending upon the action desired perform different function CFSWITCH EXPRESSION tag CFCASE VALUE find CFSET TheActi...

Page 372: ...g being sought string String being searched start Starting position for the search Examples depending upon the action desired perform different function CFSWITCH EXPRESSION tag CFCASE VALUE find CFSET...

Page 373: ...t string String being searched start Starting position for the search Examples depending upon the action desired perform different function CFSWITCH EXPRESSION tag CFCASE VALUE find CFSET TheAction Fi...

Page 374: ...erpreted as 20th century values 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 und...

Page 375: ...ber number Any number Examples This example shows the use of Fix HTML HEAD TITLE Fix Example TITLE HEAD BODY H3 Fix Example H3 P Fix returns the closest integer less than the number if the number is g...

Page 376: ...er to a string in the base specified by Radix P CFOUTPUT BR FormatBaseN 10 2 FormatBaseN 10 2 BR FormatBaseN 1024 16 FormatBaseN 1024 16 BR FormatBaseN 125 10 FormatBaseN 125 10 BR FormatBaseN 10 75 2...

Page 377: ...Required Specifies the ancestor tag name for which the function returns data instancenumber Optional Specifies the number of ancestor levels to jump before returning data The default is 1 Example Thi...

Page 378: ...example illustrates usage of the GetBaseTagList function This is typically used in custom tags CFIF thisTag executionMode is start Get the tag context stack The list will look something like CFIF MYTA...

Page 379: ...ePath FileExists and ExpandPath Syntax GetBaseTemplatePath Example This example uses GetBaseTemplatePath to show the template path of the current page HTML HEAD TITLE GetBaseTemplatePath Example TITLE...

Page 380: ...xample deletes a client variable called User_ID if it exists in the list of client variables returned by GetClientVariablesList P This example requires the existance of an Application cfm file and tha...

Page 381: ...uded template if the call is made from a template included with a CFINCLUDE tag whereas GetBaseTemplatePath returns the template path of the top level template even when the call to GetBaseTemplatePat...

Page 382: ...ath CFOUTPUT The current directory is GetDirectoryFromPath thisPath CFIF IsDefined FORM yourFile CFIF FORM yourFile is not CFSET yourFile FORM yourFile CFIF FileExists ExpandPath yourfile P Your file...

Page 383: ...The current directory is GetDirectoryFromPath thisPath CFIF IsDefined FORM yourFile CFIF FORM yourFile is not CFSET yourFile FORM yourFile CFIF FileExists ExpandPath yourfile P Your file exists in thi...

Page 384: ...ns 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 CF...

Page 385: ...st of the locales that ColdFusion and the operating system support GetLocale will return an entry from that list SetLocale will fail if called with a locale name not on that list Example This example...

Page 386: ...ned 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...

Page 387: ...Data monitor_name monitor_name The name of the performance monitor On Windows NT the performance monitor is PerfMonitor On UNIX it is CFStat Usage On Windows NT the function returns a ColdFusion struc...

Page 388: ...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...

Page 389: ...ion The section of the initialization file from which you would like to extract information entry The name of the value that you would like to see Example This example uses GetProfileString to set the...

Page 390: ...UT 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 NAME IniPat...

Page 391: ...the directory it returns under your account See also GetTempFile Syntax GetTempDirectory Example This example uses GetTempDirectory to find the temporary directory and GetTempFile to place a dummy fil...

Page 392: ...orary file to be created in the directory specified by dir Examples This example uses GetTempDirectory to find the temporary directory and GetTempFile to place a dummy file in that directory HTML HEAD...

Page 393: ...d should be used in place of it in all code written after the release of ColdFusion 4 0 See also GetBaseTemplatePath FileExists and ExpandPath Syntax GetTemplatePath Example This example uses GetTempl...

Page 394: ...s between the results of GetTickCount at specified points during page processing Examples This example calls the GetTickCount function to track execution time HTML BODY Setup timing test CFSET iterati...

Page 395: ...will always be zero However for some countries that do not land exactly on the hour offset the number will be between 0 and 60 For example standard time in Adelaide Australia has an offset of 9 hours...

Page 396: ...sets of delimiters Examples This example shows the use of GetToken HTML HEAD TITLE GetToken Example TITLE HEAD BODY BGCOLOR silver H3 GetToken Example H3 CFIF IsDefined FORM yourString set delimiter...

Page 397: ...ury values 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 Exampl...

Page 398: ...ML 3 2 Example This example shows the use of HTMLCodeFormat and HTMLEditFormat HTML HEAD TITLE HTMLCodeFormat Example TITLE HEAD BODY BGCOLOR silver H3 HTMLCodeFormat Example H3 FORM ACTION HTMLcodefo...

Page 399: ...HTTP tag to get the file content represented by urladdress CFHTTP URL urladdress METHOD GET RESOLVEURL YES CFHTTP CFELSE the first time through retrieve a URL that we know exists CFHTTP URL http local...

Page 400: ...d string This can cause unpredictable results when performing certain string functions Left Right and Mid for example against the expanded string Example This example shows the use of HTMLCodeFormat a...

Page 401: ...Address FORM urladdress CFIF now use the CFHTTP tag to get the file content represented by urladdress CFHTTP URL urladdress METHOD GET RESOLVEURL YES CFHTTP CFELSE the first time through retrieve a UR...

Page 402: ...ge The IIf function is a shortcut for the following construct CFIF condition CFSET result Evaluate string_expression1 CFELSE CFSET result Evaluate string_expression2 CFIF returning result The expressi...

Page 403: ...the original condition IsDefined LocalVar CFOUTPUT IIf IsDefined LocalVar DE LocalVar DE The variable is not defined CFOUTPUT The error message would be Error resolving parameter LOCALVAR The DE funct...

Page 404: ...380 CFMLLanguageReference DE It is morning CFOUTPUT P BODY HTML...

Page 405: ...emented Examples This shows the use of IncrementValue HTML HEAD TITLE IncrementValue Example TITLE HEAD BODY H3 IncrementValue Example H3 P Returns the integer part of a number Incremented by one P In...

Page 406: ...AD BODY H3 InputBaseN Example H3 P FormatBaseN converts a number to a string in the base specified by Radix P CFOUTPUT BR FormatBaseN 10 2 FormatBaseN 10 2 BR FormatBaseN 1024 16 FormatBaseN 1024 16 B...

Page 407: ...s This example shows the use of Insert HTML HEAD TITLE Insert Example TITLE HEAD BODY BGCOLOR silver H3 Insert Example H3 CFIF IsDefined FORM myString if the position is longer than the length of the...

Page 408: ...l number you want to round down to an integer Examples This example shows the use of Int HTML HEAD TITLE Int Example TITLE HEAD BODY BGCOLOR silver H3 Int Example H3 P Int returns the closest integer...

Page 409: ...d dimension Examples This example shows IsArray HTML HEAD TITLE IsArray Example TITLE HEAD BODY H3 IsArray Example H3 Make an array CFSET MyNewArray ArrayNew 1 set some elements CFSET MyNewArray 1 ele...

Page 410: ...Syntax IsAuthenticated security context name security context name The security context name Example This example calls the IsAuthenticated function This code is from an Application cfm file CFIF NOT...

Page 411: ...tion CustomTag UserObject resourcename String specifying the name of the resource The value specified varies depending on the resource type Resourcename is the actual resource that is protected not to...

Page 412: ...d to select information from the Orders data source CFIF IsAuthorized DATASOURCE Orders select CFQUERY NAME GetList datasource Orders SELECT FROM Orders CFQUERY CFOUTPUT QUERY GetList Authorization Su...

Page 413: ...Chapter 2 ColdFusion Functions 389 Customer BalanceDue BR CFOUTPUT CFIF BODY HTML...

Page 414: ...has passed this page the value of the variable data_var which can hold either character data or binary data This example checks to see whether data_var is binary and if it is it converts the binary da...

Page 415: ...D BODY BGCOLOR silver H3 IsBoolean Example H3 CFIF IsDefined FORM theTestValue CFIF IsBoolean FORM theTestValue H3 The expression CFOUTPUT DE FORM theTestValue CFOUTPUT is Boolean H3 CFELSE H3 The exp...

Page 416: ...0th century values Examples This example shows the use of IsDate HTML HEAD TITLE IsDate Example TITLE HEAD BODY BGCOLOR silver H3 IsDate Example H3 CFIF IsDefined FORM theTestValue CFIF IsDate FORM th...

Page 417: ...LSE if debugging mode is disabled Syntax IsDebugMode Examples This example shows the use of IsDebugMode HTML HEAD TITLE IsDebugMode Example TITLE HEAD BODY BGCOLOR silver H3 IsDebugMode Example H3 CFI...

Page 418: ...want to test for This value must always be enclosed in quotation marks Example This example shows the use of IsDefined HTML HEAD TITLE IsDefined Example TITLE HEAD BODY BGCOLOR silver H3 IsDefined Ex...

Page 419: ...H3 IsLeapYear Example H3 CFIF IsDefined FORM theTestValue CFIF IsLeapYear FORM theTestValue H3 The year value CFOUTPUT DE FORM theTestValue CFOUTPUT is a Leap Year H3 CFELSE H3 The year value CFOUTPU...

Page 420: ...Numeric Example H3 CFIF IsDefined FORM theTestValue CFIF IsNumeric FORM theTestValue H3 The string CFOUTPUT DE FORM theTestValue CFOUTPUT can be converted to a number H3 CFELSE H3 The string CFOUTPUT...

Page 421: ...re formatted Date value CFIF IsNumeric FORM theTestValue or IsDate FORM theTestValue if this value is a numericDate value then pass CFIF IsNumericDate FORM theTestValue H3 The string CFOUTPUT DE FORM...

Page 422: ...bject resourcename String specifying the name of the resource Resourcename is the actual resource that is protected not to be confused with the rule name which you specify in the ColdFusion Administra...

Page 423: ...f a resource is explicitly protected with a rule you must use the IsProtected function Example This example calls the IsProtected function The following code checks to see if the Orders data source is...

Page 424: ...IsAuthorized DATASOURCE Orders select CFQUERY NAME GetList datasource Orders SELECT FROM Orders CFQUERY CFOUTPUT QUERY GetList Authorization Succeeded Order information follows Customer BalanceDue BR...

Page 425: ...query is run the value of GetEmployees is CFOUTPUT getEmployees CFOUTPUT CFIF IsSimpleValue getEmployees P getEmployees is currently a simple value CFIF make a query on the snippets datasource RY NAME...

Page 426: ...ow P Before the query is run the value of GetEmployees is CFOUTPUT getEmployees CFOUTPUT CFIF IsSimpleValue getEmployees P getEmployees is currently a simple value CFIF make a query on the snippets da...

Page 427: ...ployee structure the EMPINFO attribute In UNIX you must also add the Emp_ID CFSWITCH EXPRESSION ThisTag ExecutionMode CFCASE VALUE start CFIF IsStruct attributes EMPINFO CFOUTPUT Error Invalid data CF...

Page 428: ...ly into JavaScript Examples This example illustrates use of the JSStringFormat function HTML HEAD TITLE JSStringFormat TITLE HEAD BODY H3 JSStringFormat H3 CFSET stringValue An example string value wi...

Page 429: ...OR silver H3 LCase Example H3 CFIF IsDefined FORM sampleText CFIF FORM sampleText is not P Your text CFOUTPUT FORM sampleText CFOUTPUT returned in lowercase is CFOUTPUT LCase FORM sampleText CFOUTPUT...

Page 430: ...ple H3 CFIF IsDefined Form MyText if len is 0 then err CFIF Len FORM myText is not 0 CFIF Len FORM myText LTE FORM RemoveChars P Your string CFOUTPUT FORM myText CFOUTPUT only has CFOUTPUT Len FORM my...

Page 431: ...le TITLE HEAD BODY BGCOLOR silver H3 Len Example H3 CFIF IsDefined Form MyText if len is 0 then err CFIF Len FORM myText is not 0 P Your string CFOUTPUT FORM myText CFOUTPUT has CFOUTPUT Len FORM myTe...

Page 432: ...s on strings that are delimited by the conjunction comma space as is common in HTTP header strings such as the COOKIE header we recommend that you specify delimiters to include both comma and space be...

Page 433: ...ple shows ListChangeDelims HTML HEAD TITLE ListChangeDelims Example TITLE HEAD BODY H3 ListChangeDelims Example H3 P ListChangeDelims allows you to change the delimiters used in a list First query to...

Page 434: ...ind HTML HEAD TITLE ListContains TITLE HEAD BODY Create a list composed of the items one two three CFSET aList one CFSET aList ListAppend aList two CFSET aList ListAppend aList three P Here is the lis...

Page 435: ...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 BR ListFind BR CFOUT...

Page 436: ...rs Set of delimiters used in list Examples This example shows ListContainsNoCase HTML HEAD TITLE ListContainsNoCase Example TITLE HEAD BODY BGCOLOR silver H3 ListContainsNoCase Example H3 CFIF IsDefin...

Page 437: ...This example shows ListDeleteAt HTML HEAD TITLE ListDeleteAt Example TITLE HEAD BODY H3 ListDeleteAt Example H3 First query to get some values for our list CFQUERY NAME GetParkInfo DATASOURCE cfsnippe...

Page 438: ...LE ListFind TITLE HEAD BODY Create a list composed of the items one two three CFSET aList one CFSET aList ListAppend aList two CFSET aList ListAppend aList three P Here is the list B CFOUTPUT aList CF...

Page 439: ...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 BR ListFind BR CFOUT...

Page 440: ...s example uses ListFind and ListFindNoCase to see if a substring exists in a list CFSET temp ListFindNoCase myList FORM myString CFIF temp is 0 H3 An employee with that exact last name was not found H...

Page 441: ...TML HEAD TITLE ListFirst Example TITLE HEAD BODY H3 ListFirst Example H3 Find a list of users who wrote messages CFQUERY NAME GetMessageUser DATASOURCE cfsnippets SELECT Username Subject Posted FROM M...

Page 442: ...r 1 not 0 Examples This example shows ListGetAt and ListLen HTML HEAD TITLE ListGetAt Example TITLE HEAD BODY H3 ListGetAt Example H3 Find a list of users who wrote messages CFQUERY NAME GetMessageUse...

Page 443: ...o the first delimiter in the string or comma if delimiters was omitted If you intend to use list functions on strings that are delimited by the conjunction comma space as is common in HTTP header stri...

Page 444: ...TLE ListLast Example TITLE HEAD BODY H3 ListLast Example H3 Find a list of users who wrote messages CFQUERY NAME GetMessageUser DATASOURCE cfsnippets SELECT Username Subject Posted FROM Messages CFQUE...

Page 445: ...Example TITLE HEAD BODY H3 ListLen Example H3 Find a list of users who wrote messages CFQUERY NAME GetMessageUser DATASOURCE cfsnippets SELECT Username Subject Posted FROM Messages CFQUERY CFSET temp...

Page 446: ...ma if delimiters was omitted If you intend to use list functions on strings that are delimited by the conjunction comma space as is common in HTTP header strings such as the COOKIE header we recommend...

Page 447: ...f you specify CHAR the function qualifiers only items comprised of alphabetic characters it does not qualify numeric items Usage The new list may not preserve all of the delimiters in the previous lis...

Page 448: ...le quotes around each full name CFSET qualifiedList1 ListQualify myList CHAR output the array as a list CFOUTPUT P The contents of the qualified list are as follows P P qualifiedList1 P CFOUTPUT show...

Page 449: ...First ListLast and ListRest HTML HEAD TITLE ListRest Example TITLE HEAD BODY H3 ListRest Example H3 Find a list of users who wrote messages CFQUERY NAME GetMessageUser DATASOURCE cfsnippets SELECT Use...

Page 450: ...omitted If you intend to use list functions on strings that are delimited by the conjunction comma space as is common in HTTP header strings such as the COOKIE header we recommend that you specify del...

Page 451: ...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...

Page 452: ...red sort_order The order to be followed You can specify any of the following Asc Default Ascending sort order Desc Descending sort order delimiter Specify the character s used to delimit elements in t...

Page 453: ...a list that must be sorted numerically since it contains both negative and positive numbers as well as decimal numbers P CFSET sortedNums2 ListSort 23 75 34 471 100 9745 Numeric ASC CFOUTPUT sortedNu...

Page 454: ...e character s used to delimit elements in the list Default is comma Example This example shows ListToArray HTML HEAD TITLE ListToArray Example TITLE HEAD BODY H3 ListToArray Example H3 Find a list of...

Page 455: ...he list The default is a comma Example This example uses ListValueCount to see how many employees are in a department HTML HEAD TITLE ListValueCount Example TITLE HEAD body bgcolor FFFFD5 CFQUERY NAME...

Page 456: ...ist ValueList SearchByDepartment Department CFSET numberInDepartment ListValueCount myList FORM departmentName CFIF numberInDepartment is 0 H3 There are no employees in CFOUTPUT FORM departmentName CF...

Page 457: ...e default is a comma Example This example uses ListValueCountNoCase to see how many employees are in a department HTML HEAD TITLE ListValueCountNoCase Example TITLE HEAD body bgcolor FFFFD5 CFQUERY NA...

Page 458: ...ist ValueList SearchByDepartment Department CFSET numberInDepartment ListValueCountNoCase myList FORM departmentName CFIF numberInDepartment is 0 H3 There are no employees in CFOUTPUT FORM departmentN...

Page 459: ...use LJustify CFPARAM NAME jstring DEFAULT CFIF IsDefined FORM justifyString CFSET jstring Ljustify FORM justifyString 35 CFIF HTML HEAD TITLE LJustify Example TITLE HEAD BODY BGCOLOR silver H3 LJusti...

Page 460: ...number CFIF FORM number LTE 0 BR You must enter a positive real number to see the natural logarithm of that number CFELSE BR The natural logarithm of FORM number log FORM number CFIF CFIF FORM number...

Page 461: ...0 BR You must enter a positive real number to see the natural logarithm of that number CFELSE BR The natural logarithm of FORM number log FORM number CFIF CFIF FORM number LTE 0 BR You must enter a po...

Page 462: ...ut for some of the locales supported by ColdFusion in each of the format types local international and none Locale Format Type Output Dutch Belgian Local 100 000 00 BF International BEF100 000 00 None...

Page 463: ...000 00 German Standard Local 100 000 00 DM International DEM100 000 00 None 100 000 00 German Swiss Local SFr 100 000 00 International CHF100 000 00 None 100 000 00 Italian Standard Local L 10 000 00...

Page 464: ...DELIMITERS CFSET oldlocale SetLocale locale CFOUTPUT P B I locale I B BR Local LSCurrencyFormat 100000 local BR International LSCurrencyFormat 100000 international BR None LSCurrencyFormat 100000 none...

Page 465: ...f the week as its full name m Month as digits with no leading zero for single digit months mm Month as digits with a leading zero for single digit months mmm Month as a three letter abbreviation mmmm...

Page 466: ...ales 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 N...

Page 467: ...y the Euro symbol only on Euro enabled computers such as Windows NT 4 0 SP4 that have Euro enabled fonts installed This function is similar to LSCurrencyFormat except that LSEuroCurrencyFormat display...

Page 468: ...International EUR100 000 00 None 100 000 00 French Canadian Local 100 000 00 International EUR100 000 00 None 100 000 00 French Standard Local 100 000 00 International EUR100 000 00 None 100 000 00 F...

Page 469: ...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 100 000 00 International EUR100 000 00 None...

Page 470: ...les 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 LSE...

Page 471: ...mple TITLE HEAD BODY BGCOLOR silver H3 LSIsCurrency Example H3 CFIF IsDefined FORM locale if locale is defined set locale to that entry CFSET NewLocale SetLocale FORM locale P Is the value CFOUTPUT FO...

Page 472: ...TML HEAD TITLE LSIsDate Example TITLE HEAD BODY BGCOLOR silver H3 LSIsDate Example H3 CFIF IsDefined FORM locale if locale is defined set locale to that entry CFSET NewLocale SetLocale FORM locale P I...

Page 473: ...ML HEAD TITLE LSIsNumeric Example TITLE HEAD BODY BGCOLOR silver H3 LSIsNumeric Example H3 CFIF IsDefined FORM locale if locale is defined set locale to that entry CFSET NewLocale SetLocale FORM local...

Page 474: ...9 Optional digit placeholder Same as _ but shows decimal places more clearly Specifies the location of a mandatory decimal point 0 Located to the left or right of a mandatory decimal point to force p...

Page 475: ...cters This positioning idea can also be used to show where to place the minus sign for negative numbers There are four possible positions for any code character far left near left near right and far r...

Page 476: ...DEX locale DELIMITERS CFSET oldlocale SetLocale locale CFOUTPUT P B I locale I B BR LSNumberFormat 1234 5678 _________ BR LSNumberFormat 1234 5678 _________ ___ BR LSNumberFormat 1234 5678 _________ B...

Page 477: ...cales supported by ColdFusion in each of the format types local international and none Currency Output by Locale Locale Format Type Output Dutch Belgian Local 100 000 00 BF International BEF100 000 00...

Page 478: ...onal DEM100 000 00 None 100 000 00 German Swiss Local SFr 100 000 00 International CHF100 000 00 None 100 000 00 Italian Standard Local L 10 000 000 International ITL10 000 000 None 10 000 000 Italian...

Page 479: ...T oldlocale SetLocale locale CFOUTPUT P B I locale I B BR Local LSCurrencyFormat 123456 local BR Currency Number LSParseCurrency LSCurrencyFormat 123456 local BR International LSCurrencyFormat 123456...

Page 480: ...a year in the date you should specify the full year If the date is formatted for a locale other than the English US locale add or subtract the conversion time depending on the locale LSParseDateTime...

Page 481: ...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 LSDateForm...

Page 482: ...t that LSParseEuroCurrency parses only the Euro currency symbol or the international Euro sign EUR not other currency symbols such as the dollar sign or the pound sign Example This example shows LSPar...

Page 483: ...Chapter 2 ColdFusion Functions 459 CFOUTPUT CFLOOP BODY HTML...

Page 484: ...op through a list of possible locales and show number values CFLOOP LIST Server Coldfusion SupportedLocales INDEX locale DELIMITERS CFSET oldlocale SetLocale locale CFOUTPUT P B I locale I B BR LSNumb...

Page 485: ...g zero for single digit minutes mm Minutes with a leading zero for single digit minutes s Seconds with no leading zero for single digit seconds ss Seconds with a leading zero for single digit seconds...

Page 486: ...ITERS 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...

Page 487: ...TML HEAD TITLE LTrim Example TITLE HEAD BODY BGCOLOR silver H3 LTrim Example H3 CFIF IsDefined FORM myText CFOUTPUT PRE Your string FORM myText Your string Ltrim FORM myText left trimmed PRE CFOUTPUT...

Page 488: ...um1 CFIF IsNumeric FORM myNum1 and IsNumeric FORM myNum2 P The maximum of the two numbers is CFOUTPUT Max FORM myNum1 FORM myNum2 CFOUTPUT P The minimum of the two numbers is CFOUTPUT Min FORM myNum1...

Page 489: ...ple H3 CFIF IsDefined Form MyText if len is 0 then err CFIF Len FORM myText is not 0 CFIF Len FORM myText LTE FORM RemoveChars P Your string CFOUTPUT FORM myText cFOUTPUT only has CFOUTPUT Len FORM my...

Page 490: ...Num1 CFIF IsNumeric FORM myNum1 and IsNumeric FORM myNum2 P The maximum of the two numbers is CFOUTPUT Max FORM myNum1 FORM myNum2 CFOUTPUT P The minimum of the two numbers is CFOUTPUT Min FORM myNum1...

Page 491: ...values 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 Examples...

Page 492: ...sults Examples shows the value of the Month function HTML HEAD TITLE Month Example TITLE HEAD BODY BGCOLOR silver H3 Month Example H3 CFIF IsDefined FORM year More information about your date CFSET yo...

Page 493: ...tring Example H3 CFIF IsDefined FORM year More information about your date CFSET yourDate CreateDate FORM year FORM month FORM day CFOUTPUT P Your date DateFormat yourDate BR It is DayofWeekAsString D...

Page 494: ...Part 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 P The current date tim...

Page 495: ...re clearly Specifies the location of a mandatory decimal point 0 Located to the left or right of a mandatory decimal point to force padding with zeros Places parentheses around the mask if the number...

Page 496: ...n just to the left of the digits in the formatted number In all examples below the numbers under the masks and the formatted output are used to clearly show the positions of characters This positionin...

Page 497: ...H3 NumberFormat Example H3 CFLOOP FROM 1000 TO 1020 INDEX counter CFSET CounterRoot2 Evaluate counter sqr 2 Show the result in default format adding the comma for the thousands place and also in custo...

Page 498: ...Example TITLE HEAD BODY BGCOLOR silver H3 ParagraphFormat Example H3 P Enter some text into this textarea and see it returned as HTML CFIF IsDefined FORM myTextArea P Your text area formatted P CFOUT...

Page 499: ...Y BGCOLOR silver H3 ParameterExists Example H3 CFIF ParameterExists FORM myString P Using ParameterExists we have shown that the FORM field myString now exists However this function is provided for ba...

Page 500: ...values Both ParseDateTime and CreateDateTime are provided primarily to increase the readability of code in compound expressions Years from 0 to 29 are interpreted as 21st century values Years 30 to 99...

Page 501: ...ter 2 ColdFusion Functions 477 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 CFOUT...

Page 502: ...t 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 H3 Pi Example H3 Returns the number CFOUTPUT NumberFormat P...

Page 503: ...erveSingleQuotes Example H3 P This is a useful function for creating lists of information to return from a query In the following example we pick the list of Centers in Suisun San Francisco and San Di...

Page 504: ...interpreted as 20th century values 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...

Page 505: ...ou can add columns to any type of query object such as queries retrieved with CFQUERY or queries created with QueryNew The only type of query that you cannot use QueryAddColumn on is a cached query Th...

Page 506: ...add a second column to the query CFSET nColumnNumber2 QueryAddColumn myQuery FineCuisine FineCuisineArray create a third array CFSET HealthFoodArray ArrayNew 1 CFSET HealthFoodArray 1 Bean Curd CFSET...

Page 507: ...TML HEAD TITLE QueryAddRow Example TITLE HEAD BODY H3 QueryAddRow Example H3 start by making a query CFQUERY NAME GetCourses DATASOURCE cfsnippets SELECT Course_ID Number Descript FROM Courses CFQUERY...

Page 508: ...AD TITLE QueryNew Example TITLE HEAD BODY H3 QueryNew Example H3 P We will construct a new query with two rows CFSET myQuery QueryNew name address phone make some rows in the query CFSET newRow QueryA...

Page 509: ...xample This example shows the use of QueryAddRow and QuerySetCell HTML HEAD TITLE QuerySetCell Example TITLE HEAD BODY H3 QuerySetCell Example H3 start by making a query CFQUERY NAME GetCourses DATASO...

Page 510: ...erence 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...

Page 511: ...EAD TITLE QuotedValueList Example TITLE HEAD BODY H3 QuotedValueList Example H3 use the contents of one query to create another dynamically CFSET List BIOL CHEM first get the department ids in our lis...

Page 512: ...Usage To ensure even greater randomness call Randomize before calling Rand Example This example shows the use of Rand HTML HEAD TITLE Rand Example TITLE HEAD BODY BGCOLOR silver H3 Rand Example H3 P...

Page 513: ...s This example shows the use of Randomize HTML HEAD TITLE Randomize Example TITLE HEAD BODY BGCOLOR silver H3 Randomize Example H3 P Call Randomize to seed the random number generator This helps to en...

Page 514: ...Range Example TITLE HEAD BODY BGCOLOR silver H3 RandRange Example H3 P RandRange returns an integer between two specified integers CFIF IsDefined FORM myInt P RandRange returned CFOUTPUT RandRange FOR...

Page 515: ...of the first substring that matches the criteria of the search You can retrieve the position and length of the matching subexpression by using the keys pos and len If there are no occurrences of the r...

Page 516: ...a c abcaaccdd CFOUTPUT P P REFind upper abcaacCDD CFOUTPUT REFind upper abcaacCDD CFOUTPUT P P REFind rep report cfm rep 1234 u 5 CFOUTPUT REFind rep report cfm rep 1234 u 5 CFOUTPUT P Set startPos to...

Page 517: ...the first element contains the position and length of the first instance of the whole expression The position and length of the first instance of each parenthesized subexpression within will be includ...

Page 518: ...nt arrays containing the position and length of the first substring that matches the criteria of the search You can retrieve the position and length of the matching subexpression by using the keys pos...

Page 519: ...EFindNoCase a c abcaaccdd CFOUTPUT P P REFindNoCase alpha abcaacCDD CFOUTPUT REFindNoCase alpha abcaacCDD CFOUTPUT P P REFindNoCase rep report cfm rep 1234 u 5 CFOUTPUT REFindNoCase rep report cfm rep...

Page 520: ...pression you will find that the first element contains the position and length of the first instance of the whole expression The position and length of the first instance of each subexpression within...

Page 521: ...emoveChars Example TITLE HEAD BODY BGCOLOR silver H3 RemoveChars Example H3 Returns a string with I count I characters removed from the specified starting position Returns 0 if no characters are found...

Page 522: ...TLE RepeatString Example TITLE HEAD BODY BGCOLOR silver H3 RepeatString Example H3 P RepeatString returns a string created from I string I being repeated a specified number of times UL LI RepeatString...

Page 523: ...st occurrence default ALL Replace all occurrences Examples This example shows the use of Replace HTML HEAD TITLE Replace Example TITLE HEAD BODY BGCOLOR silver H3 Replace Example H3 P The Replace func...

Page 524: ...cement if one of your list1 elements is contained in list2 elements The second example listed below demonstrates such replacement Examples This example shows the use of Replacelist HTML HEAD TITLE Rep...

Page 525: ...ME 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 Sente...

Page 526: ...urrence default ALL Replace all occurrences Examples This example shows the use of ReplaceNoCase HTML HEAD TITLE ReplaceNoCase Example TITLE HEAD BODY BGCOLOR silver H3 ReplaceNoCase Example H3 P The...

Page 527: ...ion ONE Replace only the first occurrence default ALL Replace all occurrences Examples This example shows the use of REReplace HTML HEAD TITLE REReplace Example TITLE HEAD BODY BGCOLOR silver H3 RERep...

Page 528: ...ence default ALL Replace all occurrences Examples This example shows the use of REReplaceNoCase HTML HEAD TITLE REReplaceNoCase Example TITLE HEAD BODY BGCOLOR silver H3 REReplaceNoCase Example H3 P T...

Page 529: ...xample TITLE HEAD BODY BGCOLOR silver H3 Reverse Example H3 P Reverse returns your string with the positions of the characters reversed CFIF IsDefined FORM myString CFIF FORM myString is not P Reverse...

Page 530: ...Defined Form MyText if len is 0 then err CFIF Len FORM myText is not 0 CFIF Len FORM myText LTE FORM RemoveChars P Your string CFOUTPUT FORM myText CFOUTPUT only has CFOUTPUT Len FORM myText CFOUTPUT...

Page 531: ...use RJustify CFPARAM NAME jstring DEFAULT CFIF IsDefined FORM justifyString CFSET jstring Rjustify FORM justifyString 35 CFIF HTML HEAD TITLE RJustify Example TITLE HEAD BODY BGCOLOR silver H3 RJusti...

Page 532: ...ple shows the use of Round HTML HEAD TITLE Round Example TITLE HEAD ODY H3 Round Example H3 P This function rounds a number to the closest integer UL LI Round 7 49 CFOUTPUT Round 7 49 CFOUTPUT LI Roun...

Page 533: ...L HEAD TITLE RTrim Example TITLE HEAD BODY BGCOLOR silver H3 RTrim Example H3 CFIF IsDefined FORM myText CFOUTPUT PRE Your string FORM myText Your string Rtrim FORM myText right trimmed PRE CFOUTPUT C...

Page 534: ...ng make sure it is enclosed in quotes Otherwise it is interpreted as a number representation of a date time object returning undesired results Examples This example shows the use of Hour Minute and Se...

Page 535: ...delimited list of the locales that ColdFusion and the operating system support GetLocale will return an entry from that list SetLocale will fail if called with a locale name not on that list Example T...

Page 536: ...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 G...

Page 537: ...This example uses SetProfileString to set the timeout value in an initialization file HTML HEAD TITLE SetProfileString Example TITLE HEAD body bgcolor FFFFD5 H3 SetProfileString Example H3 This exampl...

Page 538: ...n file is already CFOUTPUT MyTimeout CFOUTPUT P CFIF CFSET timeout GetProfileString IniPath Section timeout CFSET DEFAULT GetProfileString IniPath Section default H4 Boot Loader H4 P Timeout is set to...

Page 539: ...and the ClientManagement attribute of CFAPPLICATION tag has been set to Yes for this template Examples This example shows SetVariable HTML HEAD TITLE SetVariable Example TITLE HEAD BODY BGCOLOR silve...

Page 540: ...ber number Any number Examples This example shows the use of Sgn HTML HEAD TITLE Sgn Example TITLE HEAD BODY H3 Sgn Example H3 P Sgn determines the sign of a number Returns 1 if number is positive 0 i...

Page 541: ...BODY BGCOLOR silver H3 Sin Example H3 output its Sin value CFIF IsDefined FORM SinNum CFIF IsNumeric FORM SinNum Sin CFOUTPUT FORM SinNum CFOUTPUT CFOUTPUT Sin FORM sinNum Degrees Evaluate Sin FORM s...

Page 542: ...anExcluding Example H3 CFIF IsDefined FORM myString P Your string was CFOUTPUT FORM myString CFOUTPUT P Your set of characters was CFOUTPUT FORM mySet CFOUTPUT P Your string up until one of the charac...

Page 543: ...3 SpanIncluding Example H3 CFIF IsDefined FORM myString P Your string was CFOUTPUT FORM myString CFOUTPUT P Your set of characters was CFOUTPUT FORM mySet CFOUTPUT P Your string up until all of the ch...

Page 544: ...he square root Usage Number must be greater than or equal to 0 Examples This example shows Sqr HTML HEAD TITLE Sqr Example TITLE HEAD BODY H3 Sqr Example H3 P Returns a positive square root for a numb...

Page 545: ...tripCR Example H3 P Function StripCR is useful for preformatted HTML display of data PRE entered into TEXTAREA fields CFIF IsDefined FORM myTextArea PRE CFOUTPUT StripCR FORM myTextArea CFOUTPUT PRE C...

Page 546: ...dd New Employees H1 Establish parms for first time through CFPARAM NAME FORM firstname DEFAULT CFPARAM NAME FORM lastname DEFAULT CFPARAM NAME FORM email DEFAULT CFPARAM NAME FORM phone DEFAULT CFPARA...

Page 547: ...w StructClear and StructDelete CFSWITCH EXPRESSION ThisTag ExecutionMode CFCASE VALUE start CFIF StructIsEmpty attributes EMPINFO CFOUTPUT Error No employee data was passed CFOUTPUT CFEXIT METHOD Exit...

Page 548: ...t this file copy the StructCount function to the appropriate place in addemployee cfm CFSWITCH EXPRESSION ThisTag ExecutionMode CFCASE VALUE start CFIF StructIsEmpty attributes EMPINFO CFOUTPUT Error...

Page 549: ...f it does not Example This example shows how to use the StructDelete function HTML HEAD TITLE StructDelete Function TITLE HEAD basefont face Arial Helvetica size 2 body bgcolor FFFFD5 H3 StructDelete...

Page 550: ...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 option VALUE firstname first name...

Page 551: ...ear and StructDelete It is an example of a custom tag used to add employees Employee information is passed through the employee structure the EMPINFO attribute In UNIX you must also add the Emp_ID CFS...

Page 552: ...ing an existing key The default is FALSE Usage This function throws an exception if structure does not exist or if key exists and allowoverwrite is set to FALSE Example This example shows how to use t...

Page 553: ...yee phone P P Department is StructFind employee department P CFOUTPUT Call the custom tag that adds employees CF_ADDEMPLOYEE EMPINFO employee CFIF Hr FORM ACTION structinsert cfm METHOD post P First N...

Page 554: ...custom tag used to add employees Employee information is passed through the employee structure the EMPINFO attribute In UNIX you must also add the Emp_ID CFSWITCH EXPRESSION ThisTag ExecutionMode CFC...

Page 555: ...array It also uses the StructNew function to create the structure and fills its fields with the information the user types into the corresponding form fields HTML HEAD TITLE StructKeyArray Function TI...

Page 556: ...st Name td td INPUT NAME firstname TYPE text VALUE hspace 30 maxlength 30 td tr tr td Last Name td td INPUT NAME lastname TYPE text VALUE hspace 30 maxlength 30 td tr tr td EMail td td INPUT NAME emai...

Page 557: ...Chapter 2 ColdFusion Functions 533 P CFOUTPUT Value i is employee keysToStruct i CFOUTPUT P CFLOOP CFIF BODY HTML...

Page 558: ...r to addemployee cfm which is called by StructNew StructClear and StructDelete To test this file copy the LT CFELSEif GT statement to the appropriate place in addemployee cfm It is an example of a cus...

Page 559: ...ist Example This example shows how to use the StructKeyList function to list the keys within a specified structure It also uses the StructNew function to create the structure and fills its fields with...

Page 560: ...nformation into a database See CFQUERY for more information about database insertion hr size 2 color 0000A0 FORM ACTION structkeylist cfm METHOD post table cellspacing 2 cellpadding 2 border 0 tr td F...

Page 561: ...0A0 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 informati...

Page 562: ...RM lastname DEFAULT CFPARAM NAME FORM email DEFAULT CFPARAM NAME FORM phone DEFAULT CFPARAM NAME FORM department DEFAULT CFIF FORM firstname EQ P Please fill out the form CFELSE CFOUTPUT CFSCRIPT empl...

Page 563: ...s usage of StructUpdate P This file is similar to addemployee cfm which is called by StructNew StructClear and StructDelete To test this file copy the LT CFELSEIF GT statement to the appropriate place...

Page 564: ...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 HTML HEAD TITLE Tan Example TITLE HEAD BODY H3 Tan...

Page 565: ...eading zero for single digit hours Uses a 24 hour clock m Minutes with no leading zero for single digit minutes mm Minutes with a leading zero for single digit minutes s Seconds with no leading zero f...

Page 566: ...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...

Page 567: ...it encoding of 8 bit ASCII characters Because high ASCII values and binary objects are not safe for transport over internet protocols such as HTTP and SMTP ColdFusion offers Base 64 as a means to safe...

Page 568: ...oBase64 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 equa...

Page 569: ...e that it is an acceptable binary value Usage Base 64 provides 6 bit encoding of 8 bit ASCII characters If you receive data in Base 64 you can re create the actual binary object that it represents suc...

Page 570: ...FSET binaryData toBinary data64 Convert binary back to Base 64 CFSET another64 toBase64 binaryData Compare another64 with data64 to ensure that they are equal CFIF another64 eq data64 H3 Base 64 repre...

Page 571: ...the use of ToBase64 ToBinary and ToString HTML HEAD TITLE ToString Example TITLE HEAD BODY BGCOLOR silver H3 ToString Example H3 Initialize data CFSET charData Create a string of all ASCII characters...

Page 572: ...ation 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 binar...

Page 573: ...HEAD TITLE Trim Example TITLE HEAD BODY BGCOLOR silver H3 Trim Example H3 CFIF IsDefined FORM myText CFOUTPUT PRE Your string FORM myText Your string trim FORM myText trimmed on both sides PRE CFOUTPU...

Page 574: ...lver H3 UCase Example H3 CFIF IsDefined FORM sampleText CFIF FORM sampleText is not P Your text CFOUTPUT FORM sampleText CFOUTPUT returned in uppercase is CFOUTPUT UCase FORM sampleText CFOUTPUT CFELS...

Page 575: ...in HTTP are always URL encoded URL encoded strings can be created using the URLEncodedFormat function Example Here is an example of the URLDecode and URLEncodedFormat functions In the example a strin...

Page 576: ...the character code For example a character with code 129 will be encoded as 81 In addition spaces can be encoded using the plus sign Query strings in HTTP are always URL encoded URL encoded strings c...

Page 577: ...theTestValue CFIF Val FORM theTestValue is not 0 H3 The string CFOUTPUT DE FORM theTestValue CFOUTPUT can be converted to a number CFOUTPUT Val FORM theTestValue CFOUTPUT H3 CFELSE H3 The beginning o...

Page 578: ...to separate column data Example This example shows the use of ValueList HTML HEAD TITLE ValueList Example TITLE HEAD BODY H3 ValueList Example H3 use the contents of one query to create another dynami...

Page 579: ...d results Examples shows the value of the Week function HTML HEAD TITLE Week Example TITLE HEAD BODY BGCOLOR silver H3 Week Example H3 CFIF IsDefined FORM year More information about your date CFSET y...

Page 580: ...not use WriteOutput within CFQUERY and CFMAIL This function writes to the page output stream regardless of conditions established by the CFSETTING tag Syntax WriteOutput string string Text to be appen...

Page 581: ...reater than sign less than sign single quotation mark double quotation mark ampersand Examples This example illustrates use of the XMLFormat function HTML HEAD TITLE XMLFormat TITLE HEAD BODY H3 XMLFo...

Page 582: ...s shows the value of the Year function HTML HEAD TITLE Year Example TITLE HEAD BODY BGCOLOR silver H3 Year Example H3 CFIF IsDefined FORM year More information about your date CFSET yourDate CreateDat...

Page 583: ...YES and zero values as NO Examples This example shows the YesNoFormat HTML HEAD TITLE YesNoFormat Example TITLE HEAD BODY H3 YesNoFormat Example H3 P The YesNoFormat function returns all non zero valu...

Page 584: ...560 CFMLLanguageReference...

Page 585: ...pter 3 WDDX JavaScript Objects This chapter provides information about JavaScript objects and functions used when implementing WDDX in a ColdFusion application Contents WddxSerializer Object 562 WddxR...

Page 586: ...ds and a null value if an error occurs Usage Call this function to serialize the data in a WddxRecordset instance Example This example illustrates a JavaScript function that you can call to serialize...

Page 587: ...function Example This example is from the WddxSerializer serializeValue function Some generic object treat it as a structure this write struct for prop in obj bSuccess this serializeVariable prop obj...

Page 588: ...nction this wddxPacket this write wddxPacket version 1 0 header data bSuccess this serializeValue rootObj this write data wddxPacket if bSuccess return this wddxPacket else return null write Appends d...

Page 589: ...ified column to all rows in the WddxRecordset instance Syntax object addColumn name object Instance name of the WddxRecordset object name Name of the column to add Return value None Usage This functio...

Page 590: ...ry column of the WDDX record set Initially the row column values are set to NULL Example This example calls the addRows function create a new recordset rs new WddxRecordset add a new column rs addColu...

Page 591: ...w 0 row nRows row o tr for i 0 i colNames length i o td r getField row colNames i td o tr getRowCount Indicates the number of rows in the WddxRecordset instance Syntax object getRowCount object Instan...

Page 592: ...Value to be set Return value None Usage Call this function to set a value in a WddxRecordset instance Example This example calls the setField function create a new recordset rs new WddxRecordset add a...

Page 593: ...rror occurs 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 empt...

Page 594: ...570 CFMLLanguageReference...

Page 595: ...nd Other Constructs This chapter describes ColdFusion expressions language constructs that allow you to create sophisticated applications Contents Elements of ColdFusion Expressions 572 Operators 576...

Page 596: ...available memory on the ColdFusion server To use a single quote inside a string that is single quoted escape the single quote by using two single quotes You can similarly escape a double quote inside...

Page 597: ...cters to the delimiters Delimiters before the first element and after the last element are ignored The structure of lists is flat that is lists cannot be nested into one another Also lists can contain...

Page 598: ...ve the same name at the same time in the same application page COM objects COM Component Object Model objects are non visual components that encapsulate specific functionality you can invoke in your a...

Page 599: ...fer to dates in expressions in the following order month day and year For example CFIF 11 23 1998 GT 11 15 1998 If this switch is set the default date format returned by the DateFormat function cannot...

Page 600: ...s Operators combine sub expressions to create more complex expressions The general syntax for using operators is Expression Operator Expression ColdFusion has four types of operators Arithmetic operat...

Page 601: ...mber from the power The left operand cannot be zero For example 2 3 is 8 Arithmetic Operators Continued Operator Description String Operators Operator Description Concatenates strings Decision Operato...

Page 602: ...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 is Shorthand Not...

Page 603: ...ALSE and vice versa AND Returns TRUE if both arguments are TRUE returns FALSE otherwise For example TRUE AND TRUE is TRUE but TRUE AND FALSE is FALSE OR Returns TRUE if any of the arguments is TRUE re...

Page 604: ...e default value For example Replace FooFoo Foo Boo returns BooFoo Replace FooFoo Foo Boo ALL returns BooBoo The difference in behavior is explained by the fact that the Replace function takes an optio...

Page 605: ...bove the expression Form MyFormVariable is replaced with whatever value has been assigned to it While the guidelines for using pound signs in CFML are simple there is still some possibility for confus...

Page 606: ...he value returned by the function For example the following pairs of CFSET statements produce the same result CFSET TheString Hello FirstName CFSET TheString Hello FirstName If pound signs are not use...

Page 607: ...ME TestCookie VALUE CookieValueArray Index This usage is more efficient than VALUE CookieValue Nested pound signs There are very few cases in which pound signs can be nested inside the same expression...

Page 608: ...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...

Reviews: