home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Documentation / snippets / compare.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  1.1 KB  |  59 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. <BODY bgcolor=silver>
  11.  
  12. <H3>Compare Example</H3>
  13.  
  14. <P>The compare function performs a <I>case-sensitive</I>
  15. comparison of two strings.
  16.  
  17.  
  18. <CFIF IsDefined("form.string1")>
  19.  
  20. <CFSET comparison = Compare("#form.string1#", "#form.string2#")>
  21.  
  22. <!--- switch on the variable to give various responses --->
  23. <CFSWITCH EXPRESSION=#comparison#>
  24.     <CFCASE value="-1">
  25.         <H3>String 1 is less than String 2</H3>
  26.         <I>The strings are not equal</I>
  27.     </CFCASE>
  28.     <CFCASE value="0">
  29.         <H3>String 1 is equal to String 2</H3>
  30.         <I>The strings are equal!</I>
  31.     </CFCASE>
  32.     <CFCASE value="1">
  33.         <H3>String 1 is greater than String 2</H3>
  34.         <I>The strings are not equal</I>
  35.     </CFCASE>
  36.     <CFDEFAULTCASE>
  37.         <H3>This is the default case</H3>
  38.     </CFDEFAULTCASE>
  39. </CFSWITCH>
  40.  
  41.  
  42. </CFIF>
  43.  
  44. <FORM ACTION="compare.cfm" METHOD="POST">
  45. <P>String 1
  46. <BR><INPUT TYPE="Text" NAME="string1">
  47.  
  48. <P>String 2
  49. <BR><INPUT TYPE="Text" NAME="string2">
  50.  
  51. <P><INPUT TYPE="Submit" VALUE="Compare these Strings" NAME=""> <INPUT TYPE="RESET">
  52.  
  53. </FORM>
  54.  
  55.  
  56. </BODY>
  57.  
  58. </HTML>       
  59.