4 Replies Latest reply on Nov 28, 2013 9:01 AM by duncancumming

    cfif with or problem



      i'm trying to use multiple expressions in a cfif


      <cfif (Evaluate(test.itemcode) is not "HDMI") OR (Evaluate(itemcode) is not "DVI")>

      this should result in returning everything that 's not with hdmi or dvi , right? it doesn't , it returns everything including them

      but when I do:

      <cfif (Evaluate(test.itemcode) is not "HDMI")>

      it excludes the hdmi from the list...

      what am I doing wrong?

        • 1. Re: cfif with or problem
          duncancumming Level 3

          Don't use evaluate!  And I think you should be using an AND instead of an OR (I might have misunderstood your requirements though)


          <cfif test.itemcode is not "HDMI" AND itemcode is not "DVI">

          • 2. Re: cfif with or problem
            Benutti Level 1

            Then why does the evaluate work if there's only 1 requirement?

            Or it has to be.. i want to exclude the hdmi and dvi



            Verzonden vanaf Samsung Mobile



            • 3. Re: cfif with or problem
              Benutti Level 1

              ok , i did a litle more testing... as I thought already , the evaluate didn't do anything wrong and is needed because of some other code...
              you were right on the other hand on the OR ... i changed it to AND ... and magic happened.... still baffled why though...

              if i was writing diagrams it would've been or... because:

              if the item in the loop is not hdmi or dvi or ....

                   do this


              so it seemed more logical to me that way

              • 4. Re: cfif with or problem
                duncancumming Level 3

                I very much doubt that evaluate() is really required.  There's usually better ways to do the same thing, and is generally considered bad practice to use it among CF developers these days.


                Regardless, yes, you're correct.  The problem was really bad boolean logic.  Replacing OR with AND is correct.