- DL manuals
- MACROMEDIA
- Other
- COLDFUSION MX 61-CFML
- Reference
MACROMEDIA COLDFUSION MX 61-CFML Reference
Summary of COLDFUSION MX 61-CFML
Page 1
Cfml reference.
Page 2
Trademarks afterburner, appletace, attain, attain enterprise learning system, attain essentials, attain objects for dreamweaver, authorware, authorware attain, authorware interactive studio, authorware star, authorware synergy, backstage, backstage designer, backstage desktop studio, backstage enter...
Page 3: Contents
3 contents introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 about macromedia coldfusion mx documentation . . . . . . . . . . . . . . . . . . . . . . 17 documentation set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....
Page 4
4 contents cgi environment variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 testing for cgi variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 cgi server variables . . . . . . . . . . . . . . . . . . . . . . ...
Page 5
Contents 5 cfexecute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 cfexit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 cffile . . . . . . . . . . . . . . . ....
Page 6
6 contents cfloop: looping over a query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 cfloop: looping over a list or file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 cfloop: looping over a com collection or structure . . . . . ....
Page 7
Contents 7 cftreeitem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 cftry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353 cfupdate . . . . . . . . . . . . . . . ....
Page 8
8 contents asc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395 asin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396 atn . . . . . . . . . . . . . . . . . ...
Page 9
Contents 9 decrypt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462 deleteclientvariable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463 directoryexists . . . . . . . . . . . . . . . . ...
Page 10
10 contents insert. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522 int . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523 isarray. . . . . . . . . . . . . ....
Page 11
Contents 11 listvaluecount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 590 listvaluecountnocase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592 ljustify . . . . . . . . . . . . . . . . . . . . . . . ....
Page 12
12 contents reverse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668 right . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669 rjustify . . . . . . . . . . . . . . ....
Page 13
Contents 13 xmlformat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 741 xmlnew . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 742 xmlparse . . . . . . . . . . . . . . . . . . . ...
Page 14
14 contents chapter 5: coldfusion java cfx reference . . . . . . . . . . . . . . . . . . . . . . . . . 769 overview class libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 770 customtag interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...
Page 15
Contents 15 setfield . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 796 wddxserialize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 797 chapter 7: coldfusion actionscript functions . . . ...
Page 16
16 contents.
Page 17: Introduction
17 introduction cfml reference is your primary coldfusion markup language (cfml) reference. Use this book to learn about cfml tags and functions, coldfusion expressions, and using javascript objects for wddx in macromedia coldfusion mx. It also provides detailed references for java and c++ cfx inter...
Page 18
18 introduction viewing online documentation all coldfusion mx documentation is available online in html and adobe acrobat portable document format (pdf) files. Go to the documentation home page for coldfusion mx on the macromedia website: www.Macromedia.Com..
Page 19: Chapter 1
19 chapter 1 reserved words and variables this chapter provides information on coldfusion reserved words and lists scope variables. Contents reserved words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 scope-specific built-...
Page 20
20 chapter 1: reserved words and variables reserved words the following list indicates words you must not use for coldfusion variables, user-defined function names, or custom tag names. While some of these words can be used safely in some situations, you can prevent errors by avoiding them entirely....
Page 21
Reserved words 21 column commit connect connection constraint constraints continue convert correspon ding count create cross current current_date current_time current_time stamp current_user cursor date day deallocate dec decimal declare default deferrable deferred delete desc describe descriptor di...
Page 22
22 chapter 1: reserved words and variables time timestamp timezone_ hour timezone_ minute to trailing transaction translate translation trim true union unique unknown update upper usage user using value values varchar varying view when whenever where with work write year zone.
Page 23
Scope-specific built-in variables 23 scope-specific built-in variables coldfusion returns variables, such as those returned in a cfdirectory or cfftp operation. A variable is usually referenced by scoping it according to its type: naming it according to the code context in which it is available; for...
Page 24
24 chapter 1: reserved words and variables to ensure that modifications to shared data occur in the intended sequence, use the cflock tag. For more information, see cflock on page 221 . The predefined application and session variables are as follows: application.Applicationname session.Cfid session....
Page 25
Coldfusion tag-specific variables 25 cfhttp cfindex cfldap cfmail cfpop cfquery cfregistry cfsearch cfstoredproc coldfusion query variables a coldfusion tag that returns a query object supports the following variables, where queryname is the value of the name attribute: queryname.Currentrow querynam...
Page 26
26 chapter 1: reserved words and variables error.Httpreferer error.Template error.Querystring the following error variables are available if type="validation ". Error.Validationheader error.Invalidfields error.Validationfooter any cfcatch variable that applies to exception type can be accessed withi...
Page 27
Coldfusion tag-specific variables 27 cfftp.Errorcode cfftp.Errortext cfftp returnvalue variable some cfftp file and directory operations provide a return value, in the variable cfftp.Returnvalue. Its value is determined by the results of the action attribute. When you specify any of the following ac...
Page 28
28 chapter 1: reserved words and variables queryname.Cc queryname.To queryname.Currentrow queryname.Recordcount queryname.Columnlist queryname.Attachments queryname.Attachmentfiles cfquery and cfstoredproc variables the cfquery tag returns information about the query in this variable: cfquery.Execut...
Page 29
Cgi environment variables 29 standard cgi variables this section lists the cgi 1.1 variables that some web servers create when a cgi script is called. The cgi variables that are available for your use vary with the web server and configuration. Some of the following variables may not be available. R...
Page 30
30 chapter 1: reserved words and variables testing for cgi variables because some browsers do not support some cgi variables, coldfusion always returns true when it tests for the existence of a cgi variable, regardless of whether the browser supports the variable. To determine if the cgi variable is...
Page 31
Cgi environment variables 31 cgi client variables the following table describes common cgi environment variables the browser creates and passes in the request header: cgi client certificate variables coldfusion makes available the following client certificate data. These variables are available when...
Page 32
32 chapter 1: reserved words and variables.
Page 33: Chapter 2
33 chapter 2 coldfusion tags coldfusion markup language (cfml) includes a set of tags that you use in coldfusion pages to interact with data sources, manipulate data, and display output. Cfml tag syntax is similar to html element syntax. This chapter contains categorized and alphabetical lists of th...
Page 34
34 chapter 2: coldfusion tags tag summary the following table briefly describes cfml tags: cfml tag category description cfabort flow-control tags stops the processing of a coldfusion page at the tag location cfapplet forms tags embeds java applets in a cfform tag cfapplication application framework...
Page 35
Tag summary 35 cferror exception handling tags , application framework tags displays custom html error pages when errors occur cfexecute flow-control tags , extensibility tags executes developer-specified process on server computer cfexit flow-control tags aborts processing of executing cfml tag cff...
Page 36
36 chapter 2: coldfusion tags cfinvokeargument extensibility tags passes a parameter to a component method or a web service cfldap forms tags , internet protocol tags provides access to ldap directory servers cflocation flow-control tags controls execution of a page cflock application framework tags...
Page 37
Tag summary 37 cfquery database manipulation tags passes sql statements to a database cfqueryparam database manipulation tags checks data type of a query parameter cfregistry other tags , variable manipulation tags reads, writes, and deletes keys and values in a windows system registry cfreport exce...
Page 38
38 chapter 2: coldfusion tags cftreeitem forms tags populates a tree control element in a form; used with cftree cftry exception handling tags , flow-control tags catches exceptions in coldfusion pages cfupdate database manipulation tags updates rows in a database data source cfwddx extensibility ta...
Page 39
Tags by function 39 tags by function the following tables list tags by their function or purpose. Application framework tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 database manipulation tags . . . . . . . . . . . . . . . . . . . . . ....
Page 40
40 chapter 2: coldfusion tags exception handling tags extensibility tags file management tags flow-control tags forms tags cfcatch cfrethrow cftry cferror cfthrow cfchart cffunction cfobject cfchartdata cfindex cfproperty cfchartseries cfinvoke cfreport cfcollection cfinvokeargument cfreturn cfcompo...
Page 41
Tags by function 41 internet protocol tags page processing tags variable manipulation tags other tags cfftp cfldap cfmailpart cfhttp cfmail cfpop cfhttpparam cfmailparam cfcache cfheader cfsetting cfcontent cfhtmlhead cfsilent cfflush cfinclude cfcookie cfregistry cfset cfdump cfsavecontent cfsettin...
Page 42
42 chapter 2: coldfusion tags tag changes since coldfusion 5 the following tables list tags, attributes, and values that have changed since coldfusion 5.0 and indicate the specific release in which the change was made. New tags, attributes, and values . . . . . . . . . . . . . . . . . . . . . . . . ...
Page 43
Tag changes since coldfusion 5 43 cfimport all coldfusion mx cfinvoke all coldfusion mx cfinvokeargument all coldfusion mx cflogin all coldfusion mx cfloginuser all coldfusion mx cflogout all coldfusion mx cfmail spoolenable attribute coldfusion mx charset attribute coldfusion mx 6.1 failto attribut...
Page 44
44 chapter 2: coldfusion tags deprecated tags, attributes, and values the following tags, attributes, and attribute values are deprecated. Do not use them in coldfusion applications. They might not work, and might cause an error, in releases later than coldfusion mx. Tag attribute or value deprecate...
Page 45
Tag changes since coldfusion 5 45 cfquery connectstring attribute coldfusion mx dbname attribute coldfusion mx dbserver attribute coldfusion mx the following dbtype attribute values: • dynamic • odbc • oracle73 • oracle80 • sybase11 • oledb • db2 coldfusion mx (the value query is valid.) provider at...
Page 46
46 chapter 2: coldfusion tags obsolete tags, attributes, and values the following tags, attributes, and attribute values are obsolete. Do not use them in coldfusion applications. They do not work, and might cause an error, in releases later than coldfusion 5. Tag attribute or value obsolete as of th...
Page 47
Cfabort 47 cfabort description stops the processing of a coldfusion page at the tag location. Coldfusion returns everything that was processed before the tag. The tag is often used with conditional logic to stop processing a page when a condition occurs. Category flow-control tags syntax showerror =...
Page 48
48 chapter 2: coldfusion tags the value of myvariable after incrementing through the loop #counter# times is: #myvariable#.
Page 49
Cfapplet 49 cfapplet description this tag references a registered custom java applet. To register a java applet, in the coldfusion administrator, click extensions > java applets. Using this tag within a cfform tag is optional. If you use it within cfform , and the method attribute is defined in the ...
Page 50
50 chapter 2: coldfusion tags usage you can specify the applet method attribute only in the administrator, java applets view. For other attributes, you can accept the default values in the administrator view, or specify values in this tag and override the defaults. If java applet components are stor...
Page 51
Cfapplication 51 cfapplication description defines the scope of a coldfusion application; enables and disables storage of client variables; specifies the client variable storage mechanism; enables session variables; and sets application variable timeouts. Category application framework tags syntax n...
Page 52
52 chapter 2: coldfusion tags usage this tag is typically used in the application.Cfm file, to set defaults for a coldfusion application. This tag enables application variables, unless they are disabled in the coldfusion administrator. The administrator setting also overrides the sessionmanagement a...
Page 53
Cfapplication 53 if you use this tag to activate the application and client scopes, coldfusion saves the application name as a key, whose maximum length is 64 characters. If an application name is longer than this, the client store fails during database processing. Note: the cftoken variable is 8 by...
Page 54
54 chapter 2: coldfusion tags cfargument description creates a parameter definition within a component definition. Defines a function argument. Used within a cffunction tag. Category extensibility tags syntax name="string" type="data type" required="yes or no" default="default value" displayname="de...
Page 55
Cfargument 55 usage this tag must be in a cffunction tag, before any other tags in the cffunction tag body. Arguments that are passed when a method is invoked can be accessed from the method body in the following ways: • with shorthand syntax: #myargument# (this example accesses the argument myargum...
Page 56
56 chapter 2: coldfusion tags cfassociate description allows subtag data to be saved with a base tag. Applies only to custom tags. Category application framework tags syntax basetag = "base_tag_name" datacollection = "collection_name"> see also cfapplication , cferror , cflock , cfmodule attributes ...
Page 57
Cfauthenticate 57 cfauthenticate description this tag is obsolete. Use the newer security tools; see “authentication functions” on page 367 and chapter 16, “securing applications,” in developing coldfusion mx applications. History coldfusion mx: this tag is obsolete. It does not work in coldfusion m...
Page 58
58 chapter 2: coldfusion tags cfbreak description used within a cfloop tag. Breaks out of a loop. Category flow-control tags syntax see also cfabort , cfexecute , cfif , cflocation , cfloop , cfswitch , cfthrow , cftry example select * from courses order by course_number this example uses cfloop to ...
Page 59
Cfcache 59 cfcache description stores a copy of a page on the server and/or client computer, to improve page rendering performance. To do this, the tag creates temporary files that contain the static html returned from a coldfusion page. Use this tag if it is not necessary to get dynamic content eac...
Page 60
60 chapter 2: coldfusion tags attributes usage use this tag in pages whose content is not updated frequently. Taking this action can greatly improve the performance of your application. The output of a cached page is stored in a file on the client browser and/or the coldfusion server. Instead of reg...
Page 61
Cfcache 61 you can specify client-side caching or a combination of client-side and server-side caching (the default), using the action attribute. The advantage of client-side caching is that it requires no coldfusion resources; the browser stores pages in its own cache, improving performance. The ad...
Page 62
62 chapter 2: coldfusion tags cfcase description used only inside the cfswitch tag body. Contains code to execute when the expression specified in the cfswitch tag has one or more specific values. Category flow-control tags syntax value = "value or delimited set of values" delimiters = "delimiter ch...
Page 63
Cfcase 63 your grade is #grade#.
Page 64
64 chapter 2: coldfusion tags cfcatch description used inside a cftry tag. Together, they catch and process exceptions in coldfusion pages. Exceptions are events that disrupt the normal flow of instructions in a coldfusion page, such as failed database operations, missing include files, and develope...
Page 65
Cfcatch 65 attributes usage you must code at least one cfcatch tag within a cftry block. Put cfcatch tags at the end of a cftry block. Coldfusion mx tests cfcatch tags in the order in which they appear. This tag requires an end tag. If type="any" , coldfusion mx catches exceptions from any cfml tag,...
Page 66
66 chapter 2: coldfusion tags the cfinclude , cfmodule , and cferror tags throw an exception of type = "template" . An exception that is thrown within a cfcatch block cannot be handled by the cftry block that immediately encloses the cfcatch tag. However, you can rethrow the currently active excepti...
Page 67
Cfcatch 67 advanced exception types you can specify the following advanced exception types in the type attribute: coldfusion advanced exception type com.Allaire.Coldfusion.Cfexecute.Outputerror com.Allaire.Coldfusion.Cfexecute.Timeout com.Allaire.Coldfusion.Fileexception com.Allaire.Coldfusion.Httpa...
Page 68
68 chapter 2: coldfusion tags example select * from employeeas #cfcatch.Message# caught an exception, type = #cfcatch.Type# com.Allaire.Coldfusion.Httpnotmodified com.Allaire.Coldfusion.Httppartialcontent com.Allaire.Coldfusion.Httppaymentrequired com.Allaire.Coldfusion.Httppreconditionfailed com.Al...
Page 69
Cfcatch 69 the contents of the tag stack are: to = #arraylen(cfcatch.Tagcontext)#> #i# #scurrent["id"]# (#scurrent["line"]#,#scurrent["column"]#) #scurrent["template"]# to = #arraylen(cfcatch.Tagcontext)#> #i# #scurrent["id"]# (#scurrent["line"]#,#scurrent["column"]#) #scurrent["template"]#.
Page 70
70 chapter 2: coldfusion tags cfchart description generates and displays a chart. Category data output tags , extensibility tags syntax format = "flash, jpg, png" chartheight = "integer number of pixels" chartwidth = "integer number of pixels" scalefrom = "integer minimum value" scaleto = "integer m...
Page 71
Cfchart 71 attributes attribute req/opt default description format flash file format in which to save graph. • flash • jpg • png chartheight 240 chart height; integer number of pixels chartwidth 320 chart width; integer number of pixels scalefrom determined by data y-axis minimum value; integer. Sca...
Page 72
72 chapter 2: coldfusion tags fontsize 11 font size; integer fontbold no • yes • no fontitalic no • yes • no labelformat number format for y-axis labels. • number • currency • percent • date xaxistitle text; x-axis title yaxistitle text; y-axis title xaxistype category • category the axis indicates ...
Page 73
Cfchart 73 usage the cfchart tag defines a container in which a graph displays: its height, width, background color, labels, and so on. The cfchartseries tag defines the style in which data displays: bar, line, pie, and so on. The cfchartdata tag defines a data point. Tipstyle mouseover determines t...
Page 74
74 chapter 2: coldfusion tags data is passed to the cfchartseries tag in the following ways: • as a query • as data points, using the cfchartdata tag for the font attribute value " arialunicodems ", the following rules apply: • on windows: to permit flash charts ( type = "flash" ) to render double-b...
Page 75
Cfchartdata 75 cfchartdata description used with the cfchart and cfchartseries tags. This tag defines chart data points. Its data is submitted to the cfchartseries tag. Category data output tags , extensibility tags syntax item = "text" value = "number"> see also cfchart , cfchartseries history cold...
Page 76
76 chapter 2: coldfusion tags cfchartseries description used with the cfchart tag. This tag defines the style in which chart data displays: bar, line, pie, and so on. Category data output tags , extensibility tags syntax type="type" query="queryname" itemcolumn="querycolumn" valuecolumn="querycolumn...
Page 77
Cfchartseries 77 usage if a chart has multiple line series, coldfusion interpolates missing data points in the common x axis range. For example, if one series has data points at 0, 10, and 20 on the x axis and a second series has data points at 0, 20, and 30, coldfusion calculates and displays a dat...
Page 78
78 chapter 2: coldfusion tags cfcol description defines table column header, width, alignment, and text. Used within a cftable tag. Category data output tags syntax header = "column_header_text" width = "number_indicating_width_of_column" align = "left" or "right" or "center" text = "column_text"> s...
Page 79
Cfcol 79 from employees query = "getemployees" startrow = "1" colspacing = "3" htmltable colheaders> align = "left" width = 2 text = "#emp_id#"> align = "left" width = 15 text = "#firstname# #lastname#"> align = "center" width = 15 text = "#phone#"> query = "getemployees" startrow = "1" colspacing =...
Page 80
80 chapter 2: coldfusion tags cfcollection description creates, registers, and administers verity search engine collections. A collection that is created with the cfcollection tag is internal. A collection created any other way is external. A collection that is registered with coldfusion using the c...
Page 81
Cfcollection 81 attributes usage with this tag you can create, register a verity collection and administer a collection that was created by coldfusion or by a verity application. The following table shows the dependence relationships among this tag’s attribute values: if more than instance of the cf...
Page 82
82 chapter 2: coldfusion tags before you attempt to delete or purge a collection that is also opened by the k2server, you must stop the k2server. If you do not, some files may be open, and coldfusion might not complete the action. The list action returns the following information in a result set tha...
Page 83
Cfcollection 83 with the european verity locales language pack installed, the language attribute of this tag supports the following options: with the asian verity locales language pack installed, the language attribute of this tag supports the following options: the default location of verity collec...
Page 84
84 chapter 2: coldfusion tags create this collection optimize this collection repair this collection delete this collection collection on which to act use the default value or enter your own collection name.
Page 85
Cfcomponent 85 cfcomponent description creates and defines a component object; encloses functionality that you build in cfml and enclose within cffunction tags. This tag contains one or more cffunction tags that define methods. Code within the body of this tag, other than cffunction tags, is execute...
Page 86
86 chapter 2: coldfusion tags attributes usage if you specify the extends attribute, the data and methods of the parent component are available to any as if they were parts of the current component. If the managercfc component extends the employeecfc component, and the employeecfc component has a ge...
Page 87
Cfcontent 87 cfcontent description does either or both of the following: • sets the mime content encoding header for the current page • sends the contents of a file from the server as the page output note: this tag executes only if it is enabled in the coldfusion administrator. For more information,...
Page 88
88 chapter 2: coldfusion tags attributes attribute req/opt default description type optional the mime content type of the page, optionally followed by a semicolon and the character encoding. By default, coldfusion sends pages as text/html content type in the utf-8 character encoding. The content typ...
Page 89
Cfcontent 89 usage to set the character encoding (character set) of generated output, use code such as the following: when coldfusion processes an http request, it determines the character encoding of the data returned in the http response. By default, coldfusion returns character data using the uni...
Page 90
90 chapter 2: coldfusion tags this example shows how reset attribute changes output for text. Reset = "yes ": 123 456 this example shows how reset attribute changes output for text. Reset = "no ": 123 456.
Page 91
Cfcookie 91 cfcookie description defines web browser cookie variables, including expiration and security options. Category forms tags , variable manipulation tags syntax name = "cookie_name" value = "text" expires = "period" secure = "yes" or "no" path = "url" domain = ".Domain"> see also cfdump , c...
Page 92
92 chapter 2: coldfusion tags usage if this tag specifies that a cookie is to be saved beyond the current browser session, the client browser writes or updates the cookie in its local cookies file. Until the browser is closed, the cookie resides in browser memory. If the expires attribute is not spe...
Page 93
Cfcookie 93 value = "#now()#" expires = "now"> value = "#email#" expires = "now" > value = "#now()#" expires = "10"> the last aol visitor to view this site was #cookie.Lastaolvisitor#, on #dateformat(cookie.Timevisited)# hide my tracks no aol visitors have viewed the site lately. Value = "#now()#" e...
Page 94
94 chapter 2: coldfusion tags cfdefaultcase description used only inside the cfswitch tag body. Contains code to execute when the expression specified in the cfswitch tag does not match a of the value specified by a cfcase tag. Category flow-control tags syntax see also cfcase , cfswitch history col...
Page 95
Cfdirectory 95 cfdirectory description manages interactions with directories. Category file management tags syntax action = "directory action" directory = "directory name" name = "query name" filter = "list filter" mode = "permission" sort = "sort specification" newdirectory = "new directory name"> ...
Page 96
96 chapter 2: coldfusion tags usage note: for this tag execute, it must be enabled in the coldfusion administrator. For more information, see configuring and administering coldfusion mx. If you put coldfusion applications on a server that is used by multiple customers, you must consider the security...
Page 97
Cfdirectory 97 note: if the cfdirectory tag does not appear to work, for example, if a list operation returns an empty result set, make sure that you have correct permissions to access the directory. For example, if you run coldfusion as a service on windows, it operates by default as system, and ca...
Page 98
98 chapter 2: coldfusion tags cfdump description outputs the elements, variables and values of most kinds of coldfusion objects. Useful for debugging. You can display the contents of simple and complex variables, objects, components, user-defined functions, and other elements. Category debugging tag...
Page 99
Cfdump 99 if a table cell is empty, this tag displays "[empty string]". Example this example shows how to use this tag to display a url variable. Url variables contain parameters that are passed in a url string in a page request..
Page 100
100 chapter 2: coldfusion tags cfelse description used as the last control block in a cfif tag block to handle any case not identified by the cfif tag or a cfelseif tag. Category flow-control tags syntax html and cfml tags html and cfml tags html and cfml tags see also cfif , cfelseif , cfabort , cf...
Page 101
Cfelseif 101 cfelseif description used as a control block in a cfif tag block to handle any case not identified by the cfif tag or a cfelseif tag. Category flow-control tags syntax expression> html and cfml tags expression> html and cfml tags html and cfml tags see also cfif , cfelse , cfabort , cfb...
Page 102
102 chapter 2: coldfusion tags cferror description displays a custom html page when an error occurs. This lets you maintain a consistent look and feel among an application’s functional and error pages. Category exception handling tags , extensibility tags , application framework tags syntax type = "...
Page 103
Cferror 103 usage use this tag to provide custom error messages for pages in an application. You generally embed this tag in the application.Cfm file. For more information, see chapter 14, “handling errors,” in developing coldfusion mx applications. To ensure that error pages display successfully, a...
Page 104
104 chapter 2: coldfusion tags in exception error handling pages, you can access the error variables that are also available to the cfcatch tag. See cfcatch for a description of these variables . To use these variables, prefix them with "cferror." note: if type = "exception" you can substitute the p...
Page 105
Cferror 105 if you continue to have this problem, please contact #error.Mailto# with the following information: #error.Diagnostics#.
Page 106
106 chapter 2: coldfusion tags cfexecute description executes a coldfusion developer-specified process on a server computer. Category extensibility tags , flow-control tags syntax name = " applicationname " arguments = "commandline arguments" outputfile = "output file name" variable = "variable name...
Page 107
Cfexecute 107 usage do not put other coldfusion tags or functions between the start and end tags of cfexecute . You cannot nest cfexecute tags. Exceptions throws the following exceptions: • if the application name is not found: application file not found • if the effective user of the coldfusion exe...
Page 108
108 chapter 2: coldfusion tags cfexit description this tag aborts processing of the currently executing cfml custom tag, exits the page within the currently executing cfml custom tag, or re-executes a section of code within the currently executing cfml custom tag. Category debugging tags , flow-cont...
Page 109
Cfexit 109 cfexit is used primarily to perform a conditional stop of processing inside a custom tag. Cfexit returns control to the page that called that custom tag, or in the case of a tag called by another tag, to the calling tag. If cfexit is used outside a custom tag, it functions like a cfabort....
Page 110
110 chapter 2: coldfusion tags cffile description manages interactions with server files. The following sections describe the actions of the cffile tag: • cffile action = "append" on page 113 • cffile action = "copy" on page 115 • cffile action = "delete" on page 116 • cffile action = "move" on page...
Page 111
Cffile 111 • changed directory path requirements for the destination attribute: a directory path that you specify in the destination attribute does not require a trailing slash. • deprecated the system value of the attributes attribute. • deprecated the temporary value of the attributes attribute. I...
Page 112
112 chapter 2: coldfusion tags #readtext# make new file add to existing file delete file read existing file --->.
Page 113
Cffile 113 cffile action = "append" description appends text to a text file on the server. Syntax action = "append" file = "full_path_name" output = "string" addnewline = "yes" or "no" attributes = "file_attributes_list" mode = "mode" charset = "charset_option" > see also cfdirectory history see the...
Page 114
114 chapter 2: coldfusion tags example this example appends a text string to the file fieldwork.Txt: file = "c:\files\updates\fieldwork.Txt" output = "but davis square is the place to be."> attributes optional applies to windows. A comma-delimited list of attributes to set on the file. If omitted, t...
Page 115
Cffile 115 cffile action = "copy" description copies a file from one directory to another on the server. Syntax action = "copy" source = "full_path_name" destination = "full_path_name" mode = "mode" attributes = "file_attributes_list"> see also cfdirectory history see the history section of the main...
Page 116
116 chapter 2: coldfusion tags cffile action = "delete" description deletes a file on the server. Syntax action = "delete" file = "full_path_name"> see also cfdirectory attributes example the following example deletes the specified file: file = "c:\files\upload\#variables.Deletefilename#"> attribute...
Page 117
Cffile 117 cffile action = "move" description moves a file from one location to another on the server. Syntax action = "move" source = "full_path_name" destination = "full_path_name" mode = "mode" attributes = "file_attributes_list" charset = "charset_option"> see also cfdirectory history see the hi...
Page 118
118 chapter 2: coldfusion tags example the following example moves the keymemo.Doc file from the c:\files\upload\ directory to the c:\files\memo\ directory in windows: action = "move" source = "c:\files\upload\keymemo.Doc" destination = "c:\files\memo\"> in this example, the destination directory is...
Page 119
Cffile 119 cffile action = "read" description reads a text file on the server. The file is read into a dynamic, local variable that you can use in the page. For example: • read a text file; insert the file’s contents into a database • read a text file; use the find and replace function to modify the...
Page 120
120 chapter 2: coldfusion tags usage the following example creates a variable named message for the contents of the file message.Txt: file = "c:\web\message.Txt" variable = "message"> the variable message can be used in the page. For example, you could display the contents of the message.Txt file in...
Page 121
Cffile 121 cffile action = "readbinary" description reads a binary file (such as an executable or image file) on the serve, into a binary object parameter that you can use in the page. To send it through a web protocol (such as http or smtp) or store it in a database, first convert it to base64 usin...
Page 122
122 chapter 2: coldfusion tags cffile action = "rename" description renames or moves a file on the server. Syntax action = "rename" source = "full_path_name" destination = "path_name" mode = "mode" attributes = "file_attributes_list"> see also cfdirectory history see the history section of the main ...
Page 123
Cffile 123 source = "c:\files\memo\keymemo.Doc" destination = "c:\files\memo\oldmemo.Doc"> source = "c:\files\memo\keymemo.Doc" destination = "c:\files\memo\oldmemo.Doc">.
Page 124
124 chapter 2: coldfusion tags cffile action = "upload" description copies a file to a directory on the server. Syntax action = "upload" filefield = "formfield" destination = "full_path_name" nameconflict = "behavior" accept = "mime_type/file_type" mode = "permission" attributes = "file_attribute_or...
Page 125
Cffile 125 usage after a file upload is completed, you can get status information using file upload parameters. The status parameters use the cffile prefix; for example, cffile.Clientdirectory . Status parameters can be used anywhere other coldfusion parameters can be used. Note: the file prefix is ...
Page 126
126 chapter 2: coldfusion tags tip: to refer to parameters, use the cffile prefix: for example, #cffile.Fileexisted#. Note: file status parameters are read-only. They are set to the results of the most recent cffile operation. (if two cffile tags execute, the results of the second overwrite the firs...
Page 127
Cffile 127 cffile action = "write" description writes a text file on the server, based on dynamic content. You can create static html files from the content, or log actions in a text file. Syntax action = "write" file = "full_path_name" output = "content" mode = "permission" addnewline = "yes" or "n...
Page 128
128 chapter 2: coldfusion tags example this example creates a file with information a user entered in an html insert form: file = "c:\files\updates\#form.Updatetitle#.Txt" output = "created by: #form.Fullname# date: #form.Date# #form.Content#"> if the user submitted a form with the following: update...
Page 129
Cffile 129 destination = "/home/tomj/testing.Txt" mode = 666 output = "is this a test?"> this example uploads a file and gives it the permissions owner/group/other = read/write/execute): cffile action = "upload" filefield = "fieldname" destination = "/tmp/program.Exe" mode = 777> destination = "/hom...
Page 130
130 chapter 2: coldfusion tags cfflush description flushes currently available data to the client. Category data output tags , page processing tags syntax interval = "integer number of bytes"> see also cfcache , cfheader , cfinclude , cfsetting , cfsilent attributes usage the first occurrence of thi...
Page 131
Cfflush 131 it will take us a little while to calculate your ten magic numbers. It takes a lot of work to find numbers that truly fit your personality. So relax for a minute or so while we do the hard work for you. Magic number number #myindex# is: #randrange( 100000, 999999)#.
Page 132
132 chapter 2: coldfusion tags cfform description builds a form with cfml custom control tags; these provide more functionality than standard html form input elements. Category forms tags syntax name = "name" action = "form_action" preservedata = "yes" or "no" onsubmit = "javascript" target = "windo...
Page 133
Cfform 133 in addition to the listed attributes, you can use the following html attributes in the cfform tag. The tag does not use these attributes, but includes them in the form tag that it generates and returns to the browser: • class • enctype • id • onreset • style • target preservedata optional...
Page 134
134 chapter 2: coldfusion tags usage this tag requires an end tag. Some custom control tags that you can use within this tag require the client to download a java applet; they might execute slightly more slowly than using an html form element to get the same information. In addition to regular html ...
Page 135
Cfform 135 • html tags that can ordinarily be put within the html form tag. For example, you can use the html input tag to create a submit button in a cfform , without the other features of cfinput : example your radio button answer was yes your radio button answer was no your checkbox answer was ye...
Page 136
136 chapter 2: coldfusion tags rate your approval of this example from 1 to 10 by sliding control. 1 label = "sample slider" range = "1,10" message = "please enter a value from 1 to 10" scale = "1" bold = "no" italic = "no" refreshlabel = "no"> 10 label = "sample slider" range = "1,10" message = "pl...
Page 137
Cfftp 137 cfftp description lets users implement file transfer protocol (ftp) operations. Category file management tags , internet protocol tags syntax the tag syntax depends on the action attribute value. See the following sections: • “cfftp: opening and closing ftp server connections” on page 138 ...
Page 138
138 chapter 2: coldfusion tags cfftp: opening and closing ftp server connections description to establish a connection with an ftp server, you use the open action with a connection attribute. Syntax action = "action" username = "name" password = "password" server = "server" timeout = "timeout in sec...
Page 139
Cfftp: opening and closing ftp server connections 139 usage when you establish a connection with cfftp action="open" and specify a name in the connection attribute, coldfusion caches the connection so that you can reuse it to perform additional ftp operations. When use a cached connection for subseq...
Page 140
140 chapter 2: coldfusion tags stoponerror = "yes" name = "listfiles" directory = "/" connection = "my_query"> #name# close the connection: connection = "my_query" stoponerror = "yes"> did it succeed? #cfftp.Succeeded# connection = "my_query" stoponerror = "yes"> did it succeed? #cfftp.Succeeded#.
Page 141
Cfftp: connection: file and directory operations 141 cfftp: connection: file and directory operations description use this form of the cfftp tag to perform file and directory operations with cfftp . Syntax action = "action" username = "name" password = "password" name = "query_name" server = "server...
Page 142
142 chapter 2: coldfusion tags usage if you use connection caching to an active ftp connection, you do not have to respecify the username , password , or server connection attributes: changing a cached connection, such as changing retrycount or timeout values, might require reestablishing the connec...
Page 143
Cfftp: connection: file and directory operations 143 the cfftp.Returnvalue variable provides the return value for these actions: • getcurrentdir • getcurrenturl • existsdir • existsfile • exists for more information, see developing coldfusion mx applications. Caution: object (file and directory) nam...
Page 144
144 chapter 2: coldfusion tags action = "close" stoponerror = "yes"> did it succeed? #cfftp.Succeeded#.
Page 145
Cfftp: connection: file and directory operations 145 cfftp action = "listdir" description to access the columns in a query object, use this tag with action = " listdir" . Usage when you use this action, you must specify a value for the name attribute. This value holds the results of the listdir acti...
Page 146
146 chapter 2: coldfusion tags cffunction description defines a function that you can call in cfml. Required to defined coldfusion component methods. Category extensibility tags syntax name = "methodname" returntype = "datatype" roles = "securityroles" access = "methodaccess" output = "yes" or "no" ...
Page 147
Cffunction 147 usage the cffunction tag can define a function that you call in the same manner as a coldfusion built in function. To define a coldfusion component (cfc) method, you must use a cffunction tag. For information on using the cffunction tag. The following example shows cffunction tag attr...
Page 148
148 chapter 2: coldfusion tags access="remote" returntype="query" hint="this query returns all records in the employee database. It can drill-down or narrow the search, based on optional input parameters."> for information on using the cffunction tag for coldfusion components, see chapter 11, “build...
Page 149
Cfgraph 149 cfgraph description this tag is deprecated. Use the cfchart , cfchartdata , and cfchartseries tags instead. Displays data graphically. History coldfusion mx: deprecated this tag. It works differently than it did in coldfusion 5, and it might not work in later releases. The incompatibilit...
Page 150
150 chapter 2: coldfusion tags showvaluelabel • yes: displays values on mouse-click; • no: suppresses value displays • rollover: displays values on mouse-over. Valuelocation ignored url url of page to open if any item in the graph is clicked. The following variables may be used within the url; they ...
Page 151
Cfgraphdata 151 cfgraphdata description this tag is deprecated. Use the cfchart , cfchartdata , and cfchartseries tags instead. Displays a data point in a graph. Used within the cfgraph tag. History coldfusion mx: deprecated this tag. It works differently than in coldfusion 5 and might not work in l...
Page 152
152 chapter 2: coldfusion tags cfgrid description used within the cfform tag. Puts a grid control (a table of data) in a coldfusion form. To specify grid columns and row data, use the cfgridcolumn and cfgridrow tags, or use the query attribute, with or without cfgridcolumn tags. Category forms tags ...
Page 153
Cfgrid 153 deletebutton = "text" sortascendingbutton = "text" sortdescendingbutton = "text"> see also cfgridcolumn , cfgridrow , cfgridupdate , cfapplet , cfform , cfinput , cfselect , cfslider , cftextinput , cftree , cftreeitem history coldfusion mx: changed the rowheaderwidth attribute: coldfusio...
Page 154
154 chapter 2: coldfusion tags sort optional no the sort button performs simple text sort on column. User can sort columns by clicking column head or by clicking sort buttons. Not valid with selectmode=browse . • yes: sort buttons display on grid control • no font optional font of column data in the...
Page 155
Cfgrid 155 rowheight optional minimum row height, in pixels, of grid control. Used with cfgridcolumn type = "image" ; defines space for graphics to display in row. Rowheaders optional yes • yes: displays a column of numeric row labels in grid control • no rowheaderalign optional left • left: left-al...
Page 156
156 chapter 2: coldfusion tags usage you can populate a cfgrid with data from a cfquery . If you do not specify any cfgridcolumn entries, coldfusion generates a default set of columns, which includes each column in the query. A default header for each column is created by replacing hyphen or undersc...
Page 157
Cfgrid 157 simple selection data (selectmode = single, column, or row) the data that form variables return to the cfform 's action page contains information about which cells the user selected. In general, coldfusion makes this data available in the action page, as coldfusion variables in the form s...
Page 158
158 chapter 2: coldfusion tags form.#gridname#.#colname#: notset! Using the href attribute when specifying a url with grid items using the href attribute, the selectmode attribute value determines whether the appended key value is limited to one grid item or extends to a grid column or row. When a u...
Page 159
Cfgrid 159 tablename = "courselist" keyonly = "yes"> select course_id, dept_id, cornumber, corname, corlevel, cordesc from courselist order by dept_id asc, cornumber asc tablename = "courselist" keyonly = "yes"> select course_id, dept_id, cornumber, corname, corlevel, cordesc from courselist order b...
Page 160
160 chapter 2: coldfusion tags ....
Page 161
Cfgridcolumn 161 cfgridcolumn description used with the cfgrid tag in a cfform . Use this tag to specify column data in a cfgrid control. The font and alignment attributes used in cfgridcolumn override global font or alignment settings defined in cfgrid . Category forms tags syntax name = "column_na...
Page 162
162 chapter 2: coldfusion tags width optional; see description column head width column width, in pixels. Font optional as specified by cfgrid font of data in column. Fontsize optional as specified by cfgrid size of text in column. Italic optional as specified by cfgrid • yes: displays grid control ...
Page 163
Cfgridcolumn 163 select optional • yes: user can select the column in grid control. • no: user cannot edit column, regardless of cfgrid insert and delete values. If cfgrid selectmode = "row" or "browse" , this value is ignored. Display optional yes • yes • no: hides column type optional • image: gri...
Page 164
164 chapter 2: coldfusion tags using expressions in textcolor and bgcolor attributes the textcolor and bgcolor attributes accept the following kinds of values: • a color value literal • a hex value • an expression that selects a text color based on the evaluation of a boolean expression the syntax f...
Page 165
Cfgridcolumn 165 numberformat mask characters you can use the following numberformat attribute mask characters, which correspond to those in the numberformat function, to format output in u.S. Numeric and currency styles. For more information, see numberformat on page 631 . (this tag does not suppor...
Page 166
166 chapter 2: coldfusion tags cfgridrow description lets you define a cfgrid that does not use a query as source for row data. If a query attribute is specified in cfgrid, the cfgridrow tags are ignored. Category forms tags syntax data = "col1, col2, ..."> see also cfgrid , cfgridcolumn , cfgridupd...
Page 167
Cfgridrow 167 tablename="courselist" keyonly="yes"> select course_id, dept_id, cornumber, corname, corlevel, cordesc from courselist order by dept_id asc, cornumber asc tablename="courselist" keyonly="yes"> select course_id, dept_id, cornumber, corname, corlevel, cordesc from courselist order by dep...
Page 168
168 chapter 2: coldfusion tags this grid shows how the same grid can be built using cfgridrow with cfloop (i.E., defining query external to cfgrid, rather than within cfgrid). Delete="no" sort="yes" bold="no" italic="no" appendkey="no" highlighthref="no" griddataalign="left" gridlines="yes" rowheade...
Page 169
Cfgridupdate 169 cfgridupdate description used within a cfgrid tag. Updates data sources directly from edited grid data. This tag provides a direct interface with your data source. This tag applies delete row actions first, then insert row actions, then update row actions. If it encounters an error,...
Page 170
170 chapter 2: coldfusion tags example ... Tablename = "courselist" keyonly = "yes"> ... Tablequalifier optional table qualifier, if supported. Purpose: • sql server and oracle driver: name of database that contains table • intersolv dbase driver: directory of dbf files keyonly no applies to the upd...
Page 171
Cfheader 171 cfheader description generates custom http response headers to return to the client. Category data output tags , page processing tags syntax name = "header_name" value = "header_value" charset="charset"> or statuscode = "status_code" statustext = "status_text"> see also cfcache , cfflus...
Page 172
172 chapter 2: coldfusion tags usage if you use this tag after the cfflush tag on a page, an error is thrown. Example cfheader generates custom http response headers to return to the client. This example forces browser client to purge its cache of requested file. Statuscode required if name not spec...
Page 173
Cfhtmlhead 173 cfhtmlhead description writes text to the head section of a generated html page. It is useful for embedding javascript code, or putting other html tags, such as meta , link , title , or base in an html page header. Category page processing tags syntax text = "text"> see also cfcache ,...
Page 174
174 chapter 2: coldfusion tags cfhttp description generates an http request and handles the response from the server. Category forms tags , internet protocol tags syntax url = "server_url" port = "port_number" method = "method_name" proxyserver = "hostname" proxyport = "port_number" proxyuser = "use...
Page 175
Cfhttp 175 coldfusion mx: • added the charset and firstrowasheaders attributes. • changed secure sockets layer (ssl) support: coldfusion uses the sun jsse library, which supports 128-bit encryption, to support ssl. Attributes the following attributes control the http transaction and can be used for ...
Page 176
176 chapter 2: coldfusion tags proxyuser opt user name to provide to the proxy server. Proxypassword opt password to provide to the proxy server. Username opt a username. May be required by server. Password opt a password. May be required by server useragent opt cold fusion text to put in the user a...
Page 177
Cfhttp 177 throwonerror opt no • yes if the server returns an error response code, throws an exception that can be caught using the cftry and cfcatch or coldfusion error pages. • no does not throw an exception if an error response is returned. In this case, your application can use the cfhttp.Status...
Page 178
178 chapter 2: coldfusion tags the following attribute is used with the put method to determine how to send data specified with httpparam type="formfield" : the following attributes tell coldfusion to put the http response body in a file. You can put the response body in a file for get, post, put, d...
Page 179
Cfhttp 179 the following attributes tell coldfusion to convert the http response body into a coldfusion query object. They can be used with the get and post methods only: usage the cfhttp tag is a general-purpose tool for creating http requests and handling the returned results. It enables you to ge...
Page 180
180 chapter 2: coldfusion tags the http protocol is the backbone of the world wide web and is used for every web transaction. Because the cfhttp tag can generate most types of requests, it provides significant flexibility. Possible uses include: • interacting with dynamic web sites and services that...
Page 181
Cfhttp 181 building a query from a delimited text file the cfhttp tag can create a coldfusion query object form the response body. To do so, the response body must consist of lines of text, with each line having fields that are delimited by a character that identifies the column breaks. The default ...
Page 182
182 chapter 2: coldfusion tags http://www.Macromedia.Com/desdev/resources/macromedia_resources.Xml see http://www.Macromedia.Com/desdev/articles/xml_resource_feed.Html for more information on this feed ---> urladdress="http://www.Macromedia.Com/desdev/resources/macromedia_resources .Xml"> href=#item...
Page 183
Cfhttpparam 183 cfhttpparam description allowed inside cfhttp tag bodies only. Required for cfhttp post operations. Optional for all others. Specifies parameters to build an http request. Category forms tags , internet protocol tags syntax type = "transaction type" name = "data name" value = "data v...
Page 184
184 chapter 2: coldfusion tags attributes usage specifies header or body data to send in the http request. The type attribute identifies the information that the parameter specifies. A cfhttp tag can have multiple cfhttpparam tags, subject to the following limitations: • an xml type attribute cannot...
Page 185
Cfhttpparam 185 • a body type attribute cannot be used with additional body type attributes, or with xml , file , or formfield type attributes. • the xml and body type attributes cannot be used with the cfhttp tag trace method. • the file type attribute is only meaningfulwith the cfhttp tag post and...
Page 186
186 chapter 2: coldfusion tags cgi variable: #cgi.Cgi_test# note that the cgi variable is url encoded..
Page 187
Cfif 187 cfif description creates simple and compound conditional statements in cfml. Tests an expression, variable, function return value, or string. Used, optionally, with the cfelse and cfelseif tags. Category flow-control tags syntax html and cfml tags html and cfml tags html and cfml tags see a...
Page 188
188 chapter 2: coldfusion tags name/address:#name#, #address1#, #city#, #state# contact: #contact# if we would like more than one condition to be the case, we can ask for a list of the centers in san diego or santa ana. If the center does not follow this condition, we can use cfelse to show only the...
Page 189
Cfimpersonate 189 cfimpersonate description this tag is obsolete. Use the newer security tools; see “authentication functions” on page 367 and chapter 16, “securing applications,” in developing coldfusion mx applications. History coldfusion mx: this tag is obsolete. It does not work in coldfusion mx...
Page 190
190 chapter 2: coldfusion tags cfimport description you can use the cfimport tag to import either of the following: • all coldfusion pages in a directory, as a tag custom tag library. • a java server page (jsp) tag library. A jsp tag library is a packaged set of tag handlers that conform to the jsp ...
Page 191
Cfimport 191 jsp tags have fixed attributes; however, if the tag supports runtime attribute expressions, most tag libraries support the use of the syntax #expressions# . To reference a jsp tag in a cfml page, use the syntax . Set the prefix value in the prefix attribute. To use jsp custom tags in a ...
Page 192
192 chapter 2: coldfusion tags cfinclude description embeds references to coldfusion pages in cfml. You can embed cfinclude tags recursively. For another way to encapsulate cfml, see cfmodule on page 250 . (a coldfusion page was formerly sometimes called a coldfusion template or a template.) categor...
Page 193
Cfindex 193 cfindex description populates a verity search engine collection with an index of documents on a file system or of coldfusion query result sets. A collection must exist before it can be populated. A collection can be indexed in the following ways: • in coldfusion, with the cfindex tag • i...
Page 194
194 chapter 2: coldfusion tags attributes attribute req/opt default description collection required • name of a collection that is registered by coldfusion; for example, "personnel" • name and absolute path of a collection that is not registered by coldfusion; for example: "e:\collections\personnel"...
Page 195
Cfindex 195 usage this tag populates verity search engine collections with metadata from the following sources: • documents stored on a file system • coldfusion query result sets the following table shows the dependent relationships among this tag’s attribute values: query required if type = "custom...
Page 196
196 chapter 2: coldfusion tags for all action values of this tag except update , use the cflock tag to protect the collection during tag execution. For information on the file types you can use with the verity search engine, see article 22492, coldfusion server (versions 4.5 and higher): supported f...
Page 197
Cfindex 197 urlpath="http://localhost/cfdocs/snippets" custom1="custom1" custom2="custom2" recurse="no" extensions=".Htm, .Html, .Cfm, .Cfml" > collection="snippets" action="update" type="path" key="c:\inetpub\wwwroot\cfdocs\snippets" urlpath="http://localhost/cfdocs/snippets" custom1="custom1" cust...
Page 198
198 chapter 2: coldfusion tags query="book"> timeout="60"> collection="snippets" action="refresh" type="file" key="c:\inetpub\wwwroot\cfdocs\snippets\abs.Cfm" urlpath="http://localhost/" custom1="custom1" custom2="custom2" > timeout="60"> collection="snippets" action="refresh" type="file" key="c:\in...
Page 199
Cfindex 199 datasource="book"> select * from book where bookid='file' query="book"> --#description#-- query="book"> --#description#-- collection="snippets" action="delete" type="file" query="book" key="description" > timeout="60"> collection="snippets" action="delete" type="path" key="c:\inetpub\www...
Page 200
200 chapter 2: coldfusion tags timeout="60"> action="purge" collection="snippets"> timeout="60"> action="purge" collection="snippets"> action="purge" collection="snippets">.
Page 201
Cfinput 201 cfinput description used within the cfform tag, to place radio buttons, check boxes, or text boxes on a form. Provides input validation for the specified control type. Category forms tags syntax type = "input_type" name = "name" value = "initial_value" required = "yes" or "no" range = "m...
Page 202
202 chapter 2: coldfusion tags in addition to the listed attributes, you can use the following html attributes in the cfform tag without using the passthrough attribute. The tag does not use these attributes, but includes them in the html of the form tag that it generates and returns to the browser:...
Page 203
Cfinput 203 • class • id • onblur • onchange • onclick • ondblclick • onfocus • style • tabindex usage if the cfform preservedata attribute is true and the form posts back to the same page, the posted value of the cfinput control is used, instead of its value or checked attribute. If cfinput check b...
Page 204
204 chapter 2: coldfusion tags message = "enter a correctly formatted date (dd/mm/yy)" validate = "date" required = "no"> type = "submit" name = "" value = "send my information">.
Page 205
Cfinsert 205 cfinsert description inserts records in data sources from data in a coldfusion form or form scope. Category database manipulation tags syntax datasource = "ds_name" tablename = "tbl_name" tableowner = "owner" tablequalifier = "tbl_qualifier" username = "username" password = "password" f...
Page 206
206 chapter 2: coldfusion tags example tablename = "comments" formfields = "email,fromuser,subject,messtext,posted"> your record was added to the database. Tablename = "comments" formfields = "email,fromuser,subject,messtext,posted"> formfields="email,fromuser,subject,messtext,posted"> formfields="c...
Page 207
Cfinsert 207 name = "posted" value = "#now()#"> name = "" value = "insert my comment">.
Page 208
208 chapter 2: coldfusion tags cfinvoke description does either of the following: • invokes a component method from within a coldfusion page or component. • invokes a web service. This tag works as follows: • transiently instantiates a component or web service and invokes a method on it • invokes a ...
Page 209
Cfinvoke 209 inputparam1 = "value1" inputparam2 = "value2" ... Returnvariable = "var_name" ...> or component = "component name" name = "mystringname for instantiated object"> component = "#mystringname for instantiated component#" method = "method name" returnvariable = "variable name" argumentcolle...
Page 210
210 chapter 2: coldfusion tags attributes note: if you do not specify any the proxy attributes, and a corresponding system property is set (typically in the jvm startup arguments) coldfusion uses the system property value. Usage the following table shows when you can use each attribute: attribute re...
Page 211
Cfinvoke 211 if the component attribute specifies a component name, the component with the corresponding name is instantiated, the requested method is invoked, and then the component instance is immediately destroyed. If the attribute contains a reference to an instantiated component object, no inst...
Page 212
212 chapter 2: coldfusion tags #res# example2 this example uses syntax 1. Component="nasdaq.Quote" method="getlasttradeprice" argumentcollection="#args#" returnvariable="res"> #res# example3 this example uses syntax 2. Method = "a method name of mycomponent" returnvariable = "variable name"> example...
Page 213
Cfinvokeargument 213 cfinvokeargument description passes the name and value of a parameter to a component method or a web service. This tag is used within the cfinvoke tag. Category extensibility tags syntax name="argument name" value="argument value"> see also cfargument , cfcomponent , cffunction ...
Page 214
214 chapter 2: coldfusion tags name="sourcedata" value="hello world, friend"> #varname#.
Page 215
Cfldap 215 cfldap description provides an interface to a lightweight directory access protocol (ldap) directory server, such as the netscape directory server. Category forms tags , internet protocol tags syntax server = "server_name" port = "port_number" username = "name" password = "password" actio...
Page 216
216 chapter 2: coldfusion tags attributes attribute req/opt default description server required host name or ip address of ldap server. Port optional 389 port username required if secure = "cfssl_basic" (anonymous) user id password required if secure = "cfssl_basic" password that corresponds to user...
Page 217
Cfldap 217 sort optional attribute(s) by which to sort query results. Use a comma delimiter. Sortcontrol optional asc • nocase: case-insensitive sort • asc: ascending (a to z) case-sensitive sort • desc: descending (z to a) case-sensitive sort you can enter a combination of sort types; for example, ...
Page 218
218 chapter 2: coldfusion tags usage if you use the query action, cfldap creates a query object, allowing access to information in the query variables, as follows: if you use the security="cfssl_basic" option, coldfusion determines whether to trust the sever by comparing the server’s certificate wit...
Page 219
Cfldap 219 provides an interface to ldap directory servers. The example uses the university of connecticut public ldap server. For more public ldap servers, see http://www.Emailman.Com. Enter a name and search the public ldap resource. An asterisk before or after the name acts as a wildcard. Server ...
Page 220
220 chapter 2: coldfusion tags cflocation description stops execution of the current page and opens a coldfusion page or html file. Category flow-control tags , page processing tags syntax url = "url" addtoken = "yes" or "no"> see also cfabort , cfbreak , cfexecute , cfexit , cfif , cfloop , cfswitc...
Page 221
Cflock 221 cflock description ensures the integrity of shared data. Instantiates the following kinds of locks: • exclusive allows single-thread access to the cfml constructs in its body. The tag body can be executed by one request at a time. No other requests can start executing code within the tag ...
Page 222
222 chapter 2: coldfusion tags note: limit the scope of code that updates shared data structures, files, and cfxs. Exclusive locks are required to ensure the integrity of updates, but read-only locks are faster. In a performance-sensitive application, substitute read-only locks for exclusive locks w...
Page 223
Cflock 223 these examples show situations that cause deadlocks: the following deadlock could occur if you tried to nest an exclusive lock inside a read lock: the following code shows this scenario: ............... ......... To avoid a deadlock, everyone who nests locks must do so in a well-specified...
Page 224
224 chapter 2: coldfusion tags sessiontimeout = #createtimespan(0,0, 0, 60)# sessionmanagement = "yes"> timeout = "30" type = "exclusive"> cflock example sessiontimeout = #createtimespan(0,0, 0, 60)# sessionmanagement = "yes"> timeout = "30" type = "exclusive"> timeout = "30" type = "exclusive"> tha...
Page 225
Cflock 225 e-turtleneck has sold #application.Number# turtlenecks to date. Congratulations! You selected the most comfortable turtleneck in the world. Please select color and size. Red white blue turquoise black forest green xxsmall xsmall small medium large xlarge.
Page 226
226 chapter 2: coldfusion tags cflog description writes a message to a log file. Category data output tags syntax text = "text" log = "log type" file = "filename" type = "message type" application = "application name yes or no"> see also cfcol , cfcontent , cfoutput , cftable history coldfusion mx: ...
Page 227
Cflog 227 usage this tag logs custom messages to standard or custom log files. You can specify a file for the log message or send messages to the default application or scheduler log. The log message can include coldfusion expressions. Log files must have the suffix .Log and must be located in the c...
Page 228
228 chapter 2: coldfusion tags cflogin description a container for user login and authentication code. Coldfusion runs the code in this tag if a user is not already logged in. You put code in the tag that authenticates the user and identifies the user with a set of roles. Used with cfloginuser tag. ...
Page 229
Cflogin 229 the cflogin tag has a built-in cflogin structure that contains two variables, cflogin.Name and cflogin.Password, if the page is executing in response to any of the following: • submission of a form that contains input fields with the names j_username and j_password . • a request that use...
Page 230
230 chapter 2: coldfusion tags cfloginuser description identifies an authenticated user to coldfusion. Specifies the user id and roles. Used within a cflogin tag. Category extensibility tags syntax name = "name" password = "password-string" roles = "roles"> see also cflogin , cflogout , getauthuser ...
Page 231
Cflogout 231 cflogout description logs the current user out. Removes knowledge of the user id, password, and roles from the server. If you do not use this tag, the user is automatically logged out when the session ends. Category extensibility tags syntax see also cflogin , cfloginuser , chapter 16, ...
Page 232
232 chapter 2: coldfusion tags cfloop description looping is a programming technique that repeats a set of instructions or displays output repeatedly until one or more conditions are met. This tag supports the following types of loops: • “cfloop: index loop” on page 233 • “cfloop: conditional loop” ...
Page 233
Cfloop: index loop 233 cfloop: index loop description an index loop repeats for a number of times that is determined by a numeric value. An index loop is also known as a for loop. Syntax index = "parameter_name" from = "beginning_value" to = "ending_value" step = "increment"> ... Html or cfml code ....
Page 234
234 chapter 2: coldfusion tags in this example, the code loops four times, displaying the index value each time. The value of j is decreased by one for each iteration. This does not affect the value of to , because it is a copy of j that is made before entering the loop. The loop index is #loopcount...
Page 235
Cfloop: conditional loop 235 cfloop: conditional loop description a conditional loop iterates over a set of instructions as long as a condition is true. To use this type of loop correctly, the instructions must change the condition every time the loop iterates, until the condition is false. Conditio...
Page 236
236 chapter 2: coldfusion tags cfloop: looping over a query description a loop over a query executes for each record in a query record set. The results are similar to those of the cfoutput tag. During each iteration, the columns of the current row are available for output. The cfloop tag loops over ...
Page 237
Cfloop: looping over a query 237 datasource = "library" maxrows = "5"> select templatename from templates.
Page 238
238 chapter 2: coldfusion tags cfloop: looping over a list or file description looping over a list steps through elements contained in any of these entities: • a variable • a value that is returned from an expression • a file syntax index = "index_name" list = "list_items" delimiters = "item_delimit...
Page 239
Cfloop: looping over a list or file 239 cfloop: looping over a com collection or structure description the cfloop collection attribute loops over every object within a com/dcom collection object, or every element in a structure: • a com/dcom collection object is a set of similar items referenced as ...
Page 240
240 chapter 2: coldfusion tags cfmail description sends an e-mail message that optionally contains query output, using an smtp server. Category forms tags , internet protocol tags syntax to = "recipient" from = "sender" cc = "copy_to" bcc = "blind_copy_to" subject = "msg_subject" replyto = "reply_to...
Page 241
Cfmail 241 attributes attribute req/opt default description to required message recipient e-mail addresses. • static address. For example, " support@macromedia.Com " • variable that contains an address. For example, " #form.Email# " . • name of a query column that contains an address. For example, "...
Page 242
242 chapter 2: coldfusion tags charset optional character encoding selected in coldfusion mx administrator mail page; default is utf-8 character encoding of the mail message, including the headers. The following list includes commonly used values: • utf-8 • iso-8859-1 • windows-1252 • us-ascii • shi...
Page 243
Cfmail 243 usage sends a mail message to the specified address. Mail messages can include attachements. The tag body can include cfml code to generate mail output. The cfmailparam and cfmailpart tags can only be used in the cfmail tag body. Mail messages can be single or multipart. If you send a mul...
Page 244
244 chapter 2: coldfusion tags specifying mail servers the server attribute can specify one or more mail servers. Note: if you specify multiple mail servers in coldfusion mx standard, the cfmail tag uses only the first server in the specification. Coldfusion logs a warning message to the mail log fi...
Page 245
Cfmail 245 --->.
Page 246
246 chapter 2: coldfusion tags cfmailparam description attaches a file or adds a header to an e-mail message. Can only be used in the cfmail tag. You can use more than one cfmailparam tag within a cfmail tag. Category forms tags , internet protocol tags syntax to = "recipient" subject = "msg_subject...
Page 247
Cfmailparam 247 please review the new logo. Tell us what you think..
Page 248
248 chapter 2: coldfusion tags cfmailpart description specifies one part of a multipart e-mail message. Can only be used in the cfmail tag. You can use more than one cfmailpart tag within a cfmail tag. Category forms tags , internet protocol tags syntax ... > (optional cfmailparam entries) type="mim...
Page 249
Cfmailpart 249 usage use this tag to create mail messages with alternative versions of the message that duplicate the content in multiple formats. The most common use is to send a plain text version of the message that can be read by all mail readers followed by a version formatted in html for displ...
Page 250
250 chapter 2: coldfusion tags cfmodule description invokes a custom tag for use in coldfusion application pages. This tag processes custom tag name conflicts. For more information, see chapter 9, “creating and using custom cfml tags,” in developing coldfusion mx applications. Category application f...
Page 251
Cfmodule 251 usage to name a coldfusion page that contains the custom tag definition, including its path, use the template attribute. To refer to the custom tag in the coldfusion installation directory, using dot notation to indicate its location, use the name attribute. On unix systems, coldfusion ...
Page 252
252 chapter 2: coldfusion tags here is another way to invoke the custom tag, using the name attribute. #htmlcodeformat(" name='mytag' x=3 attributecollection=##attrcollection1## y=4>")# name='mytag' x=3 attributecollection=##attrcollection1## y=4>")# the result: #result# here is the short cut to inv...
Page 253
Cfobject 253 cfobject description creates a coldfusion object, of a specified type. Note: you can enable and disable this tag in the coldfusion administrator page, under coldfusion basic security, tag restrictions. Category extensibility tags syntax the tag syntax depends on the object type. Some ty...
Page 254
254 chapter 2: coldfusion tags cfobject: com object description creates and manipulates a component object model (com) object. Invokes a registered automation server object type. For information on oleview, and about com and dcom, see the microsoft ole development website: www.Microsoft.Com. To use ...
Page 255
Cfobject: com object 255 example type = "com" class = allaire.Docex1.1 name = "obj"> this object has #obj.Count# items. Type = "com" class = allaire.Docex1.1 name = "obj"> this object has #obj.Count# items. The last name in the third item is #emp.Lastname#. Looping through all items in the collectio...
Page 256
256 chapter 2: coldfusion tags cfobject: component object description creates an instance of a coldfusion component (cfc) object. Syntax name = "variable name" component = "component name"> see also cfcollection , cfcomponent , cfexecute , cfindex , cfreport , cfsearch , cfwddx attributes usage when...
Page 257
Cfobject: corba object 257 cfobject: corba object description calls methods on a registered corba object. Syntax type = "corba" context = "context" class = "file or naming service" name = "text" locale = "type-value arguments"> see also cfcollection , cfexecute , cfindex , cfreport , cfsearch , cfwd...
Page 258
258 chapter 2: coldfusion tags example context = "ior" class = "c:\\myobject.Ior" name = "getname"> context = "ior" class = "c:\\myobject.Ior" name = "getname">.
Page 259
Cfobject: java or ejb object 259 cfobject: java or ejb object description creates and manipulates a java and enterprise java bean (ejb) object. Syntax type = "java" action = "create" class = "java class" name = "object name"> see also cfcollection , cfexecute , cfindex , cfreport , cfsearch , cfwddx...
Page 260
260 chapter 2: coldfusion tags example action = "create" type = "java" class = "myclass" name = "myobj"> action = "create" type = "java" class = "weblogic/jndi/environment" name = "wlenv"> share value = #value# action = "create" type = "java" class = "myclass" name = "myobj"> action = "create" type ...
Page 261
Cfobject: web service object 261 cfobject: web service object description creates a web service proxy object. Syntax webservice= "http://....?Wsdl" or "name set in administrator" name = "myobjectname"> see also cfcollection , cfexecute , cfindex , cfreport , cfsearch , cfwddx attributes usage instan...
Page 262
262 chapter 2: coldfusion tags cfobjectcache description flushes the query cache. Category database manipulation tags syntax action = "clear"> see also cfobject history coldfusion 5: added this tag. Attributes attribute req/opt default description action required clear: clears queries from the cache...
Page 263
Cfoutput 263 cfoutput description displays output that can contain the results of processing coldfusion variables and functions. Can loop over the results of a database query. Category data output tags syntax query = "query_name" group = "query_column" groupcasesensitive = "yes" or "no" startrow = "...
Page 264
264 chapter 2: coldfusion tags this tag requires an end tag. Example select dept_id, corname, corlevel from courselist order by dept_id, corlevel, corname cfoutput tells coldfusion server to begin processing, and then to hand back control of page rendering to the web server. For example, to show tod...
Page 265
Cfparam 265 cfparam description tests for a parameter’s existence, tests its data type, and, if a default value is not assigned, optionally provides one. Category variable manipulation tags syntax name = "param_name" type = "data_type" default = "value"> see also cfcookie , cfregistry , cfsaveconten...
Page 266
266 chapter 2: coldfusion tags • to test whether an optional variable exists, use this tag with the name and default attributes. If the variable does not exist, it is created and set to the default attribute value. If the variable exists, processing continues; the value is not changed. If you specif...
Page 267
Cfpop 267 cfpop description retrieves or deletes e-mail messages from a pop mail server. Category forms tags , internet protocol tags syntax server = "servername" port = "port_number" username = "username" password = "password" action = "action" name = "queryname" messagenumber = "number" uid = "num...
Page 268
268 chapter 2: coldfusion tags usage the cfpop tag retrieves one or more mail messages from a pop server and populates a coldfusion query object with the resulting messages, one message per row. Alternatively, it deletes one or more messages from the pop server. To optimize performance, two retrieve...
Page 269
Cfpop 269 cfpop query variables the following table describes the variables that provide information about the query that is returned by cfpop : query message header and body columns the following table lists the message header and body columns that are returned if action = " getheaderonly" or " get...
Page 270
270 chapter 2: coldfusion tags to create a coldfusion date/time object from the date-time string that is extracted from a mail message in the queryname.Date column, use the following table: note: to set the default display format of date, time, number, and currency values, use the setlocale function...
Page 271
Cfprocessingdirective 271 cfprocessingdirective description provides the following insformation to coldfusion on how to process the current page: • specifies whether to remove excess whitespace character from coldfusion generated content in the tag body. • identifies the character encoding (characte...
Page 272
272 chapter 2: coldfusion tags attributes usage the cfprocssingdirective tag has limitations that depend on the attribute you use. For this reason, macromedia recommends that you include either the pageencoding or suppresswhitespace attribute in a cfprocessingdirective tag, not both. To specify both...
Page 273
Cfprocessingdirective 273 • if a page has a byte order mark (bom), and a pageengoding attribute specifies an encoding that differs from the bom, coldfusion generates an error. The following rules apply to the suppresswhitespace attribute: • you can specify the suppresswhitespace attribute value as a...
Page 274
274 chapter 2: coldfusion tags cfprocparam description defines stored procedure parameters. This tag is nested within a cfstoredproc tag. Category database manipulation tags syntax type = "in" or "out" or "inout" variable = "variable name" value = "parameter value" cfsqltype = "parameter datatype" m...
Page 275
Cfprocparam 275 usage use this tag to identify stored procedure parameters and their data types. Code one cfprocparam tag for each parameter. The parameters that you code vary based on parameter type and dbms. Coldfusion mx supports positional parameters only and you must code cfprocparam tags in th...
Page 276
276 chapter 2: coldfusion tags example the following example shows how to invoke an oracle 8 pl/sql stored procedure. It makes use of oracle 8 support of the reference cursor type. The following package, foo_data, houses a procedure refcurproc that declares output parameters as reference cursor: • p...
Page 277
Cfprocparam 277 the second result set: the output parameter is:'#foo#'.
Page 278
278 chapter 2: coldfusion tags cfprocresult description associates a query object with a result set returned by a stored procedure. Other coldfusion tags, such as cfoutput and cftable , use this query object to access the result set. This tag is nested within a cfstoredproc tag. Category database ma...
Page 279
Cfprocresult 279 cfsqltype = cf_sql_integer value = "1" dbvarname = @param1> variable = foo dbvarname = @param2> the output param value: ’#foo#’ the results information #name#,#date_col# cfsqltype = cf_sql_integer value = "1" dbvarname = @param1> variable = foo dbvarname = @param2> the output param ...
Page 280
280 chapter 2: coldfusion tags cfproperty description defines properties of a coldfusion component (cfc). Used to create complex data types for web services. The attributes of this tag are exposed as component metadata and are subject to inheritance rules. Category extensibility tags syntax name="na...
Page 281
Cfproperty 281 usage you must position cfproperty tags at the beginning of a component, above executable code and function definitions. If a component is not used as a web service, the cfproperty only provides metadata information when the component is viewed using introspection, for example, by ope...
Page 282
282 chapter 2: coldfusion tags cfquery description passes queries or sql statements to a data source. Macromedia recommends that you use the cfqueryparam tag within every cfquery tag, to help secure your databases from unauthorized users. For more information, see: • security bulletin asb99-04, "mul...
Page 283
Cfquery 283 attributes usage because the timeout parameter only the maximum time for each sub-operation of a query, the cumulative time may exceed its value. To set a timeout for a page that might get a very large result set, set the administrator > server settings > timeout requests option to an ap...
Page 284
284 chapter 2: coldfusion tags this tag creates a query object, providing this information in query variables: you can cache query results and execute stored procedures. For information about this and about displaying cfquery output, see developing coldfusion mx applications. The caching page of the...
Page 285
Cfquery 285 state query="getparks" startrow="#startrow#" maxrows="#maxrows#"> #getparks.Currentrow# #parkname# #region# #state# query="getparks" startrow="#startrow#" maxrows="#maxrows#"> #getparks.Currentrow# #parkname# #region# #state# #evaluate(startrow + maxrows)# ">see next #maxrows# rows.
Page 286
286 chapter 2: coldfusion tags cfqueryparam description verifies the data type of a query parameter and, for dbmss that support bind variables, enables coldfusion to use bind variables in the sql statement. Bind variable usage enhances performance when executing a cfquery statement multiple times. T...
Page 287
Cfqueryparam 287 attributes attribute req/opt default description value required value that coldfusion passes to the right of the comparison operator in a where clause. If cfsqltype is a date or time option, ensure that the date value uses your dbms-specific date format. Use the createodbcdatetime o...
Page 288
288 chapter 2: coldfusion tags usage use cfqueryparam in any sql statement (for example, select, insert, update, and delete) that uses coldfusion variables. For maximum validation of string data, specify the maxlength attribute. This tag does the following: • allows the use of sql bind parameters, w...
Page 289
Cfqueryparam 289 name="getfirst" datasource="cfsnippets"> select * from employees where lastname= value="#lastname#" cfsqltype="cf_sql_varchar" maxlength="17"> name="getfirst" datasource="cfsnippets"> select * from employees where lastname= value="#lastname#" cfsqltype="cf_sql_varchar" maxlength="17...
Page 290
290 chapter 2: coldfusion tags cfregistry description this tag is deprecated for the unix platform. Reads, writes, and deletes keys and values in the system registry. Provides persistent storage of client variables. Note: for this tag execute, it must be enabled in the coldfusion administrator. For ...
Page 291
Cfregistry 291 cfregistry action = "getall" description returns all registry keys and values defined in a branch. You can access the values as you would any record set. Syntax action = "getall" branch = "branch" type = "data type" name = "query name" sort = "criteria"> attributes usage this tag retu...
Page 292
292 chapter 2: coldfusion tags cfregistry action = "get" description accesses a registry value and stores it in a coldfusion variable. Syntax action = "get" branch = "branch" entry = "key or value" variable = "variable" type = "data type"> attributes usage if the value does not exist, cfregistry doe...
Page 293
Cfregistry 293 cfregistry action = "set" description adds a registry key, adds a value, or updates a value. Syntax action = "set" branch = "branch" entry = "key or value" type = "value type" value = "data"> attributes usage if it does not exist , cfregistry creates the key or value. Example branch =...
Page 294
294 chapter 2: coldfusion tags cfregistry action = "delete" description deletes a registry key or value. Syntax action = "delete" branch = "branch" entry = "keyorvalue"> attributes usage if you delete a key, cfregistry also deletes values and subkeys defined beneath it. Example branch = "hkey_local_...
Page 295
Cfreport 295 cfreport description runs a predefined crystal reports report. Applies only to windows systems. Uses the cfcrystal.Exe file to generate reports. Sets parameters in the crystal reports engine according to its attribute values. Category extensibility tags syntax report = "report_path" dat...
Page 296
296 chapter 2: coldfusion tags usage this tag requires an end tag. Example cfreport lets reports from the crystal reports professional report writer display through a coldfusion interface. To run, the tag requires the name of the report. Cfreport can also pass information to the report file displaye...
Page 297
Cfrethrow 297 cfrethrow description rethrows the currently active exception. Preserves the exception’s cfcatch . Type and cfcatch.Tagcontext variable values. Category exception handling tags , extensibility tags syntax see also cferror , cfthrow , cftry usage use this tag within a cfcatch block. Thi...
Page 298
298 chapter 2: coldfusion tags cfreturn description returns result values from a component method. Contains an expression returned as result of the function. Return value an expression; the result of the function from which this tag is called. Category extensibility tags syntax expr> see also cfargu...
Page 299
Cfreturn 299.
Page 300
300 chapter 2: coldfusion tags cfsavecontent description saves the generated content of the cfsavecontent tag, including the results of evaluating expressions and executing custom tags, in the specified variable. Category variable manipulation tags syntax variable = "variable name"> the content vari...
Page 301
Cfschedule 301 cfschedule description provides a programmatic interface to the coldfusion scheduling engine. Can run a cfml page at scheduled intervals, with the option to write the page output to a static html page. This feature enables you to schedule pages that publish data, such as reports, with...
Page 302
302 chapter 2: coldfusion tags attributes attribute req/opt default description action required • delete: deletes the specified task • update: updates an existing task or creates a new task, if one with the name specified by the task attribute does not exist • run: executes the specified task task r...
Page 303
Cfschedule 303 usage this tag and the coldfusion mx administrator scheduled task page schedule coldfusion tasks. Tasks that you add or change using this tag are visible in the aministrator. You can disable this tag in the administrator sandbox/resource security page. This tag’s success or failure st...
Page 304
304 chapter 2: coldfusion tags cfscript description encloses a code block that contains cfscript statements. Category application framework tags , other tags syntax cfscript code here see also cfinvoke , cfmodule , createobject , chapter 6, “extending coldfusion pages with cfml scripting,” in develo...
Page 305
Cfscript 305 you cannot use the elseif construct within a cfscript tag. You can use code such as the following: else if ( condition ) { ... } exception handling with the cfscript tag to handle exceptions with this tag, use try and catch statements, which are equivalent to the cftry and cfcatch tags....
Page 306
306 chapter 2: coldfusion tags xlatstring = ws.Babelfish("en_es", "hello world, friend"); writeoutput(xlatstring); for more information, see chapter 32, “using web services,” in developing coldfusion mx applications. Example this simple example shows variable declaration and manipulation. Y = x; z =...
Page 307
Cfsearch 307 cfsearch description searches verity collections using coldfusion or k2server, whichever search engine a collection is registered by. (coldfusion can also search collections that have not been registered, with the cfcollection tag.) a collection must be created and indexed before this t...
Page 308
308 chapter 2: coldfusion tags • changed verity operations behavior: coldfusion supports verity operations on acrobat pdf files. • changed multiple collection behavior: this tag can search multiple collections. In a multiple collection search, you cannot combine collections that are registered with ...
Page 309
Cfsearch 309 ■ cf_root\lib\common\style\file • unix: ■ cf_root/lib/common/style (typically, cf_root = /opt/coldfusionmx) ■ cf_root/lib/common/style/custom ■ cf_root/lib/common/style/file note: to search for a character such as an angle bracket (), you must use a criteria attribute value such as "<...
Page 310
310 chapter 2: coldfusion tags you can use query result columns in standard cfml expressions, preceding the result column name with the name of the query, as follows: #docsearch.Url# #docsearch.Key# #docsearch.Title# #docsearch.Score# example name="name" collection="snippets,syntax,snippets" criteri...
Page 311
Cfsearch 311 criteria = "cf_key=bookid2"> url=#book.Url# key=#book.Key# title=#book.Titlee# score=#book.Score# custom1=#book.Custom1# custom2=#book.Custom2# summary=#book.Summary# recordcount=#book.Recordcount# currentrow=#book.Currentrow# columnlist=#book.Columnlist# recordssearched=#book.Recordsse...
Page 312
312 chapter 2: coldfusion tags cfselect description constructs a drop-down list box form control. Used within a cfform tag. You can populate the list from a query, or by using the html option tag. Category forms tags syntax name = "name" required = "yes" or "no" message = "text" onerror = "text" siz...
Page 313
Cfselect 313 in addition to the listed attributes, you can use the following html attributes in the cfform tag without using the passthrough attribute. The tag does not use these attributes, but includes them in the html of the form tag that it generates and returns to the browser: • class • id • on...
Page 314
314 chapter 2: coldfusion tags example select emp_id, firstname, lastname, email, phone, department from employees where 0=0 and lastname = '#employeenames#' employee" to see expanded information. Message = "select an employee name" size = "#getemployees.Recordcount#" query = "getemployees" value = ...
Page 315
Cfselect 315 expand="no" queryasroot="no"> queryasroot="no" expand="no"> expand="no" queryasroot="no"> queryasroot="no" expand="no"> expand="no" queryasroot="no"> cfgrid presentation of data width="600" query="getemployees" insert="no" delete="no" sort="no" font="verdana" bold="no" italic="no" appen...
Page 316
316 chapter 2: coldfusion tags cfservlet description this tag is deprecated. Executes a java servlet on a jrun engine. To access servlets that run on the same server as coldfusion, use code such as the following, in which path specifies a servlet, jsp, or anything else: getpagecontext().Include(path...
Page 317
Cfservletparam 317 cfservletparam description this tag is deprecated. A child tag of the cfservlet tag. Passes data to a servlet. Each cfservletparam tag within the cfservlet block passes a separate item of data to the servlet. To access servlets that run on the same server as coldfusion, use code s...
Page 318
318 chapter 2: coldfusion tags cfset description sets a value in coldfusion. Used to create a variable, if it does not exist, and assign it a value. Also used to call functions. Category variable manipulation tags syntax var variable_name = expression > see also cfcookie , cfparam , cfregistry , cfs...
Page 319
Cfset 319 function local variables the var keyword specifies that the variable being defined is only available inside the body of a function that you define using the cffunction tag. The variable value that is set in one invocation of the function is not available in any other invocation of the func...
Page 320
320 chapter 2: coldfusion tags in addition, cfset can be used to pass variables from other pages, such as this example, which takes the url parameter test from this link: ( #urlencodedformat("hey, you, get off of my cloud")# ">click here) to display a message: #url.Test# cfset can also be used to co...
Page 321
Cfsetting 321 cfsetting description controls aspects of page processing, such as the output of html code in pages. Category page processing tags , variable manipulation tags syntax enablecfoutputonly = "yes" or "no" showdebugoutput = "yes" or "no" requesttimeout = "value in seconds" > see also cfcac...
Page 322
322 chapter 2: coldfusion tags if you nest cfsetting tags: to make html output visible, you must match each enablecfoutputonly = "yes" statement with an enablecfoutputonly = "no" statement. For example, after five enablecfoutputonly = "yes" statements, to enable html output, you must have five corre...
Page 323
Cfsilent 323 cfsilent description suppresses output produced by cfml within a tag’s scope. Category data output tags , page processing tags syntax ... See also cfcache , cfflush , cfheader , cfhtmlhead , cfinclude , cfsetting usage this tag requires an end tag. Example inside cfsilent block b-a = #c...
Page 324
324 chapter 2: coldfusion tags cfslider description puts a slider control, for selecting a numeric value from a range, in a coldfusion form. The slider moves over the slider groove. As the user moves the slider, the current value displays. Used within a cfform tag. Category forms tags syntax name = ...
Page 325
Cfslider 325 refreshlabel optional yes • yes: when user moves slider, label is refreshed • no range optional "0,100" numeric slider range values. Separate values with a comma. Scale optional unsigned integer. Defines slider scale, within range. For example, if range = "0,1000" and scale = "100" , th...
Page 326
326 chapter 2: coldfusion tags tickmarklabels optional no • yes: numeric tickmarks based on the value of the range and scale attributes. • no: prevents label text from displaying • comma-delimited list of strings for tickmark labels; for example, "ten, twenty, thirty, forty" if you do not specify en...
Page 327
Cfslider 327 usage this tag requires the client to download a java applet. Using this tag may be slightly slower than using an html form element to display the same information. For this tag to work properly. The browser must be javascript-enabled. If the following conditions are true, a user’s sele...
Page 328
328 chapter 2: coldfusion tags cfstoredproc description executes a stored procedure in a server database. It specifies database connection information and identifies the stored procedure. Category database manipulation tags syntax procedure = "procedure name" datasource = "ds_name" username = "usern...
Page 329
Cfstoredproc 329 • cfprocparam if the stored procedure uses input or output parameters, code one cfprocparam tag per parameter. Additionally, you must code cfprocparam tags in the same order as the parameters in the stored procedure definition. If you set returncode = "yes" , this tag sets the varia...
Page 330
330 chapter 2: coldfusion tags cfswitch description evaluates a passed expression and passes control to the cfcase tag that matches the expression result. You can, optionally, code a cfdefaultcase tag, which receives control if there is no matching cfcase tag value. Category flow-control tags syntax...
Page 331
Cfswitch 331 each time the case is fulfilled, the specific information is printed; if the case is not fulfilled, the default case is output #firstname# #lastname# is in sales #firstname# #lastname# is in accounting #firstname# #lastname# is in administration #firstname# #lastname# is not in sales, a...
Page 332
332 chapter 2: coldfusion tags cftable description builds a table in a coldfusion page. This tag renders data as preformatted text, or, with the htmltable attribute, in an html table. If you don't want to write html table tag code, or if your data can be presented as preformatted text, use this tag....
Page 333
Cftable 333 usage this tag aligns table data, sets column widths, and defines column heads. At least one cfcol tag is required within this tag. You must put cfcol and cftable tags adjacent in a page. The only tag that you can nest within this tag is the cfcol tag. You cannot nest cftable tags. To di...
Page 334
334 chapter 2: coldfusion tags cftextinput description puts a single-line text entry box in a cfform tag and controls its display characteristics. Category forms tags syntax name = "name" value = "text" required = "yes" or "no" range = "min_value, max_value" validate = "data_type" pattern = "java re...
Page 335
Cftextinput 335 validate optional • date: verifies format mm/dd/yy. • eurodate: verifies date format dd/mm/yyyy. • time: verifies time format hh:mm:ss. • float: verifies floating point format. • integer: verifies integer format. • telephone: verifies telephone format ###-###-####. The separator can ...
Page 336
336 chapter 2: coldfusion tags usage this tag requires the client to download a java applet. Downloading an applet takes time; therefore, using this tag might be slightly slower than using an html form element or the cfinput tag to get the same information. For this tag to work properly. The browser...
Page 337
Cftextinput 337 • the cfform action attribute posts to the same page as the form itself (this is the default), or the action page has a form that contains controls with the same names as corresponding controls on the user entry form for more information, see cfform . If the cfform preservedata attri...
Page 338
338 chapter 2: coldfusion tags cfthrow description throws a developer-specified exception, which can be caught with a cfcatch tag that has any of the following type attribute options: • type = "custom_type" • type = "application" • type = "any" category exception handling tags , flow-control tags sy...
Page 339
Cfthrow 339 usage use this tag within a cftry block, to throw an error. The cfcatch block can access accompanying information, as follows: • message, with cfcatch.Message • detail, with cfcatch.Detail • error code, with cfcatch.Errorcode to get more information, use cfcatch.Tagcontext . This array s...
Page 340
340 chapter 2: coldfusion tags (#scurrent["line"]#,#scurrent["column"]#) #scurrent["template"]# example2 the following example shows how to throw an exception from a component method: select lastname, firstname, email from tblemployees where lastname like '#arguments.Lastname#' type="noqueryresult" ...
Page 341
Cftrace 341 cftrace description displays and logs debugging data about the state of an application at the time the cftrace tag executes. Tracks runtime logic flow, variable values, and execution time. Displays output at the end of the request or in the debugging section at the end of the request; or...
Page 342
342 chapter 2: coldfusion tags usage you cannot put application code within this tag. (this avoids problems that can occur if you disable debugging.) this tag is useful for debugging cfml code during application development. You can display cftrace tag output in the following ways: • as a section in...
Page 343
Cftransaction 343 cftransaction description instructs the database management system to treat multiple database operations as a single transaction. Provides database commit and rollback processing. Category database manipulation tags syntax action = "begin" or "commit" or "rollback" isolation = "rea...
Page 344
344 chapter 2: coldfusion tags insert into courses (number, descript) values ('#mynumber#', '#mydescription#') insert into courselist (cornumber, cordesc, dept_id, corname, corlevel, lastupdate) values ('#mynumber#', '#mydescription#', '#mydepartment#', '#mydescription#', '#mycorlevel#', #now()#) --...
Page 345
Cftree 345 cftree description inserts a tree control in a form. Validates user selections. Used within a cftree tag block. You can use a coldfusion query to supply data to the tree. Category forms tags syntax required = "yes" or "no" delimiter = "delimiter" completepath = "yes" or "no" appendkey = "...
Page 346
346 chapter 2: coldfusion tags completepath optional no; tree name is returned as root • yes: passes the root part of treename.Path form variable when cftree is submitted • no, or omitted: root level of form variable is not passed; path value starts with the first node for the preservedata attribute...
Page 347
Cftree 347 usage this tag requires the client to download a java applet. Downloading an applet takes time; therefore, using this tag might be slightly slower than using an html form element or the cfinput tag to get the same information. For this tag to work properly. The browser must be javascript-...
Page 348
348 chapter 2: coldfusion tags select emp_id, firstname, lastname, email, phone, department from employees where lastname = ’#employeenames#’ to see expanded information. Size = "#getemployees.Recordcount#" query = "getemployees" value = "lastname" required = "no"> select all size = "#getemployees.R...
Page 349
Cftreeitem 349 cftreeitem description populates a form tree control, created with the cftree tag, with elements. To display icons, you can use the img values that coldfusion provides, or reference your own icons. Category forms tags syntax value = "text" display = "text" parent = "parent_name" img =...
Page 350
350 chapter 2: coldfusion tags usage this tag requires the client to download a java applet. Downloading an applet takes time; therefore, using this tag might be slightly slower than using an html form element or the cfinput tag to get the same information. For this tag to work properly. The browser...
Page 351
Cftreeitem 351 to see expanded information. Size = "#getemployees.Recordcount#" query = "getemployees" value = "lastname" required = "no"> select all size = "#getemployees.Recordcount#" query = "getemployees" value = "lastname" required = "no"> select all value = "see information for this employee">...
Page 352
352 chapter 2: coldfusion tags headeritalic="no"> bold="no" italic="yes" select="no" display="yes" headerbold="no" headeritalic="no"> headeralign="left" dataalign="left" bold="yes" italic="no" select="no" display="yes" headerbold="no" headeritalic="no"> width="40" bold="no" italic="no" select="no" d...
Page 353
Cftry 353 cftry description used with one or more cfcatch tags. Together, they catch and process exceptions in coldfusion pages. Exceptions are events that disrupt the normal flow of instructions in a coldfusion page, such as failed database operations, missing include files, and developer-specified...
Page 354
354 chapter 2: coldfusion tags.
Page 355
Cfupdate 355 cfupdate description updates records in a data source from data in a coldfusion form or form scope. Category database manipulation tags syntax datasource = "ds_name" tablename = "table_name" tableowner = "name" tablequalifier = "qualifier" username = "username" password = "password" for...
Page 356
356 chapter 2: coldfusion tags example tablename="courses" formfields="course_id,number,descript"> select course_number, course_id, descript from courses where course_id = #trim(url.Course_id)# order by course_number tablename="courses" formfields="course_id,number,descript"> select course_number, c...
Page 357
Cfupdate 357.
Page 358
358 chapter 2: coldfusion tags cfwddx description serializes and deserializes cfml data structures to the xml-based wddx format. The wddx is an xml vocabulary for describing complex data structures in a standard, generic way. Implementing it lets you use the http protocol to such information among a...
Page 359
Cfwddx 359 usage coldfusion preserves the case of column names cases in javascript. The wddx2js and cfml2js actions create a wddxrecordset javascript object when they encounter a recordset java object. The serialized javascript code requires a wddx.Js file. This tag performs the following conversion...
Page 360
360 chapter 2: coldfusion tags deserializing wddx packet... The recordset data is:... #message_id# #thread_id# #username#.
Page 361
Cfxml 361 cfxml description creates a coldfusion xml document object that contains the markup in the tag body. This tag can include xml and cfml tags. Coldfusion processes the cfml code in the tag body, then assigns the resulting text to an xml document object variable. Category extensibility tags s...
Page 362
362 chapter 2: coldfusion tags.
Page 363: Chapter 3
363 chapter 3 coldfusion functions this chapter lists and categorizes coldfusion markup language (cfml) functions. Contents function list. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364 functions by category . . . . . . ....
Page 364
364 chapter 3: coldfusion functions function list coldfusion markup language (cfml) includes a set of functions that you use in coldfusion pages to perform logical and arithmetic operations and manipulate data. The following table lists cfml functions: abs gethttptimestring min acos getk2serverdocco...
Page 365
Function list 365 bitxor isdefined reverse ceiling isk2serverabroker right chr isk2serverdoccountexceeded rjustify cjustify isk2serveronline round compare isleapyear rtrim comparenocase isnumeric second cos isnumericdate setencoding createdate isobject setlocale createdatetime isquery setprofilestri...
Page 366
366 chapter 3: coldfusion functions dollarformat listqualify timeformat duplicate listrest tobase64 encrypt listsetat tobinary evaluate listsort tostring exp listtoarray trim expandpath listvaluecount ucase fileexists listvaluecountnocase urldecode find ljustify urlencodedformat findnocase log urlse...
Page 367
Functions by category 367 functions by category the following tables list functions by their category or purpose. Array functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 authentication functions . . . . . . . . . . . ....
Page 368
368 chapter 3: coldfusion functions date and time functions decision functions display and formatting functions tobinary listtoarray xmlformat tostring urldecode xmlparse createdate dateformat gettimezoneinfo monthasstring createdatetime datepart hour now createodbcdate day isdate parsedatetime crea...
Page 369
Functions by category 369 dynamic evaluation functions extensibility functions full-text search functions history coldfusion mx 6.1: these functions are deprecated. They might not work, and might cause errors, in a future release. International functions list functions de evaluate iif setvariable cr...
Page 370
370 chapter 3: coldfusion functions mathematical functions other functions query functions string functions history coldfusion mx: coldfusion now supports the java ucs-2 representation of unicode character values 0–65535. (earlier releases supported ascii values.) string-processing functions process...
Page 371
Functions by category 371 see also “conversion functions” on page 367 . Structure functions system functions xml functions compare len refind tobase64 comparenocase ljustify refindnocase tobinary dayofweekasstring listvaluecount removechars tostring decrypt listvaluecountnocase repeatstring trim enc...
Page 372
372 chapter 3: coldfusion functions function changes since coldfusion 5 the following tables list functions, parameters and values that have changed since coldfusion 5.0 and indicate the specific release in which the change was made. Array functions . . . . . . . . . . . . . . . . . . . . . . . . . ...
Page 373
Function changes since coldfusion 5 373 deprecated functions, parameters, and values the following functions, parameters, and values are deprecated. Do not use them in coldfusion applications. They might not work, and might cause an error, in releases later than coldfusion mx. Obsolete functions, pa...
Page 374
374 chapter 3: coldfusion functions abs description absolute-value function. The absolute value of a number is the number without its sign. Returns the absolute value of a number. Category mathematical functions function syntax abs(number ) see also sgn parameters example the absolute value of the f...
Page 375
Acos 375 acos description arccosine function. The arccosine is the angle whose cosine is number. Returns the arccosine, in radians, of a number. Category mathematical functions function syntax acos(number) see also cos , sin , asin , tan , atn , pi parameters usage the range of the result is 0 to π ...
Page 376
376 chapter 3: coldfusion functions arrayappend description appends an array element to an array. Returns true, on successful completion. Category array functions function syntax arrayappend(array, value) see also arrayprepend history coldfusion mx: changed behavior: this function can be used on xml...
Page 377
Arrayavg 377 arrayavg description calculates the average of the values in an array. Returns number. If the array parameter value is an empty array, returns zero. Category array functions , mathematical functions function syntax arrayavg(array) see also arraysum parameters usage the following example...
Page 378
378 chapter 3: coldfusion functions the average of the numbers that you entered is #arrayavg(mynumberarray)#. Try again. You must enter at least two numeric values..
Page 379
Arrayclear 379 arrayclear description deletes the data in an array. Returns true, on successful completion. Category array functions function syntax arrayclear(array) see also arraydeleteat history coldfusion mx: changed behavior: this function can be used on xml objects. Parameters example your arr...
Page 380
380 chapter 3: coldfusion functions arraydeleteat description deletes an element from an array. When an element is deleted, coldfusion recalculates index positions. For example, in an array that contains the months of the year, deleting the element at position 5 removes the entry for may. After this...
Page 381
Arrayinsertat 381 arrayinsertat description inserts a value into an array. Array elements whose indexes are greater than the new position are incremented by one. The array length increases by one. Returns true, on successful completion. Category array functions function syntax arrayinsertat(array, p...
Page 382
382 chapter 3: coldfusion functions arrayisempty description determines whether an array is empty of data elements. Returns true, if the array is empty; otherwise, false. Category array functions function syntax arrayisempty(array) see also arraylen history coldfusion mx: changed behavior: this func...
Page 383
Arraylen 383 arraylen description determines the number of elements in an array. Returns the number of elements in an array. Category array functions function syntax arraylen(array) see also arrayisempty history coldfusion mx: changed behavior: this function can be used on child xml objects. Paramet...
Page 384
384 chapter 3: coldfusion functions arraymax description array maximum function. Returns the largest numeric value in an array. If the array parameter value is an empty array, returns zero. Category array functions function syntax arraymax(array) parameters example this example uses arraymax to find...
Page 385
Arraymin 385 arraymin description array minimum function. Returns the smallest numeric value in an array. If the array parameter value is an empty array, returns zero. Category array functions function syntax arraymin(array) parameters example this example uses arraymin to find the smallest number i...
Page 386
386 chapter 3: coldfusion functions arraynew description creates an array of 1–3 dimensions. Index array elements with square brackets: [ ]. Coldfusion arrays expand dynamically as data is added. Returns an array category array functions function syntax arraynew(dimension) parameters example is this...
Page 387
Arrayprepend 387 arrayprepend description inserts an array element at the beginning of an array. Returns true, on successful completion. Category array functions function syntax arrayprepend(array, value) see also arrayappend parameters example select firstname, lastname from employees #arrayprepend...
Page 388
388 chapter 3: coldfusion functions arrayresize description resets an array to a specified minimum number of elements. This can improve performance, if used to size an array to its expected maximum. For more than 500 elements, use arrayresize immediately after using the arraynew tag. Coldfusion arra...
Page 389
Arrayset 389 arrayset description in a one-dimensional array, sets the elements in a specified index range to a value. Useful for initializing an array after a call to arraynew . Returns true, on successful completion. Category array functions function syntax arrayset(array, start_pos, end_pos, valu...
Page 390
390 chapter 3: coldfusion functions arraysort description sorts array elements numerically or alphanumerically. Returns true, if sort is successful; false, otherwise. Category array functions , list functions function syntax arraysort(array, sort_type [, sort_order ]) history coldfusion mx: • change...
Page 391
Arraysort 391 throws if an array element is other than a simple element, this function throws an arraysortsimplevalueexception error. If sort_type is numeric and an array element is not numeric, this function throws a valuenotnumeric error. Example select firstname, lastname from employees ....
Page 392
392 chapter 3: coldfusion functions arraysum description array sum function. Returns the sum of values in an array. If the array parameter value is an empty array, returns zero. Category array functions , mathematical functions function syntax arraysum(array) parameters example this example uses arr...
Page 393
Arrayswap 393 arrayswap description swaps array values of an array at specified positions. This function is more efficient than multiple cfset tags. Returns true, on successful completion. Category array functions function syntax arrayswap(array, position1, position2) parameters example show the res...
Page 394
394 chapter 3: coldfusion functions arraytolist description converts a one-dimensional array to a list. Returns delimited list, as a string. Category array functions , conversion functions , list functions function syntax arraytolist(array [, delimiter ]) parameters example select firstname, lastnam...
Page 395
Asc 395 asc description determines the value of a character. Returns the value of the first character of a string; if string is empty, returns zero. Category string functions function syntax asc(string) see also chr history coldfusion mx: changed unicode support: coldfusion supports the java ucs-2 r...
Page 396
396 chapter 3: coldfusion functions asin description determines the arcsine of a number. The arcsine is the angle whose sine is number. Returns the arcsine, in radians, of a number. Category mathematical functions function syntax asin(number) see also sin , cos , acos , tan , atn , pi parameters usa...
Page 397
Asin 397.
Page 398
398 chapter 3: coldfusion functions atn description arctangent function. The arctangent is the angle whose tangent is number. Returns the arctangent, in radians, of a number. Category mathematical functions function syntax atn(number) see also atn , sin , asin , cos , acos , pi parameters usage the ...
Page 399
Authenticatedcontext 399 authenticatedcontext description this function is obsolete. Use the newer security tools; see “authentication functions” on page 367 and chapter 16, “securing applications,” in developing coldfusion mx applications. History coldfusion mx: this function is obsolete. It does n...
Page 400
400 chapter 3: coldfusion functions authenticateduser description this function is obsolete. Use the newer security tools; see “authentication functions” on page 367 and chapter 16, “securing applications,” in developing coldfusion mx applications. History coldfusion mx: this function is obsolete. I...
Page 401
Bitand 401 bitand description performs a bitwise logical and operation. Returns the bitwise and of two long integers. Category mathematical functions function syntax bitand(number1, number2) see also bitnot , bitor , bitxor parameters usage bit functions operate on 32-bit signed integers, in the ran...
Page 402
402 chapter 3: coldfusion functions bitmaskclear description performs a bitwise mask clear operation. Returns a number, bitwise cleared, with length bits beginning at start. Category mathematical functions function syntax bitmaskclear(number, start, length) see also bitmaskread , bitmaskset paramete...
Page 403
Bitmaskread 403 bitmaskread description performs a bitwise mask read operation. Returns an integer, created from length bits of number, beginning at start. Category mathematical functions function syntax bitmaskread(number, start, length) see also bitmaskclear , bitmaskset parameters usage bit funct...
Page 404
404 chapter 3: coldfusion functions bitmaskset description performs a bitwise mask set operation. Returns a number, bitwise masked with length bits of mask beginning at start. Category mathematical functions function syntax bitmaskset(number, mask, start, length) see also bitmaskclear , bitmaskread ...
Page 405
Bitnot 405 bitnot description performs a bitwise logical not operation. Returns a number; the bitwise not of a long integer. Category mathematical functions function syntax bitnot(number) see also bitand , bitor , bitxor parameters usage bit functions operate on 32-bit signed integers, in the range ...
Page 406
406 chapter 3: coldfusion functions bitor description performs a bitwise logical or operation. Returns a number; the bitwise or of two long integers. Category mathematical functions function syntax bitor(number1, number2) see also bitand , bitnot , bitxor parameters usage bit functions operate on 32...
Page 407
Bitshln 407 bitshln description performs a bitwise shift-left, no-rotation operation. Returns a number, bitwise shifted without rotation to the left by count bits. Category mathematical functions function syntax bitshln(number, count) see also bitshrn parameters usage bit functions operate on 32-bit...
Page 408
408 chapter 3: coldfusion functions bitshrn description performs a bitwise shift-right, no-rotation operation. Returns a number, bitwise shifted, without rotation, to the right by count bits. Category mathematical functions function syntax bitshrn(number, count) see also bitshln parameters usage bit...
Page 409
Bitxor 409 bitxor description performs a bitwise logical xor operation. Returns bitwise xor of two long integers. Category mathematical functions function syntax bitxor(number1, number2) see also bitand , bitnot , bitor parameters usage bit functions operate on 32-bit signed integers, in the range -...
Page 410
410 chapter 3: coldfusion functions ceiling description determines the closest integer that is greater than a specified number. Returns the closest integer that is greater than a given number. Category mathematical functions function syntax ceiling(number) see also int , fix , round parameters examp...
Page 411
Chr 411 chr converts a numeric value to a ucs-2 character. Returns a character with the specified ucs-2 character code. Category string functions function syntax chr(number) see also asc history coldfusion mx: changed unicode support: coldfusion supports the java ucs-2 representation of unicode char...
Page 412
412 chapter 3: coldfusion functions cjustify description centers a string in a field length. Returns string, center-justified by adding spaces before or after the input parameter. If length is less than the length of the input parameter string, the string is returned unchanged. Category display and ...
Page 413
Compare 413 compare description performs a case-sensitive comparison of two strings. Returns • -1, if string1 is less than string2 • 0, if string1 is equal to string2 • 1, if string1 is greater than string2 category string functions function syntax compare(string1, string2) see also comparenocase , ...
Page 414
414 chapter 3: coldfusion functions string 1 string 2.
Page 415
Comparenocase 415 comparenocase description performs a case-insensitive comparison of two strings. Returns an indicator of the difference: • a negative number, if string1 is less than string2 • 0, if string1 is equal to string2 • a positive number, if string1 is greater than string2 category string ...
Page 416
416 chapter 3: coldfusion functions.
Page 417
Cos 417 cos description calculates the cosine of an angle that is entered in radians. Returns a number; the cosine of the angle. Category mathematical functions function syntax cos(number) see also acos , sin , asin , tan , atn , pi parameters usage the range of the result is -1 to 1. To convert deg...
Page 418
418 chapter 3: coldfusion functions.
Page 419
Createdate 419 createdate description creates a date/time object. Returns a date/time value. Category date and time functions function syntax createdate(year, month, day) see also createdatetime , createodbcdate parameters usage createdate is a subset of createdatetime . The time in the returned obj...
Page 420
420 chapter 3: coldfusion functions #dateformat(createodbcdatetime(yourdate), "d/m/yy")# enter the year, month and day, as integers: year required="yes"> month required="yes"> day required="yes"> required="yes"> month required="yes"> day required="yes"> required="yes"> day required="yes"> required="...
Page 421
Createdatetime 421 createdatetime description creates a date-time object. Returns a date/time value. Category date and time functions function syntax createdatetime(year, month, day, hour, minute, second) see also createdate , createtime , createodbcdatetime , now parameters example your date value,...
Page 422
422 chapter 3: coldfusion functions #dateformat(createodbcdate(yourdate), "mmmm d, yyyy")# #dateformat(createodbcdatetime(yourdate), "d/m/yy")# please enter the year, month, and day, in integer format, for a date to view: year required="yes"> month message="please enter a month (1-12)" validate="int...
Page 423
Createobject 423 createobject description creates a coldfusion object, of a specified type. Returns an object, of the specified type. Note: you can enable and disable this function in the coldfusion administrator, coldfusion basic security, tag restrictions page. Category extensibility functions his...
Page 424
424 chapter 3: coldfusion functions createobject: com object description the createobject function can create a component object model (com) object. To create a com object, you must provide this information: • the object’s program id or filename • the methods and properties available to the object t...
Page 425
Createobject 425 createobject: component object description the createobject function can create an instance of a coldfusion component (cfc) object. Returns a component object. Function syntax createobject (type, component-name) parameters usage on unix systems, coldfusion searches first for a file ...
Page 426
426 chapter 3: coldfusion functions createobject: corba object description the createobject function can call a method on a corba object. The object must be defined and registered for use. Returns a handle to a corba interface. Function syntax createobject (type, context, class, locale) history see ...
Page 427
Createobject 427 myobj = createobject("corba", "macromedia/eng/cf", "nameservice", "visibroker") // uses nameservice myobj = createobject("corba", "d:\temp\tester.Ior", "nameservice") // uses nameservice and default configuration.
Page 428
428 chapter 3: coldfusion functions createobject: java or ejb object description the createobject function can create a java object, and, by extension, an ejb object. Returns a java object. Function syntax createobject (type, class) parameters usage any java class available in the class path that is...
Page 429
Createobject 429 createobject: web service object description this function can create a web service object. Returns a web service object. Function syntax createobject (type, urltowsdl) parameters usage you can use the createobject function to create a web service. Example newobject2 = createobject(...
Page 430
430 chapter 3: coldfusion functions createodbcdate description creates an odbc date object. Returns a date object, in normalized odbc date format. Category date and time functions function syntax createodbcdate(date) see also createdate , createodbcdatetime parameters usage this function does not pa...
Page 431
Createodbcdate 431 enter the year, month and day, as integers: year required="yes"> month message="please enter a month (1-12)" validate="integer" required="yes"> day message="please enter a day of the month (1-31)" validate="integer" required="yes"> hour message="you must enter an hour (0-23)" vali...
Page 432
432 chapter 3: coldfusion functions createodbcdatetime description creates an odbc date-time object. Returns a date/time object, in odbc timestamp format. Category date and time functions function syntax createodbcdatetime(date) see also createdatetime , createodbcdate , createodbctime , now paramet...
Page 433
Createodbcdatetime 433 enter a year, month and day, as integers: year type="text" name="year" value="1998" validate="integer" required="yes"> month type="text" name="month" value="6" range="1,12" message="enter a month (1-12)" validate="integer" required="yes"> day message="enter a day of the month ...
Page 434
434 chapter 3: coldfusion functions createodbctime description creates an odbc time object. Returns a time object, in odbc timestamp format. Category date and time functions function syntax createodbctime(date) see also createodbcdatetime , createtime parameters usage when passing a date/time value ...
Page 435
Createtime 435 createtime description creates a time variable. Returns a time variable. Category date and time functions function syntax createtime(hour, minute, second) see also createodbctime , createdatetime parameters usage createtime is a subset of createdatetime . A time variable is a special ...
Page 436
436 chapter 3: coldfusion functions createtimespan description creates a date/time object that defines a time period. You can add or subtract it from other date/ time objects and use it with the cachedwithin attribute of cfquery . Returns a date/time object. Category date and time functions function...
Page 437
Createtimespan 437 park name region state maxrows = "#maxrows#"> #getparks.Currentrow# #parkname# #region# #state# maxrows = "#maxrows#"> #getparks.Currentrow# #parkname# #region# #state# #evaluate(startrow + maxrows)#"> see next #maxrows# rows.
Page 438
438 chapter 3: coldfusion functions createuuid description creates a universally unique identifier (uuid). A uuid is a 35-character string representation of a unique 128-bit integer. Returns a coldfusion format uuid, in the format xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx , where x is a hexadecimal digit ...
Page 439
Dateadd 439 dateadd description adds units of time to a date. Returns a date/time object. Category date and time functions function syntax dateadd("datepart", number, "date") see also dateconvert , datepart , createtimespan history coldfusion mx 6.1: added the datepart character l or l to represent ...
Page 440
440 chapter 3: coldfusion functions select username, subject, posted frommessages this example uses dateadd to determine when a message in the database will expire. Currently, messages older than #value# years quarters months days of year weekdays weeks hours minutes seconds years are expired. Color...
Page 441
Datecompare 441 datecompare description performs a full date/time comparison of two dates. Returns • -1, if date1 is less than date2 • 0, if date1 is equal to date2 • 1, if date1 is greater than date2 category date and time functions function syntax datecompare("date1", "date2" [, "datepart"]) see a...
Page 442
442 chapter 3: coldfusion functions #timeformat(form.Date1)# to #dateformat(form.Date2)# #timeformat(form.Date2)# (date 2) the dates are equal! #timeformat(form.Date1)# than #dateformat(form.Date2)# #timeformat(form.Date2)# (date 2) the dates are not equal date 1 value = "#dateformat(now())# #timefo...
Page 443
Dateconvert 443 dateconvert description converts local time to coordinated universal time (utc), or utc to local time. The function uses the daylight savings settings in the executing computer to compute daylight savings time, if required. Returns utc- or local-formatted time object. Category date a...
Page 444
444 chapter 3: coldfusion functions your utc date and time, converted back to local date and time: #dateconvert("utc2local", yourutc)#. Type the date and time, and press enter to see the conversion. Enter year, month and day in integer format for date value to view: validate = "integer" required = "...
Page 445
Datediff 445 datediff description determines the integer number of units by which date1 is less than date2. Returns a number of units, of type datepart. Category date and time functions function syntax datediff("datepart", "date1", "date2") see also dateadd , datepart , createtimespan history coldfu...
Page 446
446 chapter 3: coldfusion functions example this example uses datediff to determine the difference in years quarters months days days weekdays weeks hours minutes seconds years dateparts between date1 and date2. The difference is #abs(datediff(type, form.Date2, form.Date1))# years quarters months da...
Page 447
Datediff 447 #dateformat(now())# cfoutput>"> date 2 #dateformat(now())# cfoutput>"> what kind of unit to show difference? Years quarters months days of year days weekdays weeks hours minutes seconds ..
Page 448
448 chapter 3: coldfusion functions dateformat description formats a date value using u.S. Date formats. For international date support, use lsdateformat . Returns a text string representing the date formatted according to the mask. If no mask is specified, returns the value in dd-mmm-yy format. Cat...
Page 449
Dateformat 449 date and time values in database query results can vary in sequence and formatting unless you use functions to format them. To ensure that application users correctly understand displayed dates and times, macromedia recommends that you use this function and the lsdateformat , timeform...
Page 450
450 chapter 3: coldfusion functions datepart description extracts a part from a date value. Returns part of a date, as an integer. Category date and time functions function syntax datepart("datepart", "date") see also dateadd , dateconvert history coldfusion mx 6.1: added the datepart character l or...
Page 451
Datepart 451.
Page 452
452 chapter 3: coldfusion functions day description determines the day of the month, in a date. Returns the ordinal for the day of the month, ranging from 1 to 31. Category date and time functions function syntax day("date") see also dayofweek , dayofweekasstring , dayofyear , daysinmonth , daysinye...
Page 453
Dayofweek 453 dayofweek description determines the day of the week, in a date. Returns the ordinal for the day of the week, as an integer in the range 1 (sunday) to 7 (saturday). Category date and time functions function syntax dayofweek("date") see also day , dayofweekasstring , dayofyear , daysinm...
Page 454
454 chapter 3: coldfusion functions dayofweekasstring description determines the day of the week, in a date, as a string function. Returns the day of the week, as a string that corresponds to day_of_week. Category date and time functions , string functions function syntax dayofweekasstring(day_of_we...
Page 455
Dayofyear 455 dayofyear description determines the day of the year, in a date. Returns the ordinal value of day of the year, as an integer. Category date and time functions function syntax dayofyear("date") see also day , dayofweek , dayofweekasstring , daysinmonth , daysinyear , firstdayofmonth par...
Page 456
456 chapter 3: coldfusion functions daysinmonth description determines the number of days in a month. Returns the number of days in the month in date. Category date and time functions function syntax daysinmonth("date") see also day , dayofweek , dayofweekasstring , dayofyear , daysinyear , firstday...
Page 457
Daysinyear 457 daysinyear description determines the number of days in a year. Returns the number of days in a year. Category date and time functions function syntax daysinyear("date") see also day , dayofweek , dayofweekasstring , dayofyear , daysinmonth , daysinyear , firstdayofmonth , isleapyear ...
Page 458
458 chapter 3: coldfusion functions de description postpones evaluation of a string as an expression, when it is passed as a parameter to the iif or evaluate functions. Escapes any double quotation marks in the parameter and wraps the result in double quotation marks. This function is especially use...
Page 459
De 459 for more information and code examples, see chapter 4, “using expressions and pound signs,” in developing coldfusion mx applications. Example the value of the expression #evaluate(de(form.Myexpression))# is #myexpression#. Try a simple expression, such as "2+2". #cfcatch.Message#.
Page 460
460 chapter 3: coldfusion functions decimalformat description converts a number to a decimal-formatted string. Returns a number as a string formatted with two decimal places and a thousands separator. Category display and formatting functions function syntax decimalformat(number) see also dollarform...
Page 461
Decrementvalue 461 decrementvalue description decrements the integer part of a number. Returns integer part of number, decremented by one. Category mathematical functions function syntax decrementvalue(number) see also incrementvalue parameters example returns the integer part of a number decremente...
Page 462
462 chapter 3: coldfusion functions decrypt description decrypts a string that is encrypted with the encrypt function. Returns string, unencrypted. Category other functions , string functions function syntax decrypt(encrypted_string, seed) see also duplicate , encrypt parameters example this functio...
Page 463
Deleteclientvariable 463 deleteclientvariable description deletes a client variable. (to test for the existence of a variable, use isdefined .) returns true, if the variable is successfully deleted; false, otherwise. Category other functions function syntax deleteclientvariable("name") see also getc...
Page 464
464 chapter 3: coldfusion functions directoryexists description determines whether a directory exists. Returns yes, if the specified directory exists; no, otherwise. Category system functions function syntax directoryexists(absolute_path) see also fileexists parameters example your directory exists....
Page 465
Dollarformat 465 dollarformat description formats a string in u.S. Format. (for other currencies, use lscurrencyformat or lseurocurrencyformat .) returns a number as a string, formatted with two decimal places, thousands separator, and dollar sign. If number is negative, the return value is enclosed...
Page 466
466 chapter 3: coldfusion functions duplicate description returns a clone, also known as a deep copy, of a variable. There is no reference to the original variable. Returns a clone of a variable. Category structure functions , system functions function syntax duplicate(variable_name) see also struct...
Page 467
Encrypt 467 encrypt description encrypts a string. Uses a symmetric key-based algorithm, in which the same key is used to encrypt and decrypt a string. The security of the encrypted string depends on maintaining the secrecy of the key. Uses an xor-based algorithm that uses a pseudo-random 32-bit key...
Page 468
468 chapter 3: coldfusion functions evaluate description evaluates one or more string expressions, dynamically, from left to right. (the results of an evaluation on the left can have meaning in an expression to the right.) returns the result of evaluating the rightmost expression. Returns an object;...
Page 469
Exp 469 exp description calculates the exponent whose base is e that represents number. The constant e equals 2.71828182845904, the base of the natural logarithm. This function is the inverse of log , the natural logarithm of number. Returns the constant e, raised to the power of number. Category ma...
Page 470
470 chapter 3: coldfusion functions expandpath description creates an absolute, platform-appropriate path that is equivalent to the value of relative_path , appended to the base path. This function (despite its name) can accept an absolute or relative path in the relative_path attribute the base pat...
Page 471
Expandpath 471 the current directory is: #getdirectoryfrompath(thispath)# expandpath(yourfile))> your file exists in this directory. You entered the correct file name, #getfilefrompath("#thispath#/#yourfile#")# your file was not found in this directory: here is a list of the other files in this dire...
Page 472
472 chapter 3: coldfusion functions fileexists description determines whether a file exists. Returns yes, if the file specified in the parameter exists; no, otherwise. Category system functions , decision functions function syntax fileexists(absolute_path) see also directoryexists , expandpath , get...
Page 473
Find 473 find description finds the first occurrence of a substring in a string, from a specified start position. The search is case-sensitive. Returns a number; the position of substring in string; or 0, if substring is not in string. Category string functions function syntax find(substring, string...
Page 474
474 chapter 3: coldfusion functions findnocase description finds the first occurrence of a substring in a string, from a specified start position. If substring is not in string, returns zero. The search is case-insensitive. Returns the position of substring in string; or 0, if substring is not in st...
Page 475
Findoneof 475 findoneof description finds the first occurrence of any one of a set of characters in a string, from a specified start position. The search is case-sensitive. Returns the position of the first member of set found in string; or 0, if no member of set is found in string. Category string ...
Page 476
476 chapter 3: coldfusion functions firstdayofmonth description determines the ordinal (day number, in the year) of the first day of the month in which a given date falls. Returns a number corresponding to a day-number in a year. Category date and time functions function syntax firstdayofmonth(date)...
Page 477
Fix 477 fix description converts a real number to an integer. Returns if number is greater than or equal to 0, the closest integer less than number. If number is less than 0, the closest integer greater than number. Category mathematical functions function syntax fix(number) see also ceiling , int ,...
Page 478
478 chapter 3: coldfusion functions formatbasen description converts number to a string, in the base specified by radix. Returns string that represents number, in the base radix. Category display and formatting functions , mathematical functions , string functions function syntax formatbasen(number,...
Page 479
Getauthuser 479 getauthuser description gets the name of an authenticated user. Returns the name of an authenticated user. Category authentication functions function syntax getauthuser() see also isuserinrole , cflogin , cfloginuser , chapter 16, “securing applications,” in developing coldfusion mx ...
Page 480
480 chapter 3: coldfusion functions getbasetagdata description used within a custom tag. Finds calling (ancestor) tag by name and accesses its data. Returns an object that contains data (variables, scopes, and so on) from an ancestor tag. If there is no ancestor by the specified name, or if the ance...
Page 481
Getbasetaglist 481 getbasetaglist description gets ancestor tag names, starting with the parent tag. Returns a comma-delimited list of uppercase ancestor tag names, as a string. The first list element is the current tag. If the current tag is nested, the next element is the parent tag. If the functi...
Page 482
482 chapter 3: coldfusion functions getbasetemplatepath description gets the absolute path of an application’s base page. Returns the absolute path of the application base page, as a string. Category other functions , system functions function syntax getbasetemplatepath() see also getcurrenttemplate...
Page 483
Getclientvariableslist 483 getclientvariableslist description finds the client variables to which a page has write access. Returns comma-delimited list of non-read-only client variables, as a string. Category list functions , other functions function syntax getclientvariableslist() see also deletecl...
Page 484
484 chapter 3: coldfusion functions getcurrenttemplatepath description gets the path of the page that calls this function. Returns the absolute path of the page that contains the call to this function, as a string. Category system functions function syntax getcurrenttemplatepath() see also getbasete...
Page 485
Getdirectoryfrompath 485 getdirectoryfrompath description extracts a directory from an absolute path. Returns absolute path, without the filename. The last character is a forward or backward slash, depending on the operating system. Category system functions function syntax getdirectoryfrompath(path...
Page 486
486 chapter 3: coldfusion functions --->.
Page 487
Getencoding 487 getencoding description returns the encoding (character set) of the form or url scope. Returns string; the character encoding of the specified scope. Category international functions , system functions function syntax getencoding(scope_name) see also setencoding , cfcontent , cfproce...
Page 488
488 chapter 3: coldfusion functions getexception description used with the cftry and cfcatch tags. Retrieves a java exception object from a java object. Returns any java exception object raised by a previous method call on the java object. Category system functions syntax getexception(object) parame...
Page 489
Getfilefrompath 489 getfilefrompath description extracts a filename from an absolute path. Returns filename, as a string. Category system functions function syntax getfilefrompath(path) see also expandpath , getcurrenttemplatepath parameters example the current directory is: #getdirectoryfrompath(th...
Page 490
490 chapter 3: coldfusion functions getfunctionlist description displays a list of the functions that are available in coldfusion. Returns a structure of functions. Category system functions function syntax getfunctionlist() example getfunctionlist()> #structcount(flist)# functions #key#.
Page 491
Gethttprequestdata 491 gethttprequestdata description makes http request headers and body available to cfml pages. Useful for capturing soap request data, which can be delivered in an http header. Returns a coldfusion structure. Category system functions function syntax gethttprequestdata() paramete...
Page 492
492 chapter 3: coldfusion functions http_content --- #x.Content#.
Page 493
Gethttptimestring 493 gethttptimestring description gets the current time, in the universal time code (utc). Returns the time, as a string, according to the http standard described in rfc 1123. Category date and time functions , international functions function syntax gethttptimestring(date_time_obj...
Page 494
494 chapter 3: coldfusion functions getk2serverdoccount description this function is deprecated. Determines the number of documents that can be searched by the coldfusion registered k2 server. This function is used primarily by the coldfusion verity and k2server administrator pages, and requires sig...
Page 495
Getk2serverdoccountlimit 495 getk2serverdoccountlimit description this function is deprecated. Gets the maximum number of documents that the coldfusion registered k2 server is permitted to return from a search. This function is used primarily by the coldfusion verity and k2server administrator pages...
Page 496
496 chapter 3: coldfusion functions getlocale description gets the current geographic/language locale value. To set the default display format of date, time, number, and currency values in a coldfusion application session, you use the setlocale function. Returns the current locale value, as a string...
Page 497
Getmetadata 497 getmetadata description gets metadata (the methods, properties, and parameters of a component) associated with an object that is deployed on the coldfusion server. This functionality, called introspection, lets applications dynamically determine how to use a component. Returns key-va...
Page 498
498 chapter 3: coldfusion functions property metadata contains at least the following key: • name : the property name other property attributes are returned as additional keys..
Page 499
Getmetricdata 499 getmetricdata description gets server performance metrics. Returns coldfusion structure that contains metric data, depending on the mode value. Category system functions function syntax getmetricdata(mode) history coldfusion mx: deprecated the cachepops parameter. It might not work...
Page 500
500 chapter 3: coldfusion functions example current perfmonitor data is: instancename:#pmdata.Instancename# pagehits:#pmdata.Pagehits# reqqueued: #pmdata.Reqqueued# dbhits: #pmdata.Dbhits# reqrunning: #pmdata.Reqrunning# reqtimedout: #pmdata.Reqtimedout# bytesin: #pmdata.Bytesin# bytesout: #pmdata.B...
Page 501
Getpagecontext 501 getpagecontext description gets the current coldfusion mx pagecontext object that provides access to page attributes and configuration, request and response objects. Returns the current coldfusion mx java pagecontext java object. Category system functions function syntax getpageco...
Page 502
502 chapter 3: coldfusion functions getprofilesections description gets all the sections of an initialization file. An initialization file assigns values to configuration variables, also known as entries, that are set when the system boots, the operating system comes up, or an application starts. An...
Page 503
Getprofilestring 503 getprofilestring description gets an initialization file entry. An initialization file assigns values to configuration variables, also known as entries, that are set when the system boots, the operating system comes up, or an application starts. An initialization file has the su...
Page 504
504 chapter 3: coldfusion functions.
Page 505
Gettempdirectory 505 gettempdirectory description gets the path of the directory that coldfusion uses for temporary files. The directory depends on the account under which coldfusion is running and other factors. Before using this function in an application, test to determine the directory it return...
Page 506
506 chapter 3: coldfusion functions gettempfile description creates a temporary file in a directory whose name starts with (at most) the first three characters of prefix. Returns name of a temporary file, as a string. Category system functions function syntax gettempfile(dir, prefix) see also gettem...
Page 507
Gettemplatepath 507 gettemplatepath description this function is deprecated. Use the getbasetemplatepath function instead. Gets the absolute path of an application’s base page. History coldfusion mx: deprecated this function. It might not work, and it might cause an error, in later releases..
Page 508
508 chapter 3: coldfusion functions gettickcount description returns the current value of an internal millisecond timer. Returns a string representation of the system time, in milliseconds. Category date and time functions function syntax gettickcount() usage this function is useful for timing cfml ...
Page 509
Gettimezoneinfo 509 gettimezoneinfo description gets local time zone information for the computer on which it is called, relative to universal time coordinated (utc). Utc is the mean solar time of the meridian of greenwich, england, used as the basis for calculating standard time throughout the worl...
Page 510
510 chapter 3: coldfusion functions gettoken description determines whether a token of the list in the delimiters parameter is present in a string. Returns the token found at position index of the string, as a string. If index is greater than the number of tokens in the string, returns an empty stri...
Page 511
Gettoken 511 the output is as follows: four, ,five, nine,zero:; nine,ten:, eleven:;twelve:;thirteen, ,four the gettoken function recognizes explicit spaces, tabs, or newline characters as the parameter delimiters (to specify a space character, the code is chr(32) ; a tab character, chr(9) ; and a ne...
Page 512
512 chapter 3: coldfusion functions the function finds the second delimiter, and returns the substring just before it that is between the first and second delimiter. This substring is " ,five,nine,zero:; ". Example element #form.Returnelement# in #form.Yourstring#, delimited by "#yourdelimiter#" is:...
Page 513
Hash 513 hash description converts a variable-length string to a 32-byte, hexadecimal string, using the md5 algorithm. (it is not possible to convert the hash result back to the source string.) returns 32-byte, hexadecimal string category conversion functions , other functions , string functions fun...
Page 514
514 chapter 3: coldfusion functions hour description gets the current hour of the day. Returns ordinal value of the hour, in the range 0 - 23. Category date and time functions function syntax hour(date) see also datepart , minute , second parameters usage when passing a date/time value as a string, ...
Page 515
Htmlcodeformat 515 htmlcodeformat description replaces special characters in a string with their html-escaped equivalents and inserts and tags at the beginning and end of the string. Returns html-escaped string string, enclosed in and tags. Returns are removed from string. Special characters ( > ) a...
Page 516
516 chapter 3: coldfusion functions htmleditformat description replaces special characters in a string with their html-escaped equivalents. Returns html-escaped string string. Returns are removed from string. Special characters (for example, ) are escaped. Category display and formatting functions f...
Page 517
Iif 517 iif description evaluates a boolean conditional dynamic expression. Depending on whether the expression is true or false, dynamically evaluates one of two string expressions and returns the result. This function is convenient for incorporating a cfif tag in-line in html. For general conditio...
Page 518
518 chapter 3: coldfusion functions note: if you use pound signs (#) in string_expression1 or string_expression2, coldfusion evaluates the part of the expression in pound signs first. If you misuse the pound signs, you can cause unexpected results from the iif function. For example, if you use pound...
Page 519
Iif 519.
Page 520
520 chapter 3: coldfusion functions incrementvalue description adds one to an integer. Returns the integer part of number, incremented by one. Category mathematical functions function syntax incrementvalue(number) see also decrementvalue parameters example returns the integer part of a number increm...
Page 521
Inputbasen 521 inputbasen description converts string, using the base specified by radix, to an integer. Returns a number in the range 2-36, as a string. Category mathematical functions function syntax inputbasen(string, radix) see also formatbasen parameters example formatbasen converts a number to...
Page 522
522 chapter 3: coldfusion functions insert description inserts a substring in a string after a specified character position. If position = 0, prefixes the substring to the string. Returns a string. Category string functions function syntax insert(substring, string, position) see also removechars , l...
Page 523
Int 523 int description calculates the closest integer that is smaller than number. Returns an integer, as a string. Category mathematical functions function syntax int(number) see also ceiling , fix , round parameters example int returns the closest integer smaller than a number. Int(11.7) : #int(1...
Page 524
524 chapter 3: coldfusion functions isarray description determines whether a value is an array. Returns true, if value is an array, or a query column object. Category array functions , decision functions function syntax isarray(value [, number ]) see also array functions history coldfusion mx: • cha...
Page 525
Isauthenticated 525 isauthenticated description this function is obsolete. Use the newer security tools; see “authentication functions” on page 367 and chapter 16, “securing applications,” in developing coldfusion mx applications. History coldfusion mx: this function is obsolete. It does not work in...
Page 526
526 chapter 3: coldfusion functions isauthorized description this function is obsolete. Use the newer security tools; see “authentication functions” on page 367 and chapter 16, “securing applications,” in developing coldfusion mx applications history coldfusion mx: this function is obsolete. It does...
Page 527
Isbinary 527 isbinary description determines whether a value is stored as binary data. Returns true, if the value is binary; false, otherwise. Category decision functions function syntax isbinary(value) see also tobinary , tobase64 , isnumeric , yesnoformat parameters example the following string is...
Page 528
528 chapter 3: coldfusion functions isboolean description determines whether a value can be converted to boolean returns true, if the parameter can be converted to boolean; false, otherwise. Category decision functions function syntax isboolean(value) see also isnumeric , yesnoformat parameters exam...
Page 529
Iscustomfunction 529 iscustomfunction description determines whether a name represents a custom function. Returns true, if name can be called as a custom function; false, otherwise. Category decision functions function syntax iscustomfunction(name) parameters usage the iscustomfunction function retu...
Page 530
530 chapter 3: coldfusion functions iscustomfunction(mytestcfcobject.Testfunc)> mytestcfcobject.Testfunc is a function..
Page 531
Isdate 531 isdate description determines whether a string or java object can be converted to a date/time value. Returns true, if string can be converted to a date/time value; otherwise, false. Coldfusion converts the boolean return value to its string equivalent, "yes" or "no." category date and tim...
Page 532
532 chapter 3: coldfusion functions isdebugmode description determines whether debugging output is enabled. Returns true, if debugging mode is set in the coldfusion administrator; false if debugging mode is disabled. Category decision functions function syntax isdebugmode() see also cfsetting descri...
Page 533
Isdefined 533 isdefined description evaluates a string value to determine whether the variable named in it exists. This function is an alternative to the parameterexists function, which is deprecated. Returns true, if the variable is found, or, for a structure, if the specified key is defined; false...
Page 534
534 chapter 3: coldfusion functions.
Page 535
Isk2serverabroker 535 isk2serverabroker description this function is deprecated. Determines whether the k2server version is k2 broker. For more information, see getk2serverdoccountlimit on page 495 . This function is used primarily by the coldfusion verity and k2server administrator pages. This func...
Page 536
536 chapter 3: coldfusion functions isk2serverdoccountexceeded description this function is deprecated. Determines whether the number of documents that can be searched by the coldfusion registered k2 server exceed the limit. Depends on the k2server platform limit; see getk2serverdoccountlimit on pag...
Page 537
Isk2serveronline 537 isk2serveronline description this function is deprecated. Determines whether the k2server is running and available to perform a search. This function is used primarily by the coldfusion verity and k2server administrator pages. This function uses verity k2server release k2.2.0. R...
Page 538
538 chapter 3: coldfusion functions isleapyear description determines whether a year is a leap year. Returns true, if year is a leap year; otherwise, false. Category date and time functions , decision functions function syntax isleapyear(year) see also daysinyear parameters example isleapyear(form.T...
Page 539
Isnumeric 539 isnumeric description determines whether a string can be converted to a numeric value. Supports numbers in u.S. Number format. For other number support, use lsisnumeric . Returns true, if string can be converted to a number; otherwise, false. Category decision functions function syntax...
Page 540
540 chapter 3: coldfusion functions isnumericdate description evaluates whether a real number is a valid representation of a date (date/time object). Returns true, if the parameter represents a valid date/time object; otherwise, false. Category date and time functions , decision functions function s...
Page 541
Isobject 541 isobject description determines whether a value is an object. Returns true, if the value represents a coldfusion object. False if the value is any other type of data, such as an integer, string, date, or struct. Category decision functions function syntax isobject(value) see also isdate...
Page 542
542 chapter 3: coldfusion functions.
Page 543
Isprotected 543 isprotected description this function is obsolete. Use the newer security tools; see “authentication functions” on page 367 and chapter 16, “securing applications,” in developing coldfusion mx applications history coldfusion mx: this function is obsolete. It does not work in coldfusi...
Page 544
544 chapter 3: coldfusion functions isquery description determines whether value is a query. Returns true, if value is a query. Category decision functions , query functions function syntax isquery(value) see also queryaddrow parameters example before the query is run, the value of getemployees is #...
Page 545
Issimplevalue 545 issimplevalue description determines the type of a value. Returns true, if value is a string, number, boolean, or date/time value; false, otherwise. Category decision functions function syntax issimplevalue(value) parameters example before the query is run, the value of getemployee...
Page 546
546 chapter 3: coldfusion functions isstruct description determines whether a variable is a structure. Returns true, if variable is a coldfusion structure or is a java object that implements the java.Lang.Map interface. Returns false if the object in variable is a user-defined function (udf). Catego...
Page 547
Isstruct 547 --->.
Page 548
548 chapter 3: coldfusion functions isuserinrole description determines whether an authenticated user belongs to the specified role. Returns true, if the authenticated user, belongs to the specified role; false, otherwise. Category authentication functions , decision functions function syntax isuser...
Page 549
Iswddx 549 iswddx description determines whether a value is a well-formed wddx packet. Returns true, if the value is a well-formed wddx packet; false, otherwise. Category decision functions , xml functions syntax iswddx(value) history coldfusion mx: changed behavior: if the value parameter is not a ...
Page 550
550 chapter 3: coldfusion functions iswddx() returns #iswddx(packet)#.
Page 551
Isxmldoc 551 isxmldoc description determines whether a function parameter is an extended markup language (xml) document object. Returns true, if the function argument is an xml document object; false, otherwise. Category decision functions , xml functions function syntax isxmldoc(value) see also isx...
Page 552
552 chapter 3: coldfusion functions isxmlelem description determines whether a function parameter is an extended markup language (xml) document object element. Returns true, if the function argument is an xml document object element; false, otherwise. Category decision functions , xml functions func...
Page 553
Isxmlroot 553 isxmlroot description determines whether a function parameter is the root element of an extended markup language (xml) document object. Returns true, if the function argument is the root object of an xml document object; false, otherwise. Category decision functions , xml functions fun...
Page 554
554 chapter 3: coldfusion functions javacast description converts the data type of a coldfusion variable to pass as an argument to an overloaded method of a java object. Use only for scalar and string arguments. Returns the variable, as type type. Category string functions function syntax javacast(t...
Page 555
Javacast 555 } within coldfusion, you use the following code: action="create" type = "java" class = "fooclass" name = obj> perform an explicit cast to an int and call foomethod: #obj.Foomethod(myint)# perform an explicit cast to a string and call foomethod: #obj.Foomethod(mystring)# action="create" ...
Page 556
556 chapter 3: coldfusion functions jsstringformat description escapes special javascript characters, such as single quotation mark, double quotation mark, and newline. Returns a string that is safe to use with javascript. Category string functions function syntax jsstringformat(string) parameters u...
Page 557
Lcase 557 lcase description converts the alphabetic characters in a string to lowercase. Returns a string, converted to lowercase. Category string functions function syntax lcase(string) see also ucase parameters example your text, #form.Sampletext#, returned in lowercase is #lcase(form.Sampletext)#...
Page 558
558 chapter 3: coldfusion functions left description returns the leftmost count characters in a string. Returns string; the first count characters in the string parameter. Category string functions function syntax left(string, count) see also right , mid , len parameters example your string #form.My...
Page 559
Left 559 9.
Page 560
560 chapter 3: coldfusion functions len description determines the length of a string or binary object. Returns number; length of a string or a binary object. Category string functions function syntax len(string or binary object) see also tobinary , left , right , mid history coldfusion mx: changed ...
Page 561
Listappend 561 listappend description concatenates a list or element to a list. Returns a copy of the list , with value appended. If delimiter = "" , returns a copy of the list, unchanged. Category list functions function syntax listappend(list, value [, delimiters ]) see also listprepend , listinse...
Page 562
562 chapter 3: coldfusion functions select parkname,city,state from parks where parkname like ‘al%’ the original list: #temp# ....
Page 563
Listchangedelims 563 listchangedelims description changes a list delimiter. Returns a copy of the list, with each delimiter character replaced by new_delimiter. Category list functions function syntax listchangedelims(list, new_delimiter [, delimiters ]) see also listfirst , listqualify parameters e...
Page 564
564 chapter 3: coldfusion functions listcontains description determines the index of the first list element that contains a specified substring. Returns index of the first list element that contains substring. If not found, returns zero. Category list functions function syntax listcontains(list, sub...
Page 565
Listcontains 565 the string "two" is in element #listfind(alist, "two")# of the list..
Page 566
566 chapter 3: coldfusion functions listcontainsnocase description determines the index of the first list element that contains a specified substring. Returns index of the first list element that contains substring, regardless of case. If not found, returns zero. Category list functions function syn...
Page 567
Listdeleteat 567 listdeleteat description deletes an element from a list. Returns a copy of the list, without the specified element. Category list functions function syntax listdeleteat(list, position [, delimiters ]) see also listgetat , listsetat , listlen parameters usage to use this and other fu...
Page 568
568 chapter 3: coldfusion functions the changed list: #temp2# this list element:#deleted_element# is no longer present at position three of the list..
Page 569
Listfind 569 listfind description determines the index of the first list element in which a specified value occurs. Case-sensitive. Returns index of the first list element that contains value, with matching case. If not found, returns zero. The search is case-sensitive. Category list functions funct...
Page 570
570 chapter 3: coldfusion functions listfind(mylist, form.Mystring)> employee #listgetat(valuelist(searchemplastname.Firstname), temp)# #listgetat(valuelist(searchemplastname.Lname), temp)#, of the #listgetat(valuelist(searchemplastname.Department), temp)# department, can be reached at #listgetat(va...
Page 571
Listfindnocase 571 listfindnocase description determines the index of the first list element in which a specified value occurs. Returns index of the first list element that contains value. If not found, returns zero. The search is case- insensitive. Category list functions function syntax listfindno...
Page 572
572 chapter 3: coldfusion functions employee #listgetat(valuelist(searchemplastname.Firstname), temp)# #listgetat(valuelist(searchemplastname.Lname), temp)#, of the #listgetat(valuelist(searchemplastname.Department), temp)# department, can be reached at #listgetat(valuelist(searchemplastname.Phone),...
Page 573
Listfirst 573 listfirst description gets the first element of a list. Returns the first element of a list. If the list is empty, returns an empty string. Category list functions function syntax listfirst(list [, delimiters ]) see also listgetat , listlast , listqualify parameters usage coldfusion ig...
Page 574
574 chapter 3: coldfusion functions listgetat description gets a list element at a specified position. Returns index of the list element at position position. Category list functions function syntax listgetat(list, position [, delimiters ]) see also listfirst , listlast , listqualify , listsetat par...
Page 575
Listgetat 575 username #counter#: #listgetat(temp, counter)#.
Page 576
576 chapter 3: coldfusion functions listinsertat description inserts an element in a list. Returns a copy of the list , with value inserted at the specified position. Category list functions function syntax listinsertat(list, position, value [, delimiters ]) see also listdeleteat , listappend , list...
Page 577
Listlast 577 listlast description gets the last element of a list. Returns the last element of the list. Category list functions function syntax listlast(list [, delimiters ]) see also listgetat , listfirst parameters usage if you use list functions on strings that separated by a delimiter character...
Page 578
578 chapter 3: coldfusion functions (users who posted more than once are listed more than once.) the last user in the list is: #listlast(temp)#.
Page 579
Listlen 579 listlen description determines the number of elements in a list. Integer; the number of elements in a list. Category list functions function syntax listlen(list [, delimiters ]) see also listappend , listdeleteat , listinsertat , listprepend parameters usage coldfusion ignores empty list...
Page 580
580 chapter 3: coldfusion functions listprepend description inserts an element at the beginning of a list. Returns a copy of the list , with value inserted at the first position. Category list functions function syntax listprepend(list, value [, delimiters ]) see also listappend , listinsertat , lis...
Page 581
Listprepend 581 the original list: #temp# the original list: #temp# listprepend(temp, "my inserted value")>.
Page 582
582 chapter 3: coldfusion functions listqualify description inserts a string at the beginning and end of list elements. Returns a copy of the list, with qualifier before and after the specified element(s). Category list functions function syntax listqualify(list, qualifier [, delimiters ] [, element...
Page 583
Listqualify 583 the contents of the unqualified list are as follows: #mylist# listqualify(mylist,"'",",","char")> the contents of the qualified list are as follows: #qualifiedlist1# listqualify(mylist,""",",","char")> the contents of the second qualified list are: #qualifiedlist2#.
Page 584
584 chapter 3: coldfusion functions listrest description gets a list, without its first element. Returns a copy of list, without the first element. If list has one element, returns an empty list. Category list functions function syntax listrest(list [, delimiters ]) see also listfirst , listgetat , ...
Page 585
Listsetat 585 listsetat description replaces the contents of a list element. Returns a copy of a list, with a new value assigned to the element at a specified position. Category list functions function syntax listsetat(list, position, value [, delimiters ]) see also listdeleteat , listgetat , listin...
Page 586
586 chapter 3: coldfusion functions subjects posted in messages. Listsetat(temp, 2, "i changed this subject", ",")> (#counter#) subject: #listgetat(temptoo, counter)# note that element 2, "#changedelement#", has been altered to "i changed this subject" using listsetat..
Page 587
Listsort 587 listsort description sorts list elements according to a sort type and sort order. Returns a copy of a list, sorted. Category list functions function syntax listsort(list, sort_type [, sort_order] [, delimiters ]) history coldfusion mx: changed the order in which sorted elements are retu...
Page 588
588 chapter 3: coldfusion functions usage coldfusion ignores empty list elements; thus, the list "a,b,c,,,d" has four elements. Example select username, subject, posted from messages here is the unsorted list. #mylist# here is the list sorted alphabetically: #sortedlist# here is a numeric list that ...
Page 589
Listtoarray 589 listtoarray description copies the elements of a list to an array. Returns an array category array functions , conversion functions , list functions function syntax listtoarray(list [, delimiters ]) see also arraytolist parameters usage coldfusion ignores empty list elements; thus, t...
Page 590
590 chapter 3: coldfusion functions listvaluecount description counts instances of a specified value in a list. The search is case-sensitive. Returns the number of instances of value in the list. Category list functions , string functions function syntax listvaluecount(list, value [, delimiters ]) s...
Page 591
Listvaluecount 591 h3> there is only one person in #form.Departmentname#. There is only one person in #form.Departmentname#. There are #numberindepartment# people in #form.Departmentname#. There are #numberindepartment# people in #form.Departmentname#..
Page 592
592 chapter 3: coldfusion functions listvaluecountnocase description counts instances of a specified value in a list. The search is case-insensitive. Returns the number of instances of value in the list. Category list functions function syntax listvaluecountnocase(list, value [, delimiters ]) see al...
Page 593
Listvaluecountnocase 593 form.Departmentname)> there are no employees in #form.Departmentname# form.Departmentname)> cfoutput> there is only one person in #form.Departmentname#. There is only one person in #form.Departmentname#. There are #numberindepartment# people in #form.Departmentname#. There a...
Page 594
594 chapter 3: coldfusion functions ljustify description left justifies characters in a string of a specified length. Returns a copy of a string, left-justified. Category display and formatting functions , string functions function syntax ljustify(string, length) see also cjustify , rjustify paramet...
Page 595
Log 595 log description calculates the natural logarithm of a number. Natural logarithms are based on the constant e (2.71828182845904). Returns the natural logarithm of a number. Category mathematical functions function syntax log(number) see also exp , log10 parameters example your number, #form.N...
Page 596
596 chapter 3: coldfusion functions log10 description calculates the logarithm of number, to base 10. Returns number; the logarithm of number, to base 10. Category mathematical functions function syntax log10(number) see also exp , log parameters example your number, #form.Number# #form.Number# rais...
Page 597
Lscurrencyformat 597 lscurrencyformat description formats a number in a locale-specific currency format. For countries that use the euro, the result depends on the jvm. Returns a formatted currency value. Category display and formatting functions , international functions function syntax lscurrencyf...
Page 598
598 chapter 3: coldfusion functions chinese (taiwan) nt$100,000.00 twd100,000.00 100,000.00 dutch (belgian) 100.000,00 ¤ 100.000,00 bf bef100.000,00 eur100.000,00 100.000,00 dutch (standard) ¤ 100.000,00 fl 100.000,00 nlg100.000,00 eur100.000,00 100.000,00 english (australian) $100,000.00 aud100,000...
Page 599
Lscurrencyformat 599 note: coldfusion maps spanish (modern) to the spanish (standard) format. To set the default display format of date, time, number, and currency values, use the setlocale function. Example lscurrencyformat returns a currency value using the locale convention. Default value is "loc...
Page 600
600 chapter 3: coldfusion functions lsdateformat description formats the date part of a date/time value in a locale-specific format. Returns a formatted date/time value. If no mask is specified, the value is formatted according to the locale setting of the client computer. Category date and time fun...
Page 601
Lsdateformat 601 when passing date/time value as a string, enclose it in quotation marks. Otherwise, it is interpreted as a number representation of a date/time object. To calculate a difference between time zones, use the gettimezoneinfo function. Example lsdateformat formats the date part of a dat...
Page 602
602 chapter 3: coldfusion functions lseurocurrencyformat description formats a number in a locale-specific currency format. Returns a formatted currency value. For countries in the euro currency zone, the function uses the locale’s rule’s for formatting currency in euros. Category display and format...
Page 603
Lseurocurrencyformat 603 currency output the following table shows examples of currency output: note: coldfusion uses the spanish (standard) formats for spanish (modern) and spanish (standard). Locale type = local type = international type = none chinese (china) ¥100,000.00 cny100,000.00 100,000.00 ...
Page 604
604 chapter 3: coldfusion functions the following example shows how the function formats negative values. The format includes a negative sign before the value, or parentheses around the value, according to the formatting rules of the current locale. Example lseurocurrencyformat returns a currency va...
Page 605
Lsiscurrency 605 lsiscurrency description determines whether a string is a valid representation of a currency amount in the current locale. Returns true, if the parameter is formatted as a valid currency amount, including the appropriate currency indicator. Returns true for amounts in the local, int...
Page 606
606 chapter 3: coldfusion functions select a locale for which you would like to check a currency value:.
Page 607
Lsisdate 607 lsisdate description determines whether a string is a valid representation of a date/time value in the current locale. Returns true, if the string can be formatted as a date/time value in the current locale; false, otherwise. Category date and time functions , display and formatting fun...
Page 608
608 chapter 3: coldfusion functions.
Page 609
Lsisnumeric 609 lsisnumeric description determines whether a string is a valid representation of a number in the current locale. Returns true, if the string represents a number the current locale; false, otherwise. Category decision functions , international functions , string functions function syn...
Page 610
610 chapter 3: coldfusion functions lsnumberformat description formats a number in a locale-specific format. Returns a formatted number. • if no mask is specified, it returns the number formatted as an integer • if no mask is specified, truncates the decimal part; for example, it truncates 34.57 to ...
Page 611
Lsnumberformat 611 note: if you do not specify a sign for the mask, positive and negative numbers do not align in columns. To put a plus sign or space before positive numbers and a minus sign before negative numbers, use the plus or hyphen mask character, respectively. Usage this function uses java ...
Page 612
612 chapter 3: coldfusion functions to set the default display format of date, time, number, and currency values, use the setlocale function. When converting from string to double, to prevent rounding errors, this function adds a rounding factor of 1.5543122344752e-014 to the converted number. For e...
Page 613
Lsparsecurrency 613 lsparsecurrency description converts a locale-specific currency string into a formatted number. Attempts conversion by comparing the string with each the three supported currency formats (none, local, international) and using the first that matches. Returns a formatted number (st...
Page 614
614 chapter 3: coldfusion functions index = "locale" delimiters = ","> #locale# local: #lscurrencyformat(123456.78, "local")# parsed local currency: #lsparsecurrency(lscurrencyformat(123456,"local"))# international: #lscurrencyformat(123456.78999, "international")# parsed international currency: #ls...
Page 615
Lsparsedatetime 615 lsparsedatetime description converts a string that is a valid date/time representation in the current locale into a date/time object. Returns a date/time object. Category date and time functions , display and formatting functions , international functions , string functions funct...
Page 616
616 chapter 3: coldfusion functions valid dates are in the range 100 ad–9999 ad. Two digit years in the range 00-29 are interpreted as being 2000-2029. Two digit years in the range 30-99 are interpreted as being 1930-1999 this function corrects for differences between the current time zone and any t...
Page 617
Lsparseeurocurrency 617 lsparseeurocurrency description formats a locale-specific currency string as a number. Attempts conversion through each of the default currency formats (none, local, international). Ensures correct handling of euro currency for euro zone countries. Returns a formatted number ...
Page 618
618 chapter 3: coldfusion functions value with international currency formatting: #intlcurrency# parsed using lsparseeurocurrency: #lsparseeurocurrency(intlcurrency)# value with no currency formatting: #currency# parsed using lsparseeurocurrency: #lsparseeurocurrency(currency)#.
Page 619
Lsparsenumber 619 lsparsenumber description converts a string that is a valid numeric representation in the current locale into a formatted number. Returns a formatted number that matches the value of the string. Category international functions , string functions function syntax lsparsenumber(strin...
Page 620
620 chapter 3: coldfusion functions.
Page 621
Lstimeformat 621 lstimeformat description formats the time part of a date/time string into a string in a locale-specific format. Returns a string representing the time value. Category date and time functions , display and formatting functions , international functions function syntax lstimeformat(ti...
Page 622
622 chapter 3: coldfusion functions usage this function uses java standard locale formatting rules on all platforms. When passing date/time value as a string, enclose it in quotation marks. Otherwise, it is interpreted as a number representation of a date/time object. To calculate a difference betwe...
Page 623
Ltrim 623 ltrim description removes leading spaces from a string. Returns a copy of the string, without leading spaces. Category display and formatting functions , string functions function syntax ltrim(string) see also rtrim , tobase64 parameters example your string:"#form.Mytext#" your string:"#lt...
Page 624
624 chapter 3: coldfusion functions max description determines the greater of two numbers. Returns the greater of two numbers. Category mathematical functions function syntax max(number1, number2) see also min parameters example the maximum of the two numbers is #max(form.Mynum1, form.Mynum2)# the m...
Page 625
Mid 625 mid description extracts a substring from a string. Returns a string; the set of characters from string, beginning at start, of length count. Category string functions function syntax mid(string, start, count) see also left , len , right parameters example your string #form.Mytext# only has ...
Page 626
626 chapter 3: coldfusion functions min description determines the lesser of two numbers. Returns the lesser of two numbers. Category mathematical functions function syntax min(number1, number2) see also max parameters example the maximum of the two numbers is #max(form.Mynum1, form.Mynum2)# the min...
Page 627
Minute 627 minute description extracts the minute value from a date/time object. Returns the ordinal value of the minute, in the range 0–59. Category date and time functions function syntax minute(date) see also datepart , hash , second parameters usage when passing a date/time value as a string, yo...
Page 628
628 chapter 3: coldfusion functions month description extracts the month value from a date/time object. Returns the ordinal value of the month, in the range 1 (january) – 12 (december). Category date and time functions function syntax month(date) see also datepart , monthasstring , quarter parameter...
Page 629
Monthasstring 629 monthasstring description determines the name of the month that corresponds to month_number. Returns a string; the name of a month. Category date and time functions , string functions function syntax monthasstring(month_number) see also datepart , month , quarter parameters example...
Page 630
630 chapter 3: coldfusion functions now description gets the current date and time of the computer running the coldfusion server. The return value can be passed as a parameter to date functions such as daysinyear or firstdayofmonth . Returns a date/time object; the current date and time of the compu...
Page 631
Numberformat 631 numberformat description creates a custom-formatted number value. Supports the numeric formatting used in the u.S. For international number formatting, see lsnumberformat . Returns a formatted number value: • if no mask is specified, returns the value as an integer with a thousands ...
Page 632
632 chapter 3: coldfusion functions note: if you do not specify a sign for the mask, positive and negative numbers do not align in columns. To put a plus sign or space before positive numbers and a minus sign before negative numbers, use the plus or minus sign, respectively. Usage this function uses...
Page 633
Numberformat 633 when converting from string to double, to prevent rounding errors, this function adds a rounding factor of 1.5543122344752e-014 to the converted number. For example, without adding the rounding factor, converting the string value 1.275 to double with two digits of precision results ...
Page 634
634 chapter 3: coldfusion functions paragraphformat description replaces characters in a string: • single newline characters (cr/lf sequences) with spaces • double newline characters with html paragraph tags ( ) returns a copy of the string, with characters converted. Category display and formatting...
Page 635
Parameterexists 635 parameterexists description this function is deprecated. Use the isdefined function. Determines whether a parameter exists. Coldfusion does not evaluate the argument. History coldfusion mx: deprecated this function. It might not work, and might cause an error, in later releases..
Page 636
636 chapter 3: coldfusion functions parsedatetime description parses a date/time string according to the english (u.S.) locale conventions. (to format a date/ time string for other locales, use the lsparsedatetime function.) returns a date/time object category date and time functions , display and f...
Page 637
Parsedatetime 637 enter an expression, and discover if it can be evaluated to a date value. #timeformat(now())#">.
Page 638
638 chapter 3: coldfusion functions pi description gets the mathematical constant π , accurate to 15 digits. Returns the number 3.14159265358979. Category mathematical functions function syntax pi() see also asin , cos , sin , tan example the pi function returns the number #numberformat(pi(), "_.___...
Page 639
Preservesinglequotes 639 preservesinglequotes description prevents coldfusion from automatically escaping single quotation mark characters that are contained in a variable. Coldfusion does not evaluate the argument. Returns (none) category other functions function syntax preservesinglequotes(variabl...
Page 640
640 chapter 3: coldfusion functions this function ensures that coldfusion evaluates the code as follows: '1', '2', '3' example this is a useful function for creating lists of information to return from a query. In this example, we pick the list of centers in suisun, san francisco, and san diego, usi...
Page 641
Quarter 641 quarter description calculates the quarter of the year in which a date falls. Returns an integer, 1–4. Category date and time functions function syntax quarter(date) see also datepart , month parameters usage when passing a date/time value as a string, you must enclose it in quotation ma...
Page 642
642 chapter 3: coldfusion functions queryaddcolumn description adds a column to a query and populates its rows with the contents of a one-dimensional array. Pads query columns, if necessary, to ensure that all columns have the same number of rows. Returns the number of the column that was added. Cat...
Page 643
Queryaddcolumn 643 finecuisinearray)> healthfoodarray)> fast food fine cuisine health food #fastfood# #finecuisine# #healthfood# note: because there are fewer elements in the fine cuisine and health food arrays, queryaddcolumn added padding to the corresponding columns in the query. Finecuisinearray...
Page 644
644 chapter 3: coldfusion functions queryaddrow description adds a specified number of empty rows to a query. Returns the number of rows in the query category query functions function syntax queryaddrow(query [, number ]) see also queryaddcolumn , queryaddrow , querysetcell , querynew parameters exa...
Page 645
Querynew 645 querynew description creates an empty query (query object). Returns an empty query with a set of named columns, or an empty query. Category query functions function syntax querynew(columnlist) see also queryaddcolumn , queryaddrow , querysetcell parameters usage if you specify an empty ...
Page 646
646 chapter 3: coldfusion functions querysetcell description sets a cell to a value. If no row number is specified, the cell on the last row is set. Returns true, if successful; false, otherwise. Category query functions function syntax querysetcell(query, column_name, value [, row_number ]) see als...
Page 647
Quotedvaluelist 647 quotedvaluelist description gets the values of each record returned from an executed query. Coldfusion does not evaluate the arguments. Returns a delimited list of the values of each record returned from an executed query. Each value is enclosed in single quotation marks. Categor...
Page 648
648 chapter 3: coldfusion functions rand description generates a random number. Returns a random decimal number, in the range 0 – 1. Category mathematical functions function syntax rand() see also randomize , randrange usage to ensure greater randomness, call the randomize function before calling ra...
Page 649
Randomize 649 randomize description seeds the coldfusion random number generator with an integer number. Seeding the generator helps ensure that the rand function generates highly random numbers. Returns a non-random decimal number, in the range 0 – 1. Category mathematical functions function syntax...
Page 650
650 chapter 3: coldfusion functions randrange description generates a random integer between two specified numbers. Requests for random integers that are greater than 100,000,000 result in non-random numbers, to prevent overflow during internal computations. Returns a random integer category mathema...
Page 651
Refind 651 refind description uses a regular expression (re) to search a string for a pattern. The search is case sensitive. For more information on regular expressions, including escape sequences, anchors, and modifiers, see chapter 7, “using regular expressions in functions,” in developing coldfus...
Page 652
652 chapter 3: coldfusion functions usage this function finds the first occurrence of a regular expression in a string. To find the second and subsequent instances of the expression or of subexpressions in it, you call this function more than once, each time with a different start position. To deter...
Page 653
Refind 653 the number of elements in each array: #arraylen(st.Pos)#. The number of elements in the pos and len arrays is always one if you do not use parentheses in the regular expression. The value of st.Pos[1] is: #st.Pos[1]#. The value of st.Len[1] is: #st.Len[1]#. Substring is [#mid(teststring,s...
Page 654
654 chapter 3: coldfusion functions refindnocase description uses a regular expression (re) to search a string for a pattern, starting from a specified position. The search is case-insensitive. For more information on regular expressions, including escape sequences, anchors, and modifiers, see chapt...
Page 655
Refindnocase 655 usage this function finds the first occurrence of a regular expression in a string. To find the second and subsequent instances of the expression or of subexpressions in it, you call this function more than once, each time with a different start position. To determine the next start...
Page 656
656 chapter 3: coldfusion functions the number of elements in each array: #arraylen(st.Pos)#. The number of elements in the pos and len arrays will always be one, if you do not use parentheses to denote subexpressions in the regular expression. The value of st.Pos[1] is: #st.Pos[1]#. The value of st...
Page 657
Releasecomobject 657 releasecomobject description releases a com object and frees up resources that it used. Returns nothing. Category extensibility functions function syntax releasecomobject(objectname) see also createobject , cfobject history coldfusion mx 6.1: added this function. Parameters usag...
Page 658
658 chapter 3: coldfusion functions removechars description removes characters from a string. Returns a copy of the string, with count characters removed from the specified start position. If no characters are found, returns zero. Category string functions function syntax removechars(string, start, ...
Page 659
Repeatstring 659 repeatstring description creates a string that contains a specified number of repetitions of the specified string. Returns a string. Category string functions function syntax repeatstring(string, count) see also cjustify , ljustify , rjustify parameters example repeatstring returns ...
Page 660
660 chapter 3: coldfusion functions replace description replaces occurrences of substring1 in a string with substring2, in a specified scope. The search is case-sensitive. Returns the string, after making replacements. Category string functions function syntax replace(string, substring1, substring2 ...
Page 661
Replacelist 661 replacelist description replaces occurrences of the elements from a delimited list in a string with corresponding elements from another delimited list. The search is case-sensitive. Returns a copy of the string, after making replacements. Category list functions , string functions fu...
Page 662
662 chapter 3: coldfusion functions #replacelist(stringtoreplace,"dog,brown,fox,black", "cow,black,ferret,white")#.
Page 663
Replacenocase 663 replacenocase description replaces occurrences of substring1 with substring2, in the specified scope. The search is case- insensitive. Returns a copy of the string, after making replacements. Category string functions function syntax replacenocase(string, substring1, substring2 [, ...
Page 664
664 chapter 3: coldfusion functions rereplace description uses a regular expression (re) to search a string for a string pattern and replace it with another. The search is case-sensitive. Returns if the scope attribute is set to one , returns a string with the first occurrence of the regular express...
Page 666
666 chapter 3: coldfusion functions rereplacenocase description uses a regular expression to search a string for a string pattern and replace it with another. The search is case-insensitive. Returns • if scope = "one" : returns a string with the first occurrence of the regular expression replaced by...
Page 668
668 chapter 3: coldfusion functions reverse description reverses the order of items, such as the characters in a string, the digits in a number, or the elements in an array. Returns a copy of string, with the characters in reverse order. Category string functions function syntax reverse(string) see ...
Page 669
Right 669 right description gets a specified number of characters from a string, beginning at the right. Returns • if the length of the string is greater than or equal to count , the rightmost count characters of the string • if count is greater than the length of the string, the whole string • if c...
Page 670
670 chapter 3: coldfusion functions rjustify description right justifies characters of a string. Returns a copy of a string, right-justified in the specified field length. Category display and formatting functions , string functions function syntax rjustify(string, length) see also cjustify , ljusti...
Page 671
Round 671 round description rounds a number to the closest integer. Returns an integer. Category mathematical functions function syntax round(number) see also ceiling , fix , int parameters example this function rounds a number to the closest integer. Parameter description number number to round.
Page 672
672 chapter 3: coldfusion functions rtrim description removes spaces from the end of a string. Returns a copy of string, after removing trailing spaces. Category string functions function syntax rtrim(string) see also ltrim , trim parameters example your string:"#form.Mytext#" your string:"#rtrim(fo...
Page 673
Second 673 second description extracts the ordinal for the second from a date/time object. Returns an integer in the range 0–59. Category date and time functions function syntax second(date) see also datepart , hash , minute parameters usage when passing a date/time object as a string, you must encl...
Page 674
674 chapter 3: coldfusion functions setencoding description sets the character encoding (character set) of form and url scope variable values; used when the character encoding of the input to a form, or the character encoding of a url, is not in utf-8 encoding. Returns none category international fu...
Page 675
Setencoding 675 • www.Iana.Org/assignments/character-sets is a complete list of character sets names used on the internet, maintained by the internet assigned numbers authority. • java.Sun.Com/j2se/1.4.1/docs/guide/intl/encoding.Doc.Html lists the character encoding that java 1.4.1, and therefore th...
Page 676
676 chapter 3: coldfusion functions setlocale description sets the country/language locale for coldfusion processing and the page returned to the client. The locale value determines the default format of date, time, number, and currency values, according to language and regional conventions. Returns...
Page 677
Setlocale 677 coldfusion determines the locale value as follows: • by default, coldfusion uses the jvm locale, and the default jvm locale is the operating system locale. You can set jvm locale value explicitly in coldfusion mx in the coldfusion administrator java and jvm settings page jvm arguments ...
Page 678
678 chapter 3: coldfusion functions setprofilestring description sets the value of a profile entry in an initialization file. Returns an empty string, upon successful execution; otherwise, an error message. Category system functions function syntax setprofilestring(inipath, section, entry, value) se...
Page 679
Setprofilestring 679 the timeout value in your initialization file is already #mytimeout#. Timeout is set to: #timeout#. Default directory is: #default#. Value = "c:\myboot.Ini">.
Page 680
680 chapter 3: coldfusion functions setvariable description this function is no longer required in well-formed coldfusion pages. Sets a variable in the name parameter to the value of the value parameter. Returns the new value of the variable. Category dynamic evaluation functions function syntax set...
Page 681
Setvariable 681 your variable, #varname# the value of #varname# is #varnamevalue#.
Page 682
682 chapter 3: coldfusion functions sgn description determines the sign of a number. Returns • 1, if number is positive. • 0, if number is 0. • -1, if number is negative. Category mathematical functions function syntax sgn(number) see also abs parameters example sgn determines the sign of a number. ...
Page 683
Sin 683 sin description calculates the sine of an angle that is entered in radians. Returns a number; the sine of the angle. Category mathematical functions function syntax sin(number) see also asin , cos , acos , tan , atn , pi parameters usage the range of the result is -1 to 1. To convert degrees...
Page 684
684 chapter 3: coldfusion functions.
Page 685
Spanexcluding 685 spanexcluding description gets characters from a string , from the beginning to a character that is in a specified set of characters. The search is case-sensitive. Returns a string; characters from string, from the beginning to a character that is in set . Category string functions...
Page 686
686 chapter 3: coldfusion functions spanincluding description gets characters from a string , from the beginning to a character that is not in a specified set of characters. The search is case-sensitive. Returns a string; characters from string, from the beginning to a character that is not in set ....
Page 687
Sqr 687 sqr description calculates the square root of a number. Returns number; square root of number. Category mathematical functions function syntax sqr(number) see also abs parameters usage the value in number must be greater than or equal to 0. Example returns the square root of a positive numbe...
Page 688
688 chapter 3: coldfusion functions stripcr description deletes return characters from a string. Returns a copy of string, after removing return characters. Category display and formatting functions , other functions , string functions function syntax stripcr(string) see also paragraphformat paramet...
Page 689
Structappend 689 structappend description appends one structure to another. Returns true, upon successful completion; false, otherwise. Category structure functions function syntax structappend(struct1, struct2, overwriteflag) see also structure functions history coldfusion mx: changed behavior: thi...
Page 690
690 chapter 3: coldfusion functions the person struct before the append call: #myitem# the person struct after the append call: #myitem#.
Page 691
Structclear 691 structclear description removes all data from a structure. Returns true, on successful execution; false, otherwise. Category structure functions function syntax structclear(structure) see also structure functions history coldfusion mx: changed behavior: this function can be used on x...
Page 692
692 chapter 3: coldfusion functions structclear(employee);.
Page 693
Structcopy 693 structcopy description copies a structure. Copies top-level keys, values, and arrays in the structure by value; copies nested structures by reference. Returns a copy of a structure, with the same keys and values; if structure does not exist, throws an exception. Category structure fun...
Page 694
694 chapter 3: coldfusion functions example // this script creates a structure that structcopy copies by value. // create elements. S = structnew(); s.Array = arraynew(2); // assign simple values to original top-level structure fields. S.Number = 99; s.String = "hello tommy"; // assign values to ori...
Page 695
Structcopy 695 copied.String = #copied.String# // array value copied.Array[1][1] = #copied.Array[1][1]# copied.Array[1][2] = #copied.Array[1][2]# // this script creates a structure that structcopy copies by reference. // create elements. S = structnew(); s.Nested = structnew(); s.Nested.Array = arra...
Page 696
696 chapter 3: coldfusion functions copied.Nested.Number = #copied.Nested.Number# copied.Nested.String = #copied.Nested.String# // array values copied.Nested.Array[1][1] = #copied.Nested.Array[1][1]# copied.Nested.Array[1][2] = #copied.Nested.Array[1][2]# duplicated structure values should remain un...
Page 697
Structcount 697 structcount description counts the keys in a structure. Returns a number; if structure does not exist, throws an exception. Category structure functions function syntax structcount(structure) see also structure functions history coldfusion mx: changed behavior: this function can be u...
Page 698
698 chapter 3: coldfusion functions structdelete description removes an element from a structure. Returns boolean value. The value depends on the indicatenotexisting parameter value. Category structure functions function syntax structdelete(structure, key [, indicatenotexisting ]) see also structure...
Page 699
Structdelete 699 did i delete the field "#form.Field#"? The code indicates: #rc# the structure now looks like this: select the field to be deleted: first name last name email phone department delete this comment to make this page work --->.
Page 700
700 chapter 3: coldfusion functions structfind description determines the value associated with a key in a structure. Returns the value associated with a key in a structure; if structure does not exist, throws an exception. Category structure functions function syntax structfind(structure, key) see ...
Page 701
Structfindkey 701 structfindkey description searches recursively through a substructure of nested arrays, structures, and other elements, for structures whose values match the search key in the value parameter. Returns an array that contains structures with values that match value. Category structur...
Page 702
702 chapter 3: coldfusion functions structfindvalue description searches recursively through a substructure of nested arrays, structures, and other elements for structures with values that match the search key in the value parameter. Returns an array that contains structures with values that match t...
Page 703
Structget 703 structget description gets a structure(s) from a specified path. Returns an alias to the variable in the pathdesired parameter. If necessary, structget creates structures or arrays to make pathdesired a valid variable "path." category structure functions function syntax structget(pathd...
Page 704
704 chapter 3: coldfusion functions #request.Myscope[1].Test.Foo# #request.Myscope[1].Test[2].Foo#.
Page 705
Structinsert 705 structinsert description inserts a key-value pair into a structure. Returns true, upon successful completion. If structure does not exist, or if key exists and allowoverwrite = "false" , coldfusion throws an exception. Category structure functions function syntax structinsert(struct...
Page 706
706 chapter 3: coldfusion functions first name is #structfind(employee, "firstname")# last name is #structfind(employee, "lastname")# email is #structfind(employee, "email")# phone is #structfind(employee, "phone")# department is #structfind(employee, "department")# first name: last name: email: pho...
Page 707
Structisempty 707 structisempty description determines whether a structure contains data. Returns true, if structure is empty; if structure does not exist, coldfusion throws an exception. Category decision functions , structure functions function syntax structisempty(structure) see also structure fu...
Page 708
708 chapter 3: coldfusion functions structkeyarray description finds the keys in a coldfusion structure. Returns an array of keys; if structure does not exist, coldfusion throws an exception. Category structure functions function syntax structkeyarray(structure) see also structure functions paramete...
Page 709
Structkeyarray 709 value = "" hspace = "30" maxlength = "30"> value = "" hspace = "30" maxlength = "30"> value = "" hspace = "30" maxlength = "30"> value = "" hspace = "20" maxlength = "20"> value = "" hspace = "30" maxlength = "30"> value = "ok"> key#i# is #keystostruct[i]# value#i# is #employee[ke...
Page 710
710 chapter 3: coldfusion functions structkeyexists description determines whether a specific key is present in a structure. Returns true, if key is in structure; if structure does not exist, coldfusion throws an exception. Category decision functions , structure functions function syntax structkeye...
Page 711
Structkeylist 711 structkeylist description extracts keys from a coldfusion structure. Returns a list of keys; if structure does not exist, coldfusion throws an exception. Category structure functions function syntax structkeylist(structure [, delimiter]) see also structure functions parameters usag...
Page 712
712 chapter 3: coldfusion functions after you enter employee information into structure, example uses structkeylist function to list keys in structure. This code does not show how to insert information into a database. See cfquery for more information about database insertion. Value = "" hspace = "3...
Page 713
Structnew 713 structnew description creates a structure. Returns a structure. Category structure functions function syntax structnew() see also structure functions parameters none example please fill out the form. Employee = structnew(); structinsert(employee, "firstname", form.Firstname); structins...
Page 714
714 chapter 3: coldfusion functions structsort description returns a sorted array of the top level keys in a structure. Sorts using alphabetic or numeric sorting, and can sort based on the values of any structure element. Returns an array of top-level key names (strings), sorted by the value of the ...
Page 715
Structsort 715 departments["department#i#"] = structnew() ; departments["department#i#"].Boss = employee ; } list of employees based on the salary (text search): 1) #arraytolist( structsort( salaries ) )# 2) #arraytolist( structsort( salaries, "text", "asc" ) )# 3) #arraytolist( structsort( salaries...
Page 716
716 chapter 3: coldfusion functions structupdate description updates a key with a value. Returns true, on successful execution; if the structure does not exist, coldfusion throws an error. Category structure functions function syntax structupdate(structure, key, value) see also structure functions h...
Page 717
Tan 717 tan description calculates the tangent of an angle that is entered in radians. Returns a number; the tangent of an angle. Category mathematical functions function syntax tan(number) see also atn , cos , acos , sin , asin , pi parameters usage to convert degrees to radians, multiply degrees b...
Page 718
718 chapter 3: coldfusion functions.
Page 719
Timeformat 719 timeformat description formats a time value using us english time formatting conventions. Returns a custom-formatted time value. If no mask is specified, returns a time value using the hh:mm tt format. For international time formatting, see lstimeformat . Category date and time functi...
Page 720
720 chapter 3: coldfusion functions parameters usage when passing a date/time value as a string, you must enclose it in quotation marks. Otherwise, it is interpreted as a number representation of a date/time object. Database query results for date and time values can vary in sequence and formatting ...
Page 721
Tobase64 721 tobase64 description calculates the base64 representation of a string or binary object. The base64 format uses printable characters, allowing binary data to be sent in forms and e-mail, and stored in a database or file. The base64 representation of a string or binary object. Category co...
Page 722
722 chapter 3: coldfusion functions base64 lets you store binary objects in a database. Note: to reverse base64 encoding of a string, you can convert it to a binary object, then convert the binary object to a string, using the tostring function. Example the following string is the concatenation of a...
Page 723
Tobinary 723 tobinary description calculates the binary representation of base64-encoded data. Returns the binary representation of base64-encoded data. Category conversion functions , other functions , string functions function syntax tobinary(string_in_base64 or binary_value) see also • cffile for...
Page 724
724 chapter 3: coldfusion functions.
Page 725
Tostring 725 tostring description converts a value to a string. Returns a string. Category conversion functions , other functions , string functions function syntax tostring(any_value[, encoding]) see also tobase64 , tobinary history coldfusion mx: • changed unicode support: coldfusion supports the ...
Page 726
726 chapter 3: coldfusion functions example the following string is the concatenation of characters (32 to 255) from the ascii table. #chardata# the following string is the base64 representation of the string. #data64# tostring(databinary)> the following is the string representation of the binary da...
Page 727
Trim 727 trim description removes leading and trailing spaces from a string. Returns a copy of string, after removing leading and trailing spaces. Category string functions function syntax trim(string) see also ltrim , rtrim parameters example your string:"#form.Mytext#" your string:"#trim(form.Myte...
Page 728
728 chapter 3: coldfusion functions ucase description converts the alphabetic characters in a string to uppercase. Returns a copy of a string, converted to uppercase. Category string functions function syntax ucase(string) see also lcase parameters example your text, #form.Sampletext#, returned in u...
Page 729
Urldecode 729 urldecode description decodes a url-encoded string. Returns a copy of a string, decoded. Category conversion functions , other functions , string functions function syntax urldecode(urlencodedstring[, charset]) see also urlencodedformat history coldfusion mx 6.1: changed the default ch...
Page 730
730 chapter 3: coldfusion functions query strings in http are always url-encoded. Example this example creates, encodes, and decodes a string that contains ascii character codes. // build string s = ""; for (c = 1; c lte 256; c = c + 1) { s = s & chr(c); } // encode string and display result enc = u...
Page 731
Urlencodedformat 731 urlencodedformat description generates a url-encoded string. For example, it replaces spaces with %20 , and non- alphanumeric characters with equivalent hexadecimal escape sequences. Passes arbitrary strings within a url (coldfusion automatically decodes url parameters that are ...
Page 732
732 chapter 3: coldfusion functions the url variable url.Myexample was passed from the previous link ... Its value is: "#url.Myexample#" this function returns a url encoded string. ">click me.
Page 733
Urlsessionformat 733 urlsessionformat description depending on whether a client computer accepts cookies, this function does the following: • if the client does not accept cookies: automatically appends all required client identification information to a url • if the client accepts cookies: does not...
Page 734
734 chapter 3: coldfusion functions val description converts numeric characters that occur at the beginning of a string to a number. Returns a number. If conversion fails, returns zero. Category conversion functions , string functions function syntax val(string) see also isnumeric parameters usage t...
Page 735
Valuelist 735 valuelist description inserts a delimiter between each value in an executed query. Coldfusion does not evaluate the arguments. Returns a delimited list of the values of each record returned from an executed query. Category other functions , query functions function syntax valuelist(que...
Page 736
736 chapter 3: coldfusion functions week description from a date/time object, determines the week number within the year. Returns an integer in the range 1–53; the ordinal of the week, within the year. Category date and time functions function syntax week(date) see also datepart parameters usage whe...
Page 737
Wrap 737 wrap description wraps text so that each line has a specified maximum number of characters. Returns string containing the wrapped text. Category string functions function syntax wrap(string, limit[, strip]) see also cfmail history coldfusion mx 6.1: added this function parameters usage inse...
Page 738
738 chapter 3: coldfusion functions writeoutput description appends text to the page-output stream. This function writes to the page-output stream regardless of conditions established by the cfsetting tag. Category other functions function syntax writeoutput(string ) parameters usage within the cfqu...
Page 739
Xmlchildpos 739 xmlchildpos description gets the position of a child element within an xml document object. Returns the position, in an xmlchildren array, of the nth child that has the specified name. Category extensibility functions , xml functions function syntax xmlchildpos(elem, childname, n) se...
Page 740
740 chapter 3: coldfusion functions xmlelemnew description creates an xml document object element. Returns an xml document object element. Category extensibility functions , xml functions function syntax xmlelemnew(xmlobj, childname) see also cfxml , isxmldoc , xmlchildpos , xmlformat , xmlnew , xml...
Page 741
Xmlformat 741 xmlformat description escapes special xml characters in a string, so that the string is safe to use with xml. Returns a copy of string that is safe to use with xml. Category extensibility functions , string functions , xml functions function syntax xmlformat(string) see also cfxml , is...
Page 742
742 chapter 3: coldfusion functions xmlnew description creates an xml document object. Returns an empty xml document object. Category extensibility functions , xml functions function syntax xmlnew([casesensitive]) see also cfxml , isxmldoc , xmlchildpos , xmlchildpos , xmlformat , xmlparse , xmlsear...
Page 743
Xmlnew 743 }.
Page 744
744 chapter 3: coldfusion functions xmlparse description converts an xml document that is represented as a string variable into an xml document object. Returns an xml document object. Category conversion functions , extensibility functions , xml functions function syntax xmlparse(xmlstring [, casese...
Page 745
Xmlsearch 745 xmlsearch description uses an xpath language expression to search an xml document that is represented as a string variable. Returns an array of xml object nodes that match the search criteria. Category extensibility functions , xml functions function syntax xmlsearch(xmldoc, xpathstrin...
Page 746
746 chapter 3: coldfusion functions xmltransform description applies an extensible stylesheet language transformation (xslt) to an xml document object that is represented as a string variable. An xslt converts an xml document to another format or representation by applying an extensible stylesheet l...
Page 747
Year 747 year description from a date/time object, gets the year value. Returns the year value of date. Category date and time functions function syntax year(date) see also datepart , isleapyear parameters usage when passing a date as a string, enclose it in quotation marks. Otherwise, it is interpr...
Page 748
748 chapter 3: coldfusion functions yesnoformat description evaluates a number or boolean value. Returns yes, for a non-zero value; no, otherwise. Category decision functions , display and formatting functions function syntax yesnoformat(value) see also isbinary , isnumeric parameters example the ye...
Page 749: Chapter 4
749 chapter 4 coldfusion c++ cfx reference this chapter describes the cfxapi classes and members. Contents c++ class overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 750 deprecated class members . . . . . . . . . . . . . . . ....
Page 750
750 chapter 4: coldfusion c++ cfx reference c++ class overview a list of cfxapi classes and members follows. Deprecated class members the following cfxapi classes and members are deprecated. They do not work, and might cause an error, in later releases. Class member ccfxexception class ccfxexception...
Page 751
Ccfxexception class 751 ccfxexception class an abstract class that represents an exception thrown during processing of a coldfusion extension (cfx) procedure. Exceptions of this type can be thrown by ccfxrequest class , ccfxquery class , and ccfxstringset class . Your coldfusion extension code must ...
Page 752
752 chapter 4: coldfusion c++ cfx reference // write output back to the user here... Prequest->write( "hello from cfx_foo2!" ) ; prequest->throwexception("user error", "you goof'd..."); // output optional debug info if ( prequest->debug() ) { prequest->writedebug( "debug info..." ) ; } // catch cold...
Page 753
Ccfxquery class 753 ccfxquery class an abstract class that represents a query used or created by a coldfusion extension (cfx). Queries contain one or more columns of data that extend over a varying number of rows. Class members ccfxquery::addrow syntax int ccfxquery::addrow(void) description add a r...
Page 754
754 chapter 4: coldfusion c++ cfx reference ccfxquery::getcolumns syntax ccfxstringset* ccfxquery::getcolumns(void) description retrieves a list of the column names contained in a query. Returns returns an object of ccfxstringset class that contains a list of the columns in the query. Coldfusion aut...
Page 755
Ccfxquery class 755 example the following example iterates over the elements of a query and writes the data in the query back to the user in a simple, space-delimited format: int irow, icol ; int nnumcols = pquery->getcolumns()->getcount() ; int nnumrows = pquery->getrowcount() ; for ( irow=1; irow ...
Page 756
756 chapter 4: coldfusion c++ cfx reference ccfxquery::setdata syntax void ccfxquery::setdata(int irow, int icolumn, lpcstr lpszdata) description sets a data element within a row and column of a query. Row and column indexes begin with 1. Before calling setdata for a given row, call ccfxquery::addro...
Page 757
Ccfxrequest class 757 ccfxrequest class abstract class that represents a request made to a coldfusion extension (cfx). An instance of this class is passed to the main function of your extension dll. The class provides interfaces that can be used by the custom extension for the following actions: • r...
Page 758
758 chapter 4: coldfusion c++ cfx reference ccfxrequest::addquery syntax ccfxquery* ccfxrequest::addquery(lpcstr lpszname, ccfxstringset* pcolumns) description adds a query to the calling template. The query can be accessed by cfml tags (for example, cfoutput or cftable ) within the template. After ...
Page 759
Ccfxrequest class 759 ccfxrequest::attributeexists syntax bool ccfxrequest::attributeexists(lpcstr lpszname) description checks whether the attribute was passed to the tag. Returns true if the attribute is available; false, otherwise. Parameters example the following example checks whether the user ...
Page 760
760 chapter 4: coldfusion c++ cfx reference ccfxrequest::debug syntax bool ccfxrequest::debug(void) description checks whether the tag contains the debug attribute. Use this function to determine whether to write debug information for a request. For more information, see ccfxrequest::writedebug . Re...
Page 761
Ccfxrequest class 761 ccfxrequest::getattributelist syntax ccfxstringset*ccfxrequest::getattributelist(void) description gets an array of attribute names passed to the tag. To get the value of one attribute, use ccfxrequest::getattribute . Returns returns an object of class ccfxstringset class that ...
Page 762
762 chapter 4: coldfusion c++ cfx reference ccfxrequest::getquery syntax ccfxquery* ccfxrequest::getquery(void) description retrieves a query that was passed to a tag. To pass a query to a custom tag, you use the query attribute. This attribute should be set to the name of a query (created using the...
Page 763
Ccfxrequest class 763 example the following code demonstrates how to handle exceptions in coldfusion extension dll procedures: try { ...Code that could throw an exception... } catch( ccfxexception* e ) { ...Do appropriate resource cleanup here... // re-throw the exception prequest->rethrowexception(...
Page 764
764 chapter 4: coldfusion c++ cfx reference ccfxrequest::setvariable syntax void ccfxrequest::setvariable(lpcstr lpszname, lpcstr lpszvalue) description sets a variable in the calling template. If the variable name already exists in the template, its value is replaced. If it does not exist, a variab...
Page 765
Ccfxrequest class 765 example the following example throws an exception indicating that an unexpected error occurred while processing a request: char bufferror[512] ; wsprintf( bufferror, "unexpected windows nt error number %ld " "occurred while processing request.", getlasterror() ) ; prequest->thr...
Page 766
766 chapter 4: coldfusion c++ cfx reference ccfxstringset class abstract class that represents a set of ordered strings. Strings can be added to a set and can be retrieved by a numeric index (index values for strings are 1-based). To create a string set, use ccfxrequest::createstringset . Class memb...
Page 767
Ccfxstringset class 767 returns returns the number of strings contained in the string set. Example the following example demonstrates using getcount with ccfxstringset::getstring to iterate over a string set and write the contents of the list back to the user: int nnumitems = pstringset->getcount() ...
Page 768
768 chapter 4: coldfusion c++ cfx reference returns returns the string located at the passed index. Parameters example the following example demonstrates getstring with ccfxstringset::getcount to iterate over a string set and write the contents of a list back to the user: int nnumitems = pstringset-...
Page 769: Chapter 5
769 chapter 5 coldfusion java cfx reference this chapter describes the java interfaces available for building coldfusion custom cfxs in java. Contents overview class libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 770 customtag inte...
Page 770
770 chapter 5: coldfusion java cfx reference overview class libraries the following java interfaces are available for building coldfusion custom cfxs in java. Customtag interface public abstract interface customtag interface for implementing custom tags. Classes that implement this interface can be ...
Page 771
Customtag interface 771 category customtag interface syntax public void processrequest(request request, response response) throws exception if an unexpected error occurs while processing the request. Parameters parameter description request parameters (attributes, query, and so on.) for this request...
Page 772
772 chapter 5: coldfusion java cfx reference query interface public abstract interface query interface to a query used or created by a custom tag. A query contains tabular data organized by named columns and rows. Methods addrow description adds a row to a query. Call this method to append a row to ...
Page 773
Query interface 773 query.Setdata( irow, istate, "mn" ) ; query.Setdata( irow, izip, "55105" ) ; getcolumnindex description returns the index of the column, or 0 if no such column exists. Category query interface syntax public int getcolumnindex(string name) see also getcolumns , getdata parameters ...
Page 774
774 chapter 5: coldfusion java cfx reference // print the list of columns to the user response.Write( "columns in query: " ) ; for( int i=0; i { response.Write( columns[i] + " " ) ; } getdata description retrieves a data element from a row and column of a query. Row and column indexes begin with 1. ...
Page 775
Query interface 775 getname description returns the name of a query. Category query interface syntax public string getname() example the following example retrieves the name of a query and writes it back to the user: query query = request.Getquery() ; response.Write( "the query name is: " + query.Ge...
Page 776
776 chapter 5: coldfusion java cfx reference see also getdata , addrow parameters example the following example demonstrates the addition of two rows to a query that has three columns, city, state, and zip: // define column indexes int icity = 1, istate = 2, izip = 3 ; // first row int irow = query....
Page 777
Request interface 777 request interface public abstract interface request interface to a request made to a customtag. The interface includes methods for retrieving attributes passed to the tag (including queries) and reading global tag settings. Methods attributeexists description checks whether the...
Page 778
778 chapter 5: coldfusion java cfx reference "missing destination parameter", "you must pass a destination parameter in " "order for this tag to work correctly." ) ; } ; debug description checks whether the tag contains the debug attribute. Use this method to determine whether to write debug informa...
Page 779
Request interface 779 example the following example retrieves an attribute named destination and writes its value back to the user: string strdestination = request.Getattribute("destination") ; response.Write( "the destination is: " + strdestination ) ; getattributelist description retrieves a list ...
Page 780
780 chapter 5: coldfusion java cfx reference throws numberformatexception if the attribute is not a valid number. See also attributeexists , getattributelist , getintattribute parameters example the following example retrieves an attribute named port and writes its value back to the user: int nport ...
Page 781
Request interface 781 returns the value of the custom tag setting. If no setting of that name exists, an empty string is returned. Category request interface syntax public string getsetting(string name) parameters usage all custom tags implemented in java share a registry key for storing settings. T...
Page 782
782 chapter 5: coldfusion java cfx reference response interface public abstract interface response interface to response generated from a custom tag. This interface includes methods for writing output, generating queries, and setting variables in the calling page. Methods addquery description adds a...
Page 783
Response interface 783 // add data to the query int irow = query.Addrow() ; query.Setdata( irow, ifirstname, "john" ) ; query.Setdata( irow, ilastname, "smith" ) ; irow = query.Addrow() ; query.Setdata( irow, ifirstname, "jane" ) ; query.Setdata( irow, ilastname, "doe" ) ; setvariable description se...
Page 784
784 chapter 5: coldfusion java cfx reference write description outputs text back to the user. Category response interface syntax public void write(string output) parameters example the following example outputs the value of the destination attribute: response.Write( "destination = " + request.Getatt...
Page 785
Debugging classes reference 785 debugging classes reference the constructors and methods supported by the debugrequest , debugresponse , and debugquery classes are as follows. These classes also support the other methods of the request , response , and query interfaces, respectively. Debugrequest //...
Page 786
786 chapter 5: coldfusion java cfx reference.
Page 787: Chapter 6
787 chapter 6 wddx javascript objects this chapter provides information about javascript objects and functions used to wddx in a coldfusion application. Contents javascript object overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 788 wddxs...
Page 788
788 chapter 6: wddx javascript objects javascript object overview these are the javascript objects and functions. Wddx javascript objects are defined in the wddx.Js file; this file is installed in the webroot/ cfide/scripts directory. To use these objects, you must put a javascript tag before the co...
Page 789
Wddxserializer object 789 wddxserializer object the wddxserializer object includes functions that serialize any javascript data structure. Functions the only function that developers typically call is serialize . Serialize description creates a wddx packet for a passed wddxrecordset instance. Syntax...
Page 790
790 chapter 6: wddx javascript objects alert("couldn't serialize data"); } } serializevariable description serializes a property of a structure. If an object is not a string, number, array, boolean, or date, wddxserializer treats it as a structure. Syntax object.Serializevariable( name, obj ) parame...
Page 791
Wddxserializer object 791 • recordset • any javascript object this function serializes null values as empty strings. Syntax object.Serializevalue( obj ) parameters return value returns a boolean true if obj was serialized successfully; or false if an error occurs. Usage this is an internal function;...
Page 792
792 chapter 6: wddx javascript objects usage this is an internal function; you do not typically call it. Example this example is from the wddxserializer serializevalue function: ... Else if (typeof(obj) == "number") { // number value this.Write("" + obj + ""); } else if (typeof(obj) == "boolean") { ...
Page 793
Wddxrecordset object 793 wddxrecordset object includes functions that you call as needed when constructing a wddx record set. Functions : returns html table of the wddxrecordset object data. Usage convenient for debugging and testing record sets. The boolean parameter escapestrings determines whethe...
Page 794
794 chapter 6: wddx javascript objects parameters return value none. Usage adds a column to every row of the wddx record set. Initially the new column’s values are set to null. Example this example calls the addcolumn function: // create a new record set rs = new wddxrecordset(); // add a new column...
Page 795
Wddxrecordset object 795 // create a new record set rs = new wddxrecordset(); // add a new column rs.Addcolumn("newcolumn"); // extend the record set by 3 rows rs.Addrows(3); // set an element in the first row // newvalue is a previously defined variable rs.Setfield(0, "newcolumn", newvalue); getfie...
Page 796
796 chapter 6: wddx javascript objects getrowcount description indicates the number of rows in a wddxrecordset instance. Syntax object.Getrowcount( ) parameters return value integer. Returns the number of rows in the wddxrecordset instance. Usage call this function before a looping construct to dete...
Page 797
Wddxrecordset object 797 example this example calls the setfield function: // create a new recordset rs = new wddxrecordset(); // add a new column rs.Addcolumn("newcolumn"); // extend the record set by 3 rows rs.Addrows(3); // set an element in the first row // newvalue is a previously defined varia...
Page 798
798 chapter 6: wddx javascript objects.
Page 799: Chapter 7
799 chapter 7 coldfusion actionscript functions this chapter explains the syntax and usage of the two server-side actionscript functions, cf.Query and cf.Http . Contents cf.Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....
Page 800
800 chapter 7: coldfusion actionscript functions cf.Query description performs queries against coldfusion data sources. Return value returns a recordset object.W syntax cf.Query ({ datasource:"data source name", sql:"sql stmts", username:"username", password:"password", maxrows:number, timeout:milli...
Page 801
Cf.Http 801 • recordset.Getcolumnnames • recordset.Getlength • recordset.Getitemat • recordset.Getitemid • recordset.Sortitemsby • recordset.Getnumberavailable • recordset.Filter • recordset.Sort for more information on using server-side actionscript, see chapter 30, “using server-side actionscript,...
Page 802
802 chapter 7: coldfusion actionscript functions syntax cf.Http ({ method:"get or post", url:"url", username:"username", password:"password", resolveurl:"yes or no", params:arrayvar, path:"path", file:"filename" }) arguments arguments req/opt description method required one of two arguments: • get: ...
Page 803
Cf.Http 803 usage you can write the cf.Http function using named arguments or positional arguments. You can invoke all supported arguments using the named argument style, as follows: cf.Http({method:"method", url:"url", username:"username", password:"password", resolveurl:"yes or no", params:arrayva...
Page 804
804 chapter 7: coldfusion actionscript functions you access these attributes using the get function: function basicget() { url = "http://localhost:8100/"; // invoke with just the url. This is an http get. Result = cf.Http(url); return result.Get("filecontent"); } note: for more information on using ...
Page 805
Cf.Http 805 result = cf.Http({method:"post", url:url, username:"karl", password:"salsa", resolveurl:true, params:params, path:path, file:file}); if (result) return result.Get("statuscode"); return null; } // example of a basic http get operation // shows that http get is the default function basicge...
Page 806
806 chapter 7: coldfusion actionscript functions.