6 Replies Latest reply on Dec 1, 2006 7:48 AM by Dan Bracuk

    2 conditional

    TommyMTL Level 1
      I need to check for a minimum of two condition

      <cfif IsDefined ("MyString") and MyString NEQ "ABC" OR IsDefined ("MyString") and MyString NEQ "CBA">
      Do something
      </cfif>
      It should evaluate both and If one or the other match then criterias the it does not display the message "Do Something"


      Is is obviousely not working, what would be the work around?

      many thanks
        • 1. Re: 2 conditional
          Level 7
          TommyMTL wrote:
          > I need to check for a minimum of two condition
          >
          > <cfif IsDefined ("MyString") and MyString NEQ "ABC" OR IsDefined ("MyString")
          > and MyString NEQ "CBA">
          > Do something
          > </cfif>


          <cfif IsDefined("MyString") AND (MyString NEQ "ABC" AND MyString NEQ "CBA")>
          Do something
          </cfif>
          • 2. Re: 2 conditional
            Dan Bracuk Level 5
            You need nested cfif tags. The outer one checks for isDefined and the inner one checks the value of the string. Otherwise it will crash if the variable is not defined.
            • 3. Re: 2 conditional
              Level 7
              Dan Bracuk wrote:
              > You need nested cfif tags. The outer one checks for isDefined and the inner
              > one checks the value of the string. Otherwise it will crash if the variable
              > is not defined.

              not anymore, cf has had boolean short circuiting for a couple of versions.
              • 4. Re: 2 conditional
                TommyMTL Level 1
                <cfif IsDefined("MyString") AND (MyString NEQ "ABC" AND MyString NEQ "CBA")>
                Do something
                </cfif>

                In this example,
                MyString must be defind, must not equal "ABC" and must not equal "CBA"
                Shouls it not cointain an OR somewhere?
                What I need is something that will do

                "ABC" OR "CBA"

                thanks
                • 5. Re: 2 conditional
                  Level 7
                  TommyMTL wrote:
                  > <cfif IsDefined("MyString") AND (MyString NEQ "ABC" AND MyString NEQ "CBA")>
                  > Do something
                  > </cfif>
                  >
                  > In this example,
                  > MyString must be defind, must not equal "ABC" and must not equal "CBA"

                  you just said it yourself...AND

                  > Shouls it not cointain an OR somewhere?
                  > What I need is something that will do
                  >
                  > "ABC" OR "CBA"

                  then you'll get both, ABC will not equal CBA & CBA will not equal ABC.
                  • 6. Re: 2 conditional
                    Dan Bracuk Level 5
                    quote:

                    Originally posted by: Newsgroup User
                    Dan Bracuk wrote:
                    > You need nested cfif tags. The outer one checks for isDefined and the inner
                    > one checks the value of the string. Otherwise it will crash if the variable
                    > is not defined.
                    not anymore, cf has had boolean short circuiting for a couple of versions.


                    Well whaddya know?