home *** CD-ROM | disk | FTP | other *** search
- <!--- This example shows the use of compare --->
- <HTML>
-
- <HEAD>
- <TITLE>
- Compare Example
- </TITLE>
- </HEAD>
-
- <BASEFONT FACE="Arial, Helvetica" SIZE=2>
- <BODY bgcolor="#FFFFD5">
-
- <H3>Compare Example</H3>
-
- <P>The compare function performs a <I>case-sensitive</I>
- comparison of two strings.
-
-
- <CFIF IsDefined("form.string1")>
-
- <CFSET comparison = Compare(form.string1, form.string2)>
-
- <!--- switch on the variable to give various responses --->
- <CFSWITCH EXPRESSION=#comparison#>
- <CFCASE value="-1">
- <H3>String 1 is less than String 2</H3>
- <I>The strings are not equal</I>
- </CFCASE>
- <CFCASE value="0">
- <H3>String 1 is equal to String 2</H3>
- <I>The strings are equal!</I>
- </CFCASE>
- <CFCASE value="1">
- <H3>String 1 is greater than String 2</H3>
- <I>The strings are not equal</I>
- </CFCASE>
- <CFDEFAULTCASE>
- <H3>This is the default case</H3>
- </CFDEFAULTCASE>
- </CFSWITCH>
-
-
- </CFIF>
-
- <FORM ACTION="compare.cfm" METHOD="POST">
- <P>String 1
- <BR><INPUT TYPE="Text" NAME="string1">
-
- <P>String 2
- <BR><INPUT TYPE="Text" NAME="string2">
-
- <P><INPUT TYPE="Submit" VALUE="Compare these Strings" NAME=""> <INPUT TYPE="RESET">
-
- </FORM>
-
-
- </BODY>
-
- </HTML>
-