Register for EarthWeb's Million Dollar Sweepstakes!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Platinum Edition Using HTML 4, XML, and Java 1.2
(Publisher: Macmillan Computer Publishing)
Author(s): Eric Ladd
ISBN: 078971759x
Publication Date: 11/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


String Functions

CFML comes with a wealth of functions that make string manipulation a breeze. In fact, nearly one quarter of all CFML functions operate on strings. The following list summarizes some of the more commonly used string functions:

  Asc(str)—Returns the ASCII numeric value of the first character of str.
  Chr(val)—Returns the character with the ASCII value equal to val.
  CJustify(str,len)—Centers str in a field of length len.
  Compare(str1,str2)—Does a case-sensitive comparison of str1 and str2, returning -1 if str1 is less than str2, 0 if the strings are equal, and 1 if str1 is greater than str2.
  CompareNoCase(str1,str2)—Does a case-sensitive comparison of str1 and str2, returning -1 if str1 is less than str2, 0 if the strings are equal, and 1 if str1 is greater than str2.
  Find(str1,str2,start)—Returns the position in str2 where there is an occurrence of str1. The case-sensitive search begins at the first character unless you specify a different value with the start parameter. The function returns 0 if no occurrence of str1 is found.
  FindNoCase(str1,str2,start)—Returns the position in str2 where there is an occurrence of str1. The not case-sensitive search begins at the first character unless you specify a different value with the start parameter. The function returns 0 if no occurrence of str1 is found.
  Insert(str1,str2,pos)—Inserts str1 into str2 at position pos. If pos is 0, the function concatenates str1 and str2.
  LCase(str)—Converts str to lowercase.
  Left(str,pos)—Returns the leftmost pos characters from str.
  Len(str)—Returns the number of characters in str.
  LTrim(str)—Removes any leading spaces from str.
  Mid(str,start,num)—Extracts num characters from str, starting at position start.
  REFind(rexpr,str,start)—Returns the position of an occurrence of the regular expression rexpr in str, beginning its search at position start.
  Replace(str1,str2,str3,scope)—Replaces occurrences of str2 in str1 with str3. scope controls how many replacements should be made (one or all).
  RERplace(str1,rexpr,str2,scope)—Replaces occurrences of the regular expression rexpr in str1 with str2. scope controls how many replacements should be made (one or all).
  Reverse(str)—Reverses the order of the characters in str.
  Right(str,pos)—Returns the rightmost pos characters from str.
  RJustify(str,len)—Right-justifies str in a field of length len.
  RTrim(str)—Removes trailing spaces from str.
  UCase(str)—Converts str to uppercase.

Formatting Functions

ColdFusion can do some of the preparatory work that needs to be done before displaying a value. The following are some of the more popular CFML formatting functions:

  DateFormat(date,mask)—Formats date according to the specified mask. A mask of mm/dd/yy, for example, would yield a date in the form 12/31/98.
  DollarFormat(number)—Returns number formatted as a dollar amount with a dollar sign, decimal point, and commas where necessary.
  HTMLEditFormat(HTMLcode)—Removes reserved characters within the string HTMLcode and replaces them with their escaped values. The less than sign (<), for example, would be replaced with &lt;.
  NumberFormat(number,mask)—Returns number formatted according to the specified mask. For example, a mask of ‘_,___.__’ would produce a number in the form 1,000.00.
  ParagraphFormat(str)—Removes consecutive carriage return and line feed characters from str and replaces them with <P> tags.
  TimeFormat(time,mask)—Formats time according to the specified mask. A mask of hh:mm:ssTT, for example, produces a time in the form 07:25:00AM.

Array Functions

Arrays are a convenient way to store related information for quick reference throughout your template. You create an array with the ArrayNew function. For example:

stats = ArrayNew(2)

creates a new, two-dimensional array. This means the array will have two subscripts: stats[subs1][subs2]. ColdFusion supports one-, two-, and three-dimensional arrays.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.