home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / compare.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  1.2 KB  |  60 lines

  1. <!--- This example shows the use of compare --->
  2. <HTML>
  3.  
  4. <HEAD>
  5. <TITLE>
  6. Compare Example
  7. </TITLE>
  8. </HEAD>
  9.  
  10. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  11. <BODY  bgcolor="#FFFFD5">
  12.  
  13. <H3>Compare Example</H3>
  14.  
  15. <P>The compare function performs a <I>case-sensitive</I>
  16. comparison of two strings.
  17.  
  18.  
  19. <CFIF IsDefined("form.string1")>
  20.  
  21. <CFSET comparison = Compare(form.string1, form.string2)>
  22.  
  23. <!--- switch on the variable to give various responses --->
  24. <CFSWITCH EXPRESSION=#comparison#>
  25.     <CFCASE value="-1">
  26.         <H3>String 1 is less than String 2</H3>
  27.         <I>The strings are not equal</I>
  28.     </CFCASE>
  29.     <CFCASE value="0">
  30.         <H3>String 1 is equal to String 2</H3>
  31.         <I>The strings are equal!</I>
  32.     </CFCASE>
  33.     <CFCASE value="1">
  34.         <H3>String 1 is greater than String 2</H3>
  35.         <I>The strings are not equal</I>
  36.     </CFCASE>
  37.     <CFDEFAULTCASE>
  38.         <H3>This is the default case</H3>
  39.     </CFDEFAULTCASE>
  40. </CFSWITCH>
  41.  
  42.  
  43. </CFIF>
  44.  
  45. <FORM ACTION="compare.cfm" METHOD="POST">
  46. <P>String 1
  47. <BR><INPUT TYPE="Text" NAME="string1">
  48.  
  49. <P>String 2
  50. <BR><INPUT TYPE="Text" NAME="string2">
  51.  
  52. <P><INPUT TYPE="Submit" VALUE="Compare these Strings" NAME=""> <INPUT TYPE="RESET">
  53.  
  54. </FORM>
  55.  
  56.  
  57. </BODY>
  58.  
  59. </HTML>       
  60.