|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi
have a problem, wondered if anyone could help. I think the best way of explaining is to just show the code I am trying to work, I think the problem is then self explanatary. <cfif (LEFT(neg, 2) EQ "AV" AND access GTE 4) OR (LEFT(neg, 2) NEQ "AV" or "DG" AND status GTE 4)> (left neg, 2 does not equal either "av" or "dg") AND status of the rest must be gte 4 Thanks |
|
#2
|
|||
|
|||
|
<cfif (LEFT(neg, 2) EQ "AV" AND access GTE 4) OR (LEFT(neg, 2) NEQ "AV" AND LEFT(neg, 2) NEQ "DG" AND status GTE 4)>
|
|
#3
|
|||
|
|||
|
So, just to make sure I'm hearing you correctly, you would like to evaluate the variables neg and access and check for the following:
if left(neg,2) equals AV and access greater then or equal to 4 then qualify for this statement or if left(neg,2) is not AV or DG but the status is still greater then 4 it's ok to qualify also Right? |
|
#4
|
|||
|
|||
|
Each statement evaluates to true or false. When combined as an expression, the entire expression evaluates to true or false. So,
<cfif (LEFT(neg, 2) EQ "AV" AND access GTE 4) OR (LEFT(neg, 2) NEQ "AV" AND LEFT(neg, 2) NEQ "DG" AND status GTE 4)> means that if the left 2 characters of neg are "AV" and access is GTE 4, then that statement is TRUE. The remainder of the statement does not even execute. However, if it is FALSE, then the remainder is executed. In that case, if the left 2 characters of neg are NOT "AV", and the left 2 characters of neg are NOT "DG", and the statues is GTE 4, then that statement is TRUE. If neither of these two sets evaluate to TRUE, the if block is not executed. Personally, when you start getting into convoluted logic like this to make a decision, that is a red flag to me that something should be simplified or refactored. But that is another topic. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > cfif(left( , 2)) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|