ColdFusion
  Home arrow ColdFusion arrow Page 2 - What You Must Know About Operators in Cold...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
COLDFUSION

What You Must Know About Operators in ColdFusion!
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 2 stars2 stars2 stars2 stars2 stars / 7
    2005-08-22

    Table of Contents:
  • What You Must Know About Operators in ColdFusion!
  • Conditional Operators
  • Logical Operators
  • String Operator

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    What You Must Know About Operators in ColdFusion! - Conditional Operators


    (Page 2 of 4 )

    The next table shows the details of the conditional operators available and their usage. The evaluated value of the operation is Boolean (true or false). If the condition is satisfied, the expression yields a True, otherwise it yields a false. Again, although true means 'Yes', as well as any non-zero number, make sure the version supports it. For example 'Yes' and 'No' are not supported in MX 6.1. This is the reason they have been defined in the example shown, conditional.cfm.

    Notice that the output to the screen contains both the text portion as well as the evaluated value. However WriteOutput(#x# IS #y#); should print to screen, the evaluated value of the conditional expression. Again, unlike JavaScript, the greater than and less than are using the literal values, instead of > and <.

    All of these operators produce a Boolean outcome: NO, or YES.

    Operator Description Example & Comments
    IS Case-insensitive comparison of the two values; returns true if the values are identical.
      All of these mean the same thing 
    • #x# IS #y#
    • #x# EQUAL #y#
    • #x# EQ #y#
    IS NOT Behavior opposite to that of IS
      All of these mean the same thing 
    • #x# IS NOT #y#
    • #x# NOT EQUAL #y#
    • #x# NEQ #y#
    CONTAINS Checks to see if the value on the left is contained in the value on the right; returns true if it is. #x# CONTAINS #y#
    Pertinent to strings

     

    Example: "Welcome" contains "come"
    Does Not Contain Behavior opposite to that of Contains #x# DOES NOT CONTAIN #y#
    Pertinent to strings
    GREATER THAN Checks to see if the value on the left is greater than the value on the right; returns true if it is.
      Both of these mean the same thing 
    • #x# GREATER THAN #y#
    • #x# GT #y#
      can be used with both text and numbers
    LESS THAN Behavior opposite to that of Greater than
      Both of these mean the same thing 
    • #x# LESS THAN #y#
    • #x# LT #y#
      can be used with both text and numbers
    GREATER THAN OR EQUAL TO Checks to see if the value on the left is greater than or equal to the value on the right;  returns true if it is.
      All of these mean the same thing 
    • #x# GREATER THAN OR EQUAL TO #y#
    • #x# GTE #y#
    • #x# GE #y#
    LESS THAN OR EQUAL TO Checks to see if the value on the left is less than or equal to the value on the right; returns true if it is.
      All of these mean the same thing
    • #x# LESS THAN OR EQUAL TO #y#
    • #x# LTE #y#
    • #x# LE #y#
    Example using operators

    The following example assumes a number of variables, of simple types, string and number, and evaluates the outcome of performing conditional operations using the CF MAX conditional operators. The output is written to screen. The output contains the text part of the argument as well as the Boolean part of the argument. Hence the function evaluate was used. The next screen shot shows the code in Sapien's color coded screen. Color coding helps a lot in weeding out the code.

     

    The output of this code shows the evaluated values, in the next picture.

     

    More ColdFusion Articles
    More By Jayaram Krishnaswamy


       · Sitting at an undetermined distance from the readers, the single, most important...
     

    COLDFUSION ARTICLES

    - How to Access a SQL Anywhere Database with C...
    - CFXML: Probing XMLDOM in ColdFusion
    - Creating a Web Service with ColdFusion: the ...
    - CFAjax: What it is and How to Use it
    - Querying SQL 2000 Server from ColdFusion
    - Introduction to ColdFusion Markup Language, ...
    - Introduction to ColdFusion Markup Language
    - Databases and Dreamweaver MX 2004, concluded
    - Databases and Dreamweaver MX 2004
    - Welcome to Coldfusion MX 6.1, concluded
    - Welcome to Coldfusion MX 6.1
    - What You Must Know About ColdFusion Flow-Con...
    - What You Must Know About Operators in ColdFu...
    - Everything You Must Know About ColdFusion Va...
    - My First Application on ColdFusion MX Server






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT