1 / 27

ColdFusion Basics (Cont’d)

ColdFusion Basics (Cont’d). 321483 02-14-2002. String, Date-time and Boolean Variables. In addition to numeric variables, ColdFusion can use string , date-time , and Boolean type variables ColdFusion provides a number of useful string, date-time, and Boolean functions. String Variables.

kalkin
Télécharger la présentation

ColdFusion Basics (Cont’d)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ColdFusion Basics (Cont’d) 321483 02-14-2002

  2. String, Date-time and Boolean Variables • In addition to numeric variables, ColdFusion can use string, date-time, and Boolean type variables • ColdFusion provides a number of useful string, date-time, and Boolean functions

  3. String Variables • Strings: • Strings are groupings of text • String Variables: • String variables allow you to store text data • String variables follow the same naming conventions of numeric variables

  4. String Variables and <CFSET> • You can assign a string variable a value using the CFSET tag • Example: <CFSET City=“Clarkson University"> “Clarkson University” is also called a string literal

  5. String Variables and <CFSET> • If you want to include a quotation mark in a string you must type two together • Example: <CFSET Name="William ""Buck"" Rogers"> stores William "Buck" Rogers in Name

  6. String variables and <CFOUTPUT> • String variables can be displayed just like numeric variables – using the CFOUTPUT tag and # • ColdFusion substitutes values of variables and functions enclosed in pound signs (#) in string literals • Quotation marks used in the CFSET tag are NOT displayed • They are delimiters for string literals and NOT part of the actual text

  7. Using String Expressions • ColdFusion allows you to form string expressions by using string variables and a string operator • The most useful operator is concatenate (&) which connects one string to another • Example 1:<CFSET FirstName=“Koffi "><CFSET LastName=“N'Da"><CFSET FullName = FirstName & LastName> This stores the string “Koffi N’Da" in the FullName variable

  8. Using String Expressions • Example 2: <CFSET PricePhrase="The price is #DollarFormat(Price)#"> store the phrase "The price is $1,300.00" in string variable PricePhrase, assuming numeric variable Price is 1300.00

  9. Using String Expressions • Unlike other programming languages ColdFusion lets you create string literals that span multiple lines • Example: "Pet" is a valid string literal, the carriage returns are stored after each letter

  10. String Functions

  11. String Functions

  12. String Functions Click here to have detailed information on string functions

  13. Date-Time Values and Variables • You can also create variables in ColdFusion that store date and time values • Date and times can range from 100 A.D to 9999 A.D. • For more details on date-time functions: http://nongmon.compsci.buu.ac.th/cfdocs/CFML_Reference/

  14. Creating a date-time Variable • You need to use the CreateDateTime function to create a new date-time variable • Click the link below for more information on the CreateDateTime function

  15. Creating a date-time Variable • Example <CFSET LastUpdate = CreateDateTime(2003,5,19,14,15,50)> Assigns the date 5/19/2003 and time 14:15:50 to the date-time variable LastUpdate

  16. Formatting a Date-time Variable • DateFormat Function • You can use the DateFormat and TimeFormat functions to change the way a date/time is displayed • Takes two parameters, a date-time value and a mask • The mask contains letters that signify different kinds of formatting • Click links below for syntaxes: • DateFormat syntax • TimeFormat syntax

  17. Date Format Masks

  18. Date Format Masks

  19. Time Format Masks

  20. Time Format Masks

  21. Using DateFormat and TimeFormat • Examples • <CFOUTPUT>#DateFormat(LastUpdate,"mmmm d, yyyy")#</CFOUTPUT>Displays: May 1, 2003 • <CFOUTPUT>#TimeFormat(LastUpdate,"hh:mm:sstt")#</CFOUTPUT>Displays: 02:15:50PM

  22. Date-Time Operations

  23. Date-Time Operations Click here to have detailed information on date-time functions

  24. Boolean Variables • Boolean Data • Represents a status or a situation, such as True or False • Boolean Variables • A Boolean variable can store only two possible values : • True (Yes or On) • False (No or Off) • You can use Boolean variables where a program must take an action depending on a condition

  25. Boolean Functions Click here to have detailed information on Boolean functions

  26. Typeless Expression Evaluation • Unlike traditional programming languages ColdFusion can evaluate an expression even if operands and operators are of different types • Arguments are converted into required data types, as long as the data is reasonable

  27. Exercise

More Related